kopia lustrzana https://github.com/cheeaun/phanpy
If self, don't need to get familiar followers
rodzic
62201b0250
commit
5ac255f808
|
@ -1,7 +1,7 @@
|
||||||
import './account-info.css';
|
import './account-info.css';
|
||||||
|
|
||||||
import { Menu, MenuDivider, MenuItem, SubMenu } from '@szhsin/react-menu';
|
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 { api } from '../utils/api';
|
||||||
import enhanceContent from '../utils/enhance-content';
|
import enhanceContent from '../utils/enhance-content';
|
||||||
|
@ -62,6 +62,11 @@ function AccountInfo({
|
||||||
const isString = typeof account === 'string';
|
const isString = typeof account === 'string';
|
||||||
const [info, setInfo] = useState(isString ? null : account);
|
const [info, setInfo] = useState(isString ? null : account);
|
||||||
|
|
||||||
|
const isSelf = useMemo(
|
||||||
|
() => account.id === store.session.get('currentAccount'),
|
||||||
|
[account?.id],
|
||||||
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isString) {
|
if (!isString) {
|
||||||
setInfo(account);
|
setInfo(account);
|
||||||
|
@ -128,6 +133,8 @@ function AccountInfo({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
const results = await followersIterator.current.next();
|
const results = await followersIterator.current.next();
|
||||||
|
if (isSelf) return results;
|
||||||
|
|
||||||
const { value } = results;
|
const { value } = results;
|
||||||
let newValue = [];
|
let newValue = [];
|
||||||
// On first load, fetch familiar followers, merge to top of results' `value`
|
// On first load, fetch familiar followers, merge to top of results' `value`
|
||||||
|
|
Ładowanie…
Reference in New Issue