If self, don't need to get familiar followers

pull/228/head
Lim Chee Aun 2023-09-13 18:43:46 +08:00
rodzic 62201b0250
commit 5ac255f808
1 zmienionych plików z 8 dodań i 1 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
import './account-info.css';
import { Menu, MenuDivider, MenuItem, SubMenu } from '@szhsin/react-menu';
import { useEffect, useReducer, useRef, useState } from 'preact/hooks';
import { useEffect, useMemo, useReducer, useRef, useState } from 'preact/hooks';
import { api } from '../utils/api';
import enhanceContent from '../utils/enhance-content';
@ -62,6 +62,11 @@ function AccountInfo({
const isString = typeof account === 'string';
const [info, setInfo] = useState(isString ? null : account);
const isSelf = useMemo(
() => account.id === store.session.get('currentAccount'),
[account?.id],
);
useEffect(() => {
if (!isString) {
setInfo(account);
@ -128,6 +133,8 @@ function AccountInfo({
});
}
const results = await followersIterator.current.next();
if (isSelf) return results;
const { value } = results;
let newValue = [];
// On first load, fetch familiar followers, merge to top of results' `value`