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 { 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

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

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