Merge pull request #87 from Bilb/fix-kee-issue-1

fix: disable remove button if no members selected to be removed
pull/3281/head
Audric Ackermann 1 month ago committed by GitHub
commit e4685d5ef1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,6 +6,7 @@ import { isSignWithRecoveryPhrase } from '../util/storage';
import { Flex } from './basic/Flex';
import { Spacer2XL, SpacerXS } from './basic/Text';
import { Localizer } from './basic/Localizer';
import { useShowOnboardingAccountJustCreated } from '../state/selectors/settings';
const StyledPlaceholder = styled(Flex)`
background-color: var(--background-secondary-color);
@ -72,8 +73,8 @@ export const EmptyMessageView = () => {
const conversationCount = useSelector(getLeftPaneConversationIdsCount);
const isSignInWithRecoveryPhrase = isSignWithRecoveryPhrase();
const launchCount = window.getSettingValue('launch-count');
const newAccountCreated = !isSignInWithRecoveryPhrase && (!launchCount || launchCount < 1);
const showOnboardingAccountJustCreated = useShowOnboardingAccountJustCreated();
const newAccountCreated = !isSignInWithRecoveryPhrase && showOnboardingAccountJustCreated;
return (
<StyledPlaceholder

@ -104,14 +104,22 @@ async function setupLeftPane(forceUpdateInboxComponent: () => void) {
window.inboxStore?.dispatch(
updateAllOnStorageReady({
hasBlindedMsgRequestsEnabled: Storage.getBoolOrFalse(
SettingsKey.hasBlindedMsgRequestsEnabled
hasBlindedMsgRequestsEnabled: Storage.getBoolOr(
SettingsKey.hasBlindedMsgRequestsEnabled,
false
),
someDeviceOutdatedSyncing: Storage.getBoolOr(SettingsKey.someDeviceOutdatedSyncing, false),
settingsLinkPreview: Storage.getBoolOr(SettingsKey.settingsLinkPreview, false),
hasFollowSystemThemeEnabled: Storage.getBoolOr(
SettingsKey.hasFollowSystemThemeEnabled,
false
),
hasShiftSendEnabled: Storage.getBoolOr(SettingsKey.hasShiftSendEnabled, false),
hideRecoveryPassword: Storage.getBoolOr(SettingsKey.hideRecoveryPassword, false),
showOnboardingAccountJustCreated: Storage.getBoolOr(
SettingsKey.showOnboardingAccountJustCreated,
true
),
someDeviceOutdatedSyncing: Storage.getBoolOrFalse(SettingsKey.someDeviceOutdatedSyncing),
settingsLinkPreview: Storage.getBoolOrFalse(SettingsKey.settingsLinkPreview),
hasFollowSystemThemeEnabled: Storage.getBoolOrFalse(SettingsKey.hasFollowSystemThemeEnabled),
hasShiftSendEnabled: Storage.getBoolOrFalse(SettingsKey.hasShiftSendEnabled),
hideRecoveryPassword: Storage.getBoolOrFalse(SettingsKey.hideRecoveryPassword),
})
);
window.inboxStore?.dispatch(groupInfoActions.loadMetaDumpsFromDB() as any); // this loads the dumps from DB and fills the 03-groups slice with the corresponding details

@ -264,7 +264,7 @@ export const UpdateGroupMembersDialog = (props: Props) => {
onClick={onClickOK}
buttonType={SessionButtonType.Simple}
buttonColor={SessionButtonColor.Danger}
disabled={isProcessingUIChange}
disabled={isProcessingUIChange || !membersToRemove.length}
dataTestId="session-confirm-ok-button"
/>
)}

@ -21,6 +21,7 @@ const hideRecoveryPassword = 'hideRecoveryPassword';
const latestUserProfileEnvelopeTimestamp = 'latestUserProfileEnvelopeTimestamp';
const latestUserGroupEnvelopeTimestamp = 'latestUserGroupEnvelopeTimestamp';
const latestUserContactsEnvelopeTimestamp = 'latestUserContactsEnvelopeTimestamp';
const showOnboardingAccountJustCreated = 'showOnboardingAccountJustCreated';
export const SettingsKey = {
settingsReadReceipt,
@ -44,6 +45,7 @@ export const SettingsKey = {
latestUserContactsEnvelopeTimestamp,
hasFollowSystemThemeEnabled,
hideRecoveryPassword,
showOnboardingAccountJustCreated,
} as const;
export const KNOWN_BLINDED_KEYS_ITEM = 'KNOWN_BLINDED_KEYS_ITEM';

@ -715,10 +715,46 @@ export class SwarmPolling {
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();
// Well, here we are again putting bandaids to deal with our flaky backend.
// Sometimes (often I'd say), a snode is out of sync with its swarm but still replies with what he thinks is the swarm's content.
// So, here we've fetched from a snode that has no lastHash, and after the fetch we still have no lastHash.
// A normally constituted human would understand this as "there is nothing on that swarm for that pubkey".
// Well, sometimes we just hit one of those out-of-sync snode and it is telling us the swarm is empty, when for every other snode of the swarm, it is not.
// This isn't usually too bad, because usually not having a fetch result just means we will fetch the another snode next time.
// But sometimes we have destructive actions or here, show a banner.
// Ideally, we'd fix this on the backend, but until then I am writing one more bandaid here.
// The bandaid is checking if we've already fetched from any other snode a last hash for the keys namespace.
// If yes, we know that the snode we just polled from reports incorrectly that the swarm to be empty.
const swarmSnodes = await SnodePool.getSwarmFor(pubkey);
let foundAtLeastAHashInSwarm = false;
let swarmIndex = 0;
do {
const lastHash = await this.getLastHash(
swarmSnodes[swarmIndex].pubkey_ed25519,
pubkey,
SnodeNamespaces.ClosedGroupKeys
);
if (lastHash) {
foundAtLeastAHashInSwarm = true;
break; // breaking so the swarmIndex is correct here
}
swarmIndex++;
} while (swarmIndex < swarmSnodes.length);
if (foundAtLeastAHashInSwarm) {
// considering that group as not expired
window.log.info(
`no configs before and after fetch of group: ${ed25519Str(pubkey)} from snode ${ed25519Str(snodeEdkey)}, but another snode has config hash fetched already (${ed25519Str(swarmSnodes?.[swarmIndex]?.pubkey_ed25519)}). Group is not expired.`
);
} else {
// the group appears to be expired.
window.log.warn(
`no configs before and after fetch of group: ${ed25519Str(pubkey)} from snode ${ed25519Str(snodeEdkey)}, and no other snode have one either. Group is expired.`
);
if (!convo.getIsExpired03Group()) {
convo.set({ isExpired03Group: true });
await convo.commit();
}
}
} else if (convo.getIsExpired03Group()) {
window.log.info(

@ -28,6 +28,8 @@ import { CONVERSATION_PRIORITIES, ConversationTypeEnum } from '../../models/type
import { WithConvoId, WithMessageHash, WithMessageId } from '../../session/types/with';
import { cancelUpdatesToDispatch } from '../../models/message';
import type { SessionSuggestionDataItem } from '../../components/conversation/composition/types';
import { Storage } from '../../util/storage';
import { SettingsKey } from '../../data/settings-key';
export type MessageModelPropsWithoutConvoProps = {
propsForMessage: PropsForMessageWithoutConvoProps;
@ -1107,6 +1109,10 @@ export async function openConversationWithMessages(args: {
}) {
const { conversationKey, messageId } = args;
if (Storage.getBoolOr(SettingsKey.showOnboardingAccountJustCreated, true)) {
await Storage.put(SettingsKey.showOnboardingAccountJustCreated, false);
}
await DisappearingMessages.destroyExpiredMessages();
await unmarkAsForcedUnread(conversationKey);

@ -10,6 +10,7 @@ const SettingsBoolsKeyTrackedInRedux = [
SettingsKey.hasFollowSystemThemeEnabled,
SettingsKey.hasShiftSendEnabled,
SettingsKey.hideRecoveryPassword,
SettingsKey.showOnboardingAccountJustCreated,
] as const;
export type SettingsState = {
@ -25,6 +26,7 @@ export function getSettingsInitialState() {
hasFollowSystemThemeEnabled: false,
hasShiftSendEnabled: false,
hideRecoveryPassword: false,
showOnboardingAccountJustCreated: true,
},
};
}
@ -56,6 +58,7 @@ const settingsSlice = createSlice({
hasFollowSystemThemeEnabled: boolean;
hasShiftSendEnabled: boolean;
hideRecoveryPassword: boolean;
showOnboardingAccountJustCreated: boolean;
}>
) {
const {
@ -65,6 +68,7 @@ const settingsSlice = createSlice({
someDeviceOutdatedSyncing,
hasShiftSendEnabled,
hideRecoveryPassword,
showOnboardingAccountJustCreated,
} = payload;
state.settingsBools.someDeviceOutdatedSyncing = someDeviceOutdatedSyncing;
@ -73,6 +77,7 @@ const settingsSlice = createSlice({
state.settingsBools.hasFollowSystemThemeEnabled = hasFollowSystemThemeEnabled;
state.settingsBools.hasShiftSendEnabled = hasShiftSendEnabled;
state.settingsBools.hideRecoveryPassword = hideRecoveryPassword;
state.settingsBools.showOnboardingAccountJustCreated = showOnboardingAccountJustCreated;
return state;
},

@ -20,6 +20,9 @@ const getHasShiftSendEnabled = (state: StateType) =>
const getHideRecoveryPassword = (state: StateType) =>
state.settings.settingsBools[SettingsKey.hideRecoveryPassword];
const getShowOnboardingAccountJustCreated = (state: StateType) =>
state.settings.settingsBools[SettingsKey.showOnboardingAccountJustCreated];
export const useHasLinkPreviewEnabled = () => {
const value = useSelector(getLinkPreviewEnabled);
return Boolean(value);
@ -51,3 +54,9 @@ export const useHideRecoveryPasswordEnabled = () => {
return Boolean(value);
};
export const useShowOnboardingAccountJustCreated = () => {
const value = useSelector(getShowOnboardingAccountJustCreated);
return Boolean(value);
};

@ -93,12 +93,12 @@ function reset() {
items = Object.create(null);
}
function getBoolOrFalse(settingsKey: string): boolean {
const got = Storage.get(settingsKey, false);
function getBoolOr(settingsKey: string, fallback: boolean): boolean {
const got = Storage.get(settingsKey, fallback);
if (isBoolean(got)) {
return got;
}
return false;
return fallback;
}
export async function setLocalPubKey(pubkey: string) {
@ -171,4 +171,4 @@ export function getPasswordHash() {
return Storage.get('passHash') as string;
}
export const Storage = { fetch, put, get, getBoolOrFalse, remove, onready, reset };
export const Storage = { fetch, put, get, getBoolOr, remove, onready, reset };

Loading…
Cancel
Save