diff --git a/net/web/src/AppContext/useAccountContext.hook.js b/net/web/src/AppContext/useAccountContext.hook.js index e03371dd..b4f90fe3 100644 --- a/net/web/src/AppContext/useAccountContext.hook.js +++ b/net/web/src/AppContext/useAccountContext.hook.js @@ -4,6 +4,7 @@ import { getAccountStatus } from '../Api/getAccountStatus'; export function useAccountContext() { const [state, setState] = useState({ + init: false, status: null, }); const access = useRef(null); @@ -18,7 +19,7 @@ export function useAccountContext() { if (next.current == null) { if (revision.current != rev) { let status = await getAccountStatus(access.current); - updateState({ status }); + updateState({ init: true, status }); revision.current = rev; } if (next.current != null) { diff --git a/net/web/src/AppContext/useCardContext.hook.js b/net/web/src/AppContext/useCardContext.hook.js index 089fe163..49a4f569 100644 --- a/net/web/src/AppContext/useCardContext.hook.js +++ b/net/web/src/AppContext/useCardContext.hook.js @@ -20,6 +20,7 @@ import { removeCard } from '../Api/removeCard'; export function useCardContext() { const [state, setState] = useState({ + init: false, cards: new Map(), }); const access = useRef(null); @@ -86,14 +87,11 @@ export function useCardContext() { } if (cur.data.notifiedChannel != card.data.notifiedChannel) { // update remote channels -console.log("UPDATE CHANNEL: ", cur.data.notifiedChannel, card.data.notifiedChannel); - await updateContactChannels(card.id, cur.data.cardProfile.guid, cur.data.cardDetail.token, cur.data.notifiedView, cur.data.notifiedChannel, cur.channels); cur.data.notifiedChannel = card.data.notifiedChannel; } } cur.revision = card.revision; -console.log("SAVE:", cur.data.notifiedChannel); cards.current.set(card.id, cur); } else { @@ -103,8 +101,6 @@ console.log("SAVE:", cur.data.notifiedChannel); } const updateContactChannels = async (cardId, guid, token, viewRevision, channelRevision, channelMap) => { -console.log("UPDATE CONTACT CHANNELS: ", viewRevision, channelRevision); - let delta = await getContactChannels(guid + "." + token, viewRevision, channelRevision); for (let channel of delta) { if (channel.data) { @@ -142,7 +138,7 @@ console.log("UPDATE CONTACT CHANNELS: ", viewRevision, channelRevision); next.current = rev; if (revision.current != rev) { await updateCards(); - updateState({ cards: cards.current }); + updateState({ init: true, cards: cards.current }); revision.current = rev; } let r = next.current; diff --git a/net/web/src/AppContext/useChannelContext.hook.js b/net/web/src/AppContext/useChannelContext.hook.js index 4e57dddf..ed7e64e9 100644 --- a/net/web/src/AppContext/useChannelContext.hook.js +++ b/net/web/src/AppContext/useChannelContext.hook.js @@ -8,6 +8,7 @@ import { getChannelTopic } from '../Api/getChannelTopic'; export function useChannelContext() { const [state, setState] = useState({ + init: false, channels: new Map(), }); const access = useRef(null); @@ -53,7 +54,7 @@ export function useChannelContext() { next.current = rev; if (revision.current != rev) { await updateChannels(); - updateState({ channels: channels.current }); + updateState({ init: true, channels: channels.current }); revision.current = rev; } let r = next.current; diff --git a/net/web/src/AppContext/useGroupContext.hook.js b/net/web/src/AppContext/useGroupContext.hook.js index be5679d8..e2af0ce5 100644 --- a/net/web/src/AppContext/useGroupContext.hook.js +++ b/net/web/src/AppContext/useGroupContext.hook.js @@ -3,6 +3,7 @@ import { getGroups } from '../Api/getGroups'; export function useGroupContext() { const [state, setState] = useState({ + init: false, groups: new Map(), }); const access = useRef(null); @@ -30,7 +31,7 @@ export function useGroupContext() { if (next.current == null) { if (revision.current != rev) { await updateGroups(); - updateState({ groups: groups.current }); + updateState({ init: true, groups: groups.current }); revision.current = rev; } if (next.current != null) { diff --git a/net/web/src/AppContext/useProfileContext.hook.js b/net/web/src/AppContext/useProfileContext.hook.js index 1c529dcd..0893292d 100644 --- a/net/web/src/AppContext/useProfileContext.hook.js +++ b/net/web/src/AppContext/useProfileContext.hook.js @@ -6,6 +6,7 @@ import { getProfileImageUrl } from '../Api/getProfileImageUrl'; export function useProfileContext() { const [state, setState] = useState({ + init: false, profile: {}, }); const access = useRef(null); @@ -20,7 +21,7 @@ export function useProfileContext() { if (next.current == null) { if (revision.current != rev) { let profile = await getProfile(access.current); - updateState({ profile }); + updateState({ init: true, profile }); revision.current = rev; } if (next.current != null) { diff --git a/net/web/src/User/Contact/useContact.hook.js b/net/web/src/User/Contact/useContact.hook.js index 8b0119ac..33297878 100644 --- a/net/web/src/User/Contact/useContact.hook.js +++ b/net/web/src/User/Contact/useContact.hook.js @@ -148,7 +148,7 @@ export function useContact() { }, }; - useEffect(() => { + const updateContact = () => { let contact = card.actions.getCardByGuid(guid); if (contact) { let profile = contact.data.cardProfile; @@ -201,6 +201,12 @@ export function useContact() { updateState({ status: 'unsaved' }); updateState({ showButtons: { save: true, saveRequest: true }}); } + } + + useEffect(() => { + if (card.state.init) { + updateContact(); + } }, [card, guid]) return { state, actions }; diff --git a/net/web/src/User/Conversation/useConversation.hook.js b/net/web/src/User/Conversation/useConversation.hook.js index 43b3b455..32639b21 100644 --- a/net/web/src/User/Conversation/useConversation.hook.js +++ b/net/web/src/User/Conversation/useConversation.hook.js @@ -101,7 +101,9 @@ export function useConversation() { } useEffect(() => { - updateConversation(); + if (card.state.init && channel.state.init) { + updateConversation(); + } }, [card, channel]); return { state, actions };