tangled
alpha
login
or
join now
alice.mosphere.at
/
phanpy
0
fork
atom
this repo has no description
0
fork
atom
overview
issues
pulls
pipelines
Only show followed hashtags for non-followings
Lim Chee Aun
2 years ago
9983c808
8ce720f3
+29
-2
3 changed files
expand all
collapse all
unified
split
src
pages
following.jsx
utils
relationships.js
timeline-utils.jsx
+5
-1
src/pages/following.jsx
reviewed
···
31
31
const results = await homeIterator.current.next();
32
32
let { value } = results;
33
33
if (value?.length) {
34
34
+
let latestItemChanged = false;
34
35
if (firstLoad) {
36
36
+
if (value[0].id !== latestItem.current) {
37
37
+
latestItemChanged = true;
38
38
+
}
35
39
latestItem.current = value[0].id;
36
40
console.log('First load', latestItem.current);
37
41
}
···
41
45
saveStatus(item, instance);
42
46
});
43
47
value = dedupeBoosts(value, instance);
44
44
-
if (firstLoad) clearFollowedTagsState();
48
48
+
if (firstLoad && latestItemChanged) clearFollowedTagsState();
45
49
assignFollowedTags(value, instance);
46
50
47
51
// ENFORCE sort by datetime (Latest first)
+1
src/utils/relationships.js
reviewed
···
19
19
}
20
20
return acc;
21
21
}, []);
22
22
+
if (!uniqueAccountIds.length) return null;
22
23
23
24
try {
24
25
const relationships = await masto.v1.accounts.relationships.fetch({
+23
-1
src/utils/timeline-utils.jsx
reviewed
···
1
1
import { extractTagsFromStatus, getFollowedTags } from './followed-tags';
2
2
+
import { fetchRelationships } from './relationships';
2
3
import states, { statusKey } from './states';
3
4
import store from './store';
4
5
···
182
183
const followedTags = await getFollowedTags(); // [{name: 'tag'}, {...}]
183
184
if (!followedTags.length) return;
184
185
const { statusFollowedTags } = states;
186
186
+
console.log('statusFollowedTags', statusFollowedTags);
187
187
+
const statusWithFollowedTags = [];
185
188
items.forEach((item) => {
186
189
if (item.reblog) return;
187
190
const { id, content, tags = [] } = item;
···
199
202
return acc;
200
203
}, []);
201
204
if (itemFollowedTags.length) {
202
202
-
statusFollowedTags[sKey] = itemFollowedTags;
205
205
+
// statusFollowedTags[sKey] = itemFollowedTags;
206
206
+
statusWithFollowedTags.push({
207
207
+
item,
208
208
+
sKey,
209
209
+
followedTags: itemFollowedTags,
210
210
+
});
203
211
}
204
212
});
213
213
+
214
214
+
if (statusWithFollowedTags.length) {
215
215
+
const accounts = statusWithFollowedTags.map((s) => s.item.account);
216
216
+
const relationships = await fetchRelationships(accounts);
217
217
+
if (!relationships) return;
218
218
+
219
219
+
statusWithFollowedTags.forEach((s) => {
220
220
+
const { item, sKey, followedTags } = s;
221
221
+
const r = relationships[item.account.id];
222
222
+
if (!r.following) {
223
223
+
statusFollowedTags[sKey] = followedTags;
224
224
+
}
225
225
+
});
226
226
+
}
205
227
}
206
228
207
229
export function clearFollowedTagsState() {