mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-02-25 01:08:50 +01:00
Only show followed hashtags for non-followings
This commit is contained in:
parent
8ce720f305
commit
9983c8086c
3 changed files with 29 additions and 2 deletions
|
@ -31,7 +31,11 @@ function Following({ title, path, id, ...props }) {
|
||||||
const results = await homeIterator.current.next();
|
const results = await homeIterator.current.next();
|
||||||
let { value } = results;
|
let { value } = results;
|
||||||
if (value?.length) {
|
if (value?.length) {
|
||||||
|
let latestItemChanged = false;
|
||||||
if (firstLoad) {
|
if (firstLoad) {
|
||||||
|
if (value[0].id !== latestItem.current) {
|
||||||
|
latestItemChanged = true;
|
||||||
|
}
|
||||||
latestItem.current = value[0].id;
|
latestItem.current = value[0].id;
|
||||||
console.log('First load', latestItem.current);
|
console.log('First load', latestItem.current);
|
||||||
}
|
}
|
||||||
|
@ -41,7 +45,7 @@ function Following({ title, path, id, ...props }) {
|
||||||
saveStatus(item, instance);
|
saveStatus(item, instance);
|
||||||
});
|
});
|
||||||
value = dedupeBoosts(value, instance);
|
value = dedupeBoosts(value, instance);
|
||||||
if (firstLoad) clearFollowedTagsState();
|
if (firstLoad && latestItemChanged) clearFollowedTagsState();
|
||||||
assignFollowedTags(value, instance);
|
assignFollowedTags(value, instance);
|
||||||
|
|
||||||
// ENFORCE sort by datetime (Latest first)
|
// ENFORCE sort by datetime (Latest first)
|
||||||
|
|
|
@ -19,6 +19,7 @@ export async function fetchRelationships(accounts, relationshipsMap = {}) {
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
|
if (!uniqueAccountIds.length) return null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const relationships = await masto.v1.accounts.relationships.fetch({
|
const relationships = await masto.v1.accounts.relationships.fetch({
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { extractTagsFromStatus, getFollowedTags } from './followed-tags';
|
import { extractTagsFromStatus, getFollowedTags } from './followed-tags';
|
||||||
|
import { fetchRelationships } from './relationships';
|
||||||
import states, { statusKey } from './states';
|
import states, { statusKey } from './states';
|
||||||
import store from './store';
|
import store from './store';
|
||||||
|
|
||||||
|
@ -182,6 +183,8 @@ export async function assignFollowedTags(items, instance) {
|
||||||
const followedTags = await getFollowedTags(); // [{name: 'tag'}, {...}]
|
const followedTags = await getFollowedTags(); // [{name: 'tag'}, {...}]
|
||||||
if (!followedTags.length) return;
|
if (!followedTags.length) return;
|
||||||
const { statusFollowedTags } = states;
|
const { statusFollowedTags } = states;
|
||||||
|
console.log('statusFollowedTags', statusFollowedTags);
|
||||||
|
const statusWithFollowedTags = [];
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
if (item.reblog) return;
|
if (item.reblog) return;
|
||||||
const { id, content, tags = [] } = item;
|
const { id, content, tags = [] } = item;
|
||||||
|
@ -199,9 +202,28 @@ export async function assignFollowedTags(items, instance) {
|
||||||
return acc;
|
return acc;
|
||||||
}, []);
|
}, []);
|
||||||
if (itemFollowedTags.length) {
|
if (itemFollowedTags.length) {
|
||||||
statusFollowedTags[sKey] = itemFollowedTags;
|
// statusFollowedTags[sKey] = itemFollowedTags;
|
||||||
|
statusWithFollowedTags.push({
|
||||||
|
item,
|
||||||
|
sKey,
|
||||||
|
followedTags: itemFollowedTags,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (statusWithFollowedTags.length) {
|
||||||
|
const accounts = statusWithFollowedTags.map((s) => s.item.account);
|
||||||
|
const relationships = await fetchRelationships(accounts);
|
||||||
|
if (!relationships) return;
|
||||||
|
|
||||||
|
statusWithFollowedTags.forEach((s) => {
|
||||||
|
const { item, sKey, followedTags } = s;
|
||||||
|
const r = relationships[item.account.id];
|
||||||
|
if (!r.following) {
|
||||||
|
statusFollowedTags[sKey] = followedTags;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function clearFollowedTagsState() {
|
export function clearFollowedTagsState() {
|
||||||
|
|
Loading…
Reference in a new issue