···
BLOCKEDBY = "Blocked By",
22
-
type unfollowRecord = {
22
+
type followRecord = {
let [notices, setNotices] = createSignal<string[]>([], { equals: false });
29
-
let unfollowRecords: unfollowRecord[] = [];
29
+
let unfollowRecords: followRecord[] = [];
const fetchFollows = async (agent: any) => {
···
if (unfollowRecords.length == 0 || preview) {
if (preview) unfollowRecords = [];
78
-
let followRecords = await fetchFollows(agent);
80
-
let followsDID: string[] = [];
81
-
for (let n = 0; n < followRecords.length; n++)
82
-
followsDID[n] = followRecords[n].value.subject;
79
+
const followRecords: followRecord[] = await fetchFollows(agent).then((x) =>
80
+
x.map((x: any) => ({
81
+
did: x.value.subject,
const PROFILES_LIMIT = 25;
86
-
for (let n = 0; n < followsDID.length; n = n + PROFILES_LIMIT) {
87
+
for (let n = 0; n < followRecords.length; n = n + PROFILES_LIMIT) {
const res = await agent.getProfiles({
88
-
actors: followsDID.slice(n, n + PROFILES_LIMIT),
89
+
actors: followRecords.slice(n, n + PROFILES_LIMIT).map((x) => x.did),
91
-
let tmpDID: string[] = [];
92
-
for (let i = 0; i < res.data.profiles.length; i++) {
93
-
tmpDID[i] = res.data.profiles[i].did;
94
-
if (form.blockedby && res.data.profiles[i].viewer?.blockedBy) {
95
-
unfollowRecords.push({
96
-
uri: followRecords[i + n].uri,
97
-
did: followRecords[i + n].value.subject,
98
-
status: RepoStatus.BLOCKEDBY,
101
-
"Found account you are blocked by: " +
102
-
followRecords[i + n].value.subject +
104
-
res.data.profiles[i].handle +
92
+
if (form.blockedby) {
93
+
res.data.profiles.map((x, i) => {
94
+
if (x.viewer?.blockedBy) {
95
+
unfollowRecords.push({
96
+
uri: followRecords[i + n].uri,
98
+
status: RepoStatus.BLOCKEDBY,
101
+
`Found account you are blocked by: ${x.did} (${x.handle})`,
109
-
for (let i = 0; i < PROFILES_LIMIT && n + i < followsDID.length; i++) {
111
-
(form.deleted || form.deactivated) &&
112
-
!tmpDID.includes(followsDID[i + n])
115
-
await agent.getProfile({ actor: followsDID[i + n] });
117
-
if (form.deleted && e.message.includes("not found")) {
118
-
unfollowRecords.push({
119
-
uri: followRecords[i + n].uri,
120
-
did: followRecords[i + n].value.subject,
121
-
status: RepoStatus.DELETED,
124
-
"Found deleted account: " + followRecords[i + n].value.subject,
126
-
} else if (form.deactivated && e.message.includes(" deactivated")) {
127
-
unfollowRecords.push({
128
-
uri: followRecords[i + n].uri,
129
-
did: followRecords[i + n].value.subject,
130
-
status: RepoStatus.DEACTIVATED,
133
-
"Found deactivated account: " +
134
-
followRecords[i + n].value.subject,
107
+
if (form.deleted || form.deactivated) {
109
+
.slice(n, n + PROFILES_LIMIT)
110
+
.filter((record) => {
111
+
if (!res.data.profiles.map((x) => x.did).includes(record.did)) {
112
+
return { did: record.did, uri: record.uri };
115
+
.forEach(async (record) => {
117
+
await agent.getProfile({ actor: record.did });
119
+
if (form.deleted && e.message.includes("not found")) {
120
+
unfollowRecords.push({
123
+
status: RepoStatus.DELETED,
125
+
updateNotices(`Found deleted account: ${record.did}`);
127
+
form.deactivated &&
128
+
e.message.includes(" deactivated")
130
+
unfollowRecords.push({
133
+
status: RepoStatus.DEACTIVATED,
135
+
updateNotices(`Found deactivated account: ${record.did}`);