From 3caf48c6db1472eec585da986687704bbe4ac488 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 18 Feb 2025 17:24:15 +1100 Subject: [PATCH 1/2] fix: do not show group expired banner without a good reason --- ts/session/apis/snode_api/swarmPolling.ts | 37 +++++++++++++++-------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/ts/session/apis/snode_api/swarmPolling.ts b/ts/session/apis/snode_api/swarmPolling.ts index 4830d4260..3bc33be2f 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -703,19 +703,31 @@ export class SwarmPolling { ); return []; } - const noConfigBeforeFetch = namespacesAndLastHashes.some( - m => !m.lastHash && SnodeNamespace.isGroupConfigNamespace(m.namespace) - ); - const noConfigAfterFetch = namespacesAndLastHashesAfterFetch.some( - m => !m.lastHash && SnodeNamespace.isGroupConfigNamespace(m.namespace) - ); + const noConfigBeforeFetch = namespacesAndLastHashes + .filter(m => SnodeNamespace.isGroupConfigNamespace(m.namespace)) + .every(m => !m.lastHash); + + const noConfigAfterFetch = results + .filter(m => SnodeNamespace.isGroupConfigNamespace(m.namespace)) + .every(m => !m.messages.messages?.length); + const convo = ConvoHub.use().get(pubkey); + + if (PubKey.is03Pubkey(pubkey) && convo) { + if (noConfigBeforeFetch && noConfigAfterFetch) { + window.log.warn(`no configs before and after fetch of group: ${ed25519Str(pubkey)}`); + if (!convo.getIsExpired03Group()) { + convo.set({ isExpired03Group: true }); + await convo.commit(); + } + } else if (convo.getIsExpired03Group()) { + window.log.info( + `configs received for group marked as expired: ${ed25519Str(pubkey)}... Marking it unexpired` + ); - if (PubKey.is03Pubkey(pubkey) && noConfigBeforeFetch && noConfigAfterFetch) { - window.log.warn(`no configs before and after fetch of group: ${ed25519Str(pubkey)}`); - const convo = ConvoHub.use().get(pubkey); - if (convo && !convo.get('isExpired03Group')) { - convo.set({ isExpired03Group: true }); + // Group was marked as "expired", but apparently iot is not (we have hashes saved/just fetched). + // Maybe an admin came back online?, anyway mark the group as not expired. + convo.set({ isExpired03Group: false }); await convo.commit(); } } @@ -912,9 +924,8 @@ export class SwarmPolling { this.lastHashes[nodeEdKey][pubkey] = {}; } this.lastHashes[nodeEdKey][pubkey][namespace] = lastHash || ''; - return this.lastHashes[nodeEdKey][pubkey][namespace]; } - // return the cached value + // return the cached value/the one set on the line above return this.lastHashes[nodeEdKey][pubkey][namespace]; } From 2ea43dbf8b63bb3f40d1b6a6ea60e0e603e1d0a5 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Tue, 18 Feb 2025 17:26:26 +1100 Subject: [PATCH 2/2] fix: do not show pointer cursor on unclickable banner --- ts/components/NoticeBanner.tsx | 5 +++-- ts/session/apis/snode_api/swarmPolling.ts | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/ts/components/NoticeBanner.tsx b/ts/components/NoticeBanner.tsx index d21ca90be..fecbb06b0 100644 --- a/ts/components/NoticeBanner.tsx +++ b/ts/components/NoticeBanner.tsx @@ -4,14 +4,14 @@ import { Flex } from './basic/Flex'; import { SessionIconButton, SessionIconType } from './icon'; import { StyledRootDialog } from './dialog/StyledRootDialog'; -const StyledNoticeBanner = styled(Flex)` +const StyledNoticeBanner = styled(Flex)<{ isClickable: boolean }>` background-color: var(--primary-color); color: var(--black-color); font-size: var(--font-size-md); padding: var(--margins-xs) var(--margins-sm); text-align: center; flex-shrink: 0; - cursor: pointer; + cursor: ${props => (props.isClickable ? 'pointer' : 'default')}; .session-icon-button { right: var(--margins-sm); @@ -40,6 +40,7 @@ export const NoticeBanner = (props: NoticeBannerProps) => { justifyContent={'center'} alignItems={'center'} data-testid={dataTestId} + isClickable={!!onBannerClick} onClick={event => { if (!onBannerClick) { return; diff --git a/ts/session/apis/snode_api/swarmPolling.ts b/ts/session/apis/snode_api/swarmPolling.ts index 3bc33be2f..a9138cfd1 100644 --- a/ts/session/apis/snode_api/swarmPolling.ts +++ b/ts/session/apis/snode_api/swarmPolling.ts @@ -725,7 +725,7 @@ export class SwarmPolling { `configs received for group marked as expired: ${ed25519Str(pubkey)}... Marking it unexpired` ); - // Group was marked as "expired", but apparently iot is not (we have hashes saved/just fetched). + // Group was marked as "expired", but apparently it is not (we have hashes saved/just fetched). // Maybe an admin came back online?, anyway mark the group as not expired. convo.set({ isExpired03Group: false }); await convo.commit();