mirror of
https://github.com/balzack/databag.git
synced 2025-02-12 03:29:16 +00:00
fixing contact update notification
This commit is contained in:
parent
fab9aa353a
commit
072ee38211
@ -1,6 +1,7 @@
|
||||
import { useContext, useState, useEffect } from 'react';
|
||||
import { CardContext } from 'context/CardContext';
|
||||
import { ViewportContext } from 'context/ViewportContext';
|
||||
import { StoreContext } from 'context/StoreContext';
|
||||
|
||||
export function useCards() {
|
||||
|
||||
@ -14,6 +15,7 @@ export function useCards() {
|
||||
});
|
||||
|
||||
const card = useContext(CardContext);
|
||||
const store = useContext(StoreContext);
|
||||
const viewport = useContext(ViewportContext);
|
||||
|
||||
const updateState = (value) => {
|
||||
@ -29,6 +31,17 @@ export function useCards() {
|
||||
},
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
let updated;
|
||||
const contacts = Array.from(card.state.cards.values());
|
||||
contacts.forEach(contact => {
|
||||
if (!updated || updated < contact?.data?.cardDetail?.statusUpdated) {
|
||||
updated = contact?.data?.cardDetail?.statusUpdated;
|
||||
}
|
||||
});
|
||||
store.actions.setValue('cards:updated', updated);
|
||||
}, [card]);
|
||||
|
||||
useEffect(() => {
|
||||
const contacts = Array.from(card.state.cards.values());
|
||||
|
||||
|
@ -50,23 +50,15 @@ export function useSession() {
|
||||
}, [viewport]);
|
||||
|
||||
useEffect(() => {
|
||||
const contacts = Array.from(card.state.cards.values());
|
||||
|
||||
let updated;
|
||||
const contacts = Array.from(card.state.cards.values());
|
||||
contacts.forEach(contact => {
|
||||
if (!updated || updated < contact?.data?.cardDetail?.statusUpdated) {
|
||||
updated = contact?.data?.cardDetail?.statusUpdated;
|
||||
}
|
||||
});
|
||||
|
||||
if (state.cards) {
|
||||
cardStatus.current = updated;
|
||||
storeStatus.current = updated;
|
||||
store.actions.setValue('cards:updated', updated);
|
||||
}
|
||||
|
||||
updateState({ cardUpdated: cardStatus.current > storeStatus.current });
|
||||
// eslint-disable-next-line
|
||||
}, [card]);
|
||||
|
||||
useEffect(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user