fix: show account created 🎉 emoji until we open a conversation

pull/3281/head
Audric Ackermann 2 months ago
parent c3a5669ba2
commit 0a7384c1f4
No known key found for this signature in database

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

@ -104,14 +104,22 @@ async function setupLeftPane(forceUpdateInboxComponent: () => void) {
window.inboxStore?.dispatch( window.inboxStore?.dispatch(
updateAllOnStorageReady({ updateAllOnStorageReady({
hasBlindedMsgRequestsEnabled: Storage.getBoolOrFalse( hasBlindedMsgRequestsEnabled: Storage.getBoolOr(
SettingsKey.hasBlindedMsgRequestsEnabled 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 window.inboxStore?.dispatch(groupInfoActions.loadMetaDumpsFromDB() as any); // this loads the dumps from DB and fills the 03-groups slice with the corresponding details

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

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

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

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

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