Skip to content

Commit

Permalink
work on the issue #2452
Browse files Browse the repository at this point in the history
  • Loading branch information
SebinSong committed Dec 11, 2024
1 parent 7b1c2b3 commit c067327
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
13 changes: 9 additions & 4 deletions frontend/controller/actions/group-kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import sbp from '@sbp/sbp'
import { KV_KEYS, LAST_LOGGED_IN_THROTTLE_WINDOW } from '~/frontend/utils/constants.js'
import { KV_QUEUE, ONLINE } from '~/frontend/utils/events.js'

sbp('okTurtles.events/on', ONLINE, () => {
sbp('gi.actions/group/kv/load').catch(e => {
console.error("Error from 'gi.actions/identity/kv/load' after reestablished connection:", e)
})
sbp('okTurtles.events/on', ONLINE, async () => {
try {
const identityContractID = (await sbp('chelonia/rootState')).loggedIn?.identityContractID
if (identityContractID) {
await sbp('gi.actions/group/kv/load')
}
} catch (e) {
console.error("Error from 'gi.actions/group/kv/load' after reestablished connection:", e)
}
})

export default (sbp('sbp/selectors/register', {
Expand Down
13 changes: 9 additions & 4 deletions frontend/controller/actions/identity-kv.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,15 @@ import { isExpired } from '@model/notifications/utils.js'

const initNotificationStatus = (data = {}) => ({ ...data, read: false })

sbp('okTurtles.events/on', ONLINE, () => {
sbp('gi.actions/identity/kv/load').catch(e => {
sbp('okTurtles.events/on', ONLINE, async () => {
try {
const identityContractID = (await sbp('chelonia/rootState')).loggedIn?.identityContractID
if (identityContractID) {
await sbp('gi.actions/identity/kv/load')
}
} catch (e) {
console.error("Error from 'gi.actions/identity/kv/load' after reestablished connection:", e)
})
}
})

export default (sbp('sbp/selectors/register', {
Expand All @@ -25,7 +30,7 @@ export default (sbp('sbp/selectors/register', {
// Using 'chelonia/rootState' here as 'state/vuex/state' is not available
// in the SW, and because, even without a SW, 'loggedIn' is not yet there
// in Vuex state when logging in
const identityContractID = sbp('chelonia/rootState').loggedIn?.identityContractID
const identityContractID = (await sbp('chelonia/rootState')).loggedIn?.identityContractID
if (!identityContractID) {
throw new Error('Unable to fetch chatroom unreadMessages without an active session')
}
Expand Down

0 comments on commit c067327

Please sign in to comment.