Merge pull request #75 from Bilb/fix-banner-expire-shows-by-mistake

fix: do not show group expired banner without a good reason
pull/3281/head
Audric Ackermann 2 months ago committed by GitHub
commit 61515cdd8e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -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;

@ -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 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();
}
}
@ -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];
}

Loading…
Cancel
Save