mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-14 04:08:32 +03:00
Fix loadAcounts firing twice
This commit is contained in:
parent
25ff0d7835
commit
8180cc357e
1 changed files with 4 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
import './generic-accounts.css';
|
||||
|
||||
import { useEffect, useState } from 'preact/hooks';
|
||||
import { useEffect, useRef, useState } from 'preact/hooks';
|
||||
import { InView } from 'react-intersection-observer';
|
||||
import { useSnapshot } from 'valtio';
|
||||
|
||||
|
@ -56,15 +56,18 @@ export default function GenericAccounts({ onClose = () => {} }) {
|
|||
})();
|
||||
};
|
||||
|
||||
const firstLoad = useRef(true);
|
||||
useEffect(() => {
|
||||
if (staticAccounts?.length > 0) {
|
||||
setAccounts(staticAccounts);
|
||||
} else {
|
||||
loadAccounts(true);
|
||||
firstLoad.current = false;
|
||||
}
|
||||
}, [staticAccounts, fetchAccounts]);
|
||||
|
||||
useEffect(() => {
|
||||
if (firstLoad.current) return;
|
||||
// reloadGenericAccounts contains value like {id: 'mute', counter: 1}
|
||||
// We only need to reload if the id matches
|
||||
if (snapStates.reloadGenericAccounts?.id === id) {
|
||||
|
|
Loading…
Add table
Reference in a new issue