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