···
import { BskyAgent } from "@atproto/api";
const [unfollowNotice, setUnfollowNotice] = createSignal("");
7
+
let unfollowURIs: number[] = [];
8
+
let followRecords: any[];
const fetchFollows = async (agent: any) => {
···
···
46
-
const followRecords = await fetchFollows(agent);
49
+
if (!unfollowURIs.length) {
50
+
followRecords = await fetchFollows(agent);
48
-
let followsDID: string[] = [];
49
-
for (let n = 0; n < followRecords.length; n++)
50
-
followsDID[n] = followRecords[n].value.subject;
52
+
let followsDID: string[] = [];
53
+
for (let n = 0; n < followRecords.length; n++)
54
+
followsDID[n] = followRecords[n].value.subject;
52
-
for (let n = 0; n < followsDID.length; n = n + 25) {
53
-
const res = await agent.getProfiles({
54
-
actors: followsDID.slice(n, n + 25),
56
+
for (let n = 0; n < followsDID.length; n = n + 25) {
57
+
const res = await agent.getProfiles({
58
+
actors: followsDID.slice(n, n + 25),
57
-
let tmpDID: string[] = [];
58
-
for (let i = 0; i < res.data.profiles.length; i++) {
59
-
tmpDID[i] = res.data.profiles[i].did;
60
-
if (res.data.profiles[i].viewer?.blockedBy) {
61
-
await agent.deleteFollow(followRecords[i + n].uri);
63
-
"Unfollowed blocked account: " + followRecords[i + n].value.subject,
64
-
" (" + res.data.profiles[i].handle + ")",
68
-
"Unfollowed blocked account: " +
69
-
followRecords[i + n].value.subject +
71
-
res.data.profiles[i].handle +
61
+
let tmpDID: string[] = [];
62
+
for (let i = 0; i < res.data.profiles.length; i++) {
63
+
tmpDID[i] = res.data.profiles[i].did;
64
+
if (res.data.profiles[i].viewer?.blockedBy) {
65
+
unfollowURIs.push(i + n);
66
+
//await agent.deleteFollow(followRecords[i + n].uri);
69
+
"Found blocked account: " +
70
+
followRecords[i + n].value.subject +
72
+
res.data.profiles[i].handle +
76
-
for (let i = 0; i < res.data.profiles.length; i++) {
77
-
if (!tmpDID.includes(followsDID[i + n])) {
78
-
await agent.deleteFollow(followRecords[i + n].uri);
80
-
"Unfollowed deleted account: " + followRecords[i + n].value.subject,
84
-
"Unfollowed deleted account: " +
85
-
followRecords[i + n].value.subject +
77
+
for (let i = 0; i < res.data.profiles.length; i++) {
78
+
if (!tmpDID.includes(followsDID[i + n])) {
79
+
unfollowURIs.push(i + n);
80
+
//await agent.deleteFollow(followRecords[i + n].uri);
83
+
"Found deleted account: " +
84
+
followRecords[i + n].value.subject +
93
+
for (const i of unfollowURIs) {
94
+
await agent.deleteFollow(followRecords[i].uri);
97
+
"Unfollowed account: " +
98
+
followRecords[i].value.subject +
103
+
followRecords = [];
setUnfollowNotice(unfollowNotice() + "Done");
···
127
-
unfollowBsky(userHandle(), appPassword(), serviceURL())
141
+
unfollowBsky(userHandle(), appPassword(), serviceURL(), true)
149
+
unfollowBsky(userHandle(), appPassword(), serviceURL(), false)