improvement: notification feature polished. feature tabs following the same notification socket emmited data to be updated.
This commit is contained in:
@@ -107,21 +107,36 @@ export function OrganizationsPage() {
|
||||
|
||||
const existingRows = items;
|
||||
|
||||
async function loadList() {
|
||||
setLoading(true);
|
||||
toast.setError('');
|
||||
async function loadList(options?: { silent?: boolean }) {
|
||||
const silent = options?.silent ?? false;
|
||||
if (!silent) {
|
||||
setLoading(true);
|
||||
toast.setError('');
|
||||
}
|
||||
try {
|
||||
const res = await organizationApi.list();
|
||||
setItems(res.data.items);
|
||||
} catch (e) {
|
||||
toast.showError(formatApiMessage(e));
|
||||
if (!silent) {
|
||||
toast.showError(formatApiMessage(e));
|
||||
}
|
||||
} finally {
|
||||
setLoading(false);
|
||||
if (!silent) setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
void loadList();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- mount-only
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
const onChanged = () => {
|
||||
void loadList({ silent: true });
|
||||
};
|
||||
window.addEventListener('pending-connections-changed', onChanged);
|
||||
return () => window.removeEventListener('pending-connections-changed', onChanged);
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps -- soft refresh from live inbox
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user