refactor: migrate account-menu to react - implement functionality
- implement different handlers, such as set/change/remove passcode, etc. - setup correct initial values - rename React component
This commit is contained in:
@@ -1,7 +1,5 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// import { AccountMenu2 } from '@/components/AccountMenu';
|
|
||||||
|
|
||||||
declare const __VERSION__: string;
|
declare const __VERSION__: string;
|
||||||
declare const __WEB__: boolean;
|
declare const __WEB__: boolean;
|
||||||
|
|
||||||
@@ -61,7 +59,7 @@ import { SessionsModalDirective } from './components/SessionsModal';
|
|||||||
import { NoAccountWarningDirective } from './components/NoAccountWarning';
|
import { NoAccountWarningDirective } from './components/NoAccountWarning';
|
||||||
import { NoProtectionsdNoteWarningDirective } from './components/NoProtectionsNoteWarning';
|
import { NoProtectionsdNoteWarningDirective } from './components/NoProtectionsNoteWarning';
|
||||||
import { SearchOptionsDirective } from './components/SearchOptions';
|
import { SearchOptionsDirective } from './components/SearchOptions';
|
||||||
import { AccountMenu2 } from './components/AccountMenu2';
|
import { AccountMenuReact } from './components/AccountMenuReact';
|
||||||
import { ConfirmSignoutDirective } from './components/ConfirmSignoutModal';
|
import { ConfirmSignoutDirective } from './components/ConfirmSignoutModal';
|
||||||
import { MultipleSelectedNotesDirective } from './components/MultipleSelectedNotes';
|
import { MultipleSelectedNotesDirective } from './components/MultipleSelectedNotes';
|
||||||
import { NotesContextMenuDirective } from './components/NotesContextMenu';
|
import { NotesContextMenuDirective } from './components/NotesContextMenu';
|
||||||
@@ -153,7 +151,7 @@ const startApplication: StartApplication = async function startApplication(
|
|||||||
.directive('historyMenu', () => new HistoryMenu())
|
.directive('historyMenu', () => new HistoryMenu())
|
||||||
.directive('syncResolutionMenu', () => new SyncResolutionMenu())
|
.directive('syncResolutionMenu', () => new SyncResolutionMenu())
|
||||||
.directive('sessionsModal', SessionsModalDirective)
|
.directive('sessionsModal', SessionsModalDirective)
|
||||||
.directive('accountMenu2', AccountMenu2)
|
.directive('accountMenuReact', AccountMenuReact)
|
||||||
.directive('noAccountWarning', NoAccountWarningDirective)
|
.directive('noAccountWarning', NoAccountWarningDirective)
|
||||||
.directive('protectedNotePanel', NoProtectionsdNoteWarningDirective)
|
.directive('protectedNotePanel', NoProtectionsdNoteWarningDirective)
|
||||||
.directive('searchOptions', SearchOptionsDirective)
|
.directive('searchOptions', SearchOptionsDirective)
|
||||||
|
|||||||
@@ -4,22 +4,32 @@ import { AppState } from '@/ui_models/app_state';
|
|||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
||||||
|
|
||||||
import { isDesktopApplication, isSameDay } from '@/utils';
|
import { isDesktopApplication, isSameDay, preventRefreshing } from '@/utils';
|
||||||
import { storage, StorageKey } from '@Services/localStorage';
|
import { storage, StorageKey } from '@Services/localStorage';
|
||||||
import { disableErrorReporting, enableErrorReporting, errorReportingId } from '@Services/errorReporting';
|
import { disableErrorReporting, enableErrorReporting, errorReportingId } from '@Services/errorReporting';
|
||||||
import { STRING_E2E_ENABLED, STRING_ENC_NOT_ENABLED, STRING_LOCAL_ENC_ENABLED, StringUtils } from '@/strings';
|
import {
|
||||||
|
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_CHANGE,
|
||||||
|
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL,
|
||||||
|
STRING_E2E_ENABLED,
|
||||||
|
STRING_ENC_NOT_ENABLED,
|
||||||
|
STRING_LOCAL_ENC_ENABLED,
|
||||||
|
STRING_NON_MATCHING_PASSCODES,
|
||||||
|
StringUtils
|
||||||
|
} from '@/strings';
|
||||||
import { ContentType } from '@node_modules/@standardnotes/snjs';
|
import { ContentType } from '@node_modules/@standardnotes/snjs';
|
||||||
|
import { PasswordWizardType } from '@/types';
|
||||||
|
import { JSXInternal } from '@node_modules/preact/src/jsx';
|
||||||
|
import TargetedEvent = JSXInternal.TargetedEvent;
|
||||||
|
import { alertDialog } from '@Services/alertService';
|
||||||
|
import TargetedMouseEvent = JSXInternal.TargetedMouseEvent;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
||||||
// interface Props {} // TODO: Vardan: implement props and remove `eslint-disable`
|
|
||||||
type Props = {
|
type Props = {
|
||||||
appState: AppState;
|
appState: AppState;
|
||||||
application: WebApplication;
|
application: WebApplication;
|
||||||
|
closeAccountMenu: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
// const HistoryMenu = observer((props: Props) => {
|
const AccountMenu = observer(({ application, appState, closeAccountMenu }: Props) => {
|
||||||
// const AccountMenu = observer((props) => {
|
|
||||||
const AccountMenu = observer(({ appState, application }: Props) => {
|
|
||||||
const getProtectionsDisabledUntil = (): string | null => {
|
const getProtectionsDisabledUntil = (): string | null => {
|
||||||
const protectionExpiry = application.getProtectionSessionExpiryDate();
|
const protectionExpiry = application.getProtectionSessionExpiryDate();
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@@ -57,26 +67,24 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
const [status, setStatus] = useState('');
|
const [status, setStatus] = useState('');
|
||||||
const [syncError, setSyncError] = useState<string | undefined>(undefined);
|
const [syncError, setSyncError] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
|
const [passcode, setPasscode] = useState<string | undefined>(undefined);
|
||||||
|
const [passcodeConfirmation, setPasscodeConfirmation] = useState<string | undefined>(undefined);
|
||||||
|
|
||||||
|
const [encryptionStatusString, setEncryptionStatusString] = useState<string | undefined>(undefined);
|
||||||
|
const [isEncryptionEnabled, setIsEncryptionEnabled] = useState(false);
|
||||||
|
|
||||||
const [server, setServer] = useState<string | undefined>(undefined);
|
const [server, setServer] = useState<string | undefined>(undefined);
|
||||||
const [showPasscodeForm, setShowPasscodeForm] = useState(false);
|
const [showPasscodeForm, setShowPasscodeForm] = useState(false);
|
||||||
const [selectedAutoLockInterval, setSelectedAutoLockInterval] = useState<unknown>(null);
|
const [selectedAutoLockInterval, setSelectedAutoLockInterval] = useState<unknown>(null);
|
||||||
const [isLoading, setIsLoading] = useState<unknown>(false);
|
const [isLoading, setIsLoading] = useState<unknown>(false);
|
||||||
const [isErrorReportingEnabled, setIsErrorReportingEnabled] = useState(false);
|
const [isErrorReportingEnabled, setIsErrorReportingEnabled] = useState(false);
|
||||||
const [appVersion, setAppVersion] = useState(''); // TODO: Vardan: figure out how to get `appVersion` similar to original code
|
const [appVersion, setAppVersion] = useState(''); // TODO: Vardan: figure out how to get `appVersion` similar to original code
|
||||||
|
const [hasPasscode, setHasPasscode] = useState(application.hasPasscode());
|
||||||
const user = application.getUser();
|
|
||||||
const hasUser = application.hasAccount();
|
|
||||||
const hasPasscode = application.hasPasscode();
|
|
||||||
|
|
||||||
const isEncryptionEnabled = hasUser || hasPasscode;
|
|
||||||
const encryptionStatusString = hasUser
|
|
||||||
? STRING_E2E_ENABLED : hasPasscode
|
|
||||||
? STRING_LOCAL_ENC_ENABLED : STRING_ENC_NOT_ENABLED;
|
|
||||||
|
|
||||||
// TODO: Vardan: in original code initial value of `backupEncrypted` is `hasUser || hasPasscode` -
|
|
||||||
// once I have those values here, set them as initial value
|
|
||||||
const [isBackupEncrypted, setIsBackupEncrypted] = useState(isEncryptionEnabled);
|
const [isBackupEncrypted, setIsBackupEncrypted] = useState(isEncryptionEnabled);
|
||||||
const [isSyncInProgress, setIsSyncInProgress] = useState(false);
|
const [isSyncInProgress, setIsSyncInProgress] = useState(false);
|
||||||
|
const [protectionsDisabledUntil, setProtectionsDisabledUntil] = useState(getProtectionsDisabledUntil());
|
||||||
|
|
||||||
|
const user = application.getUser();
|
||||||
|
|
||||||
const reloadAutoLockInterval = useCallback(async () => {
|
const reloadAutoLockInterval = useCallback(async () => {
|
||||||
const interval = await application.getAutolockService().getAutoLockInterval();
|
const interval = await application.getAutolockService().getAutoLockInterval();
|
||||||
@@ -85,7 +93,6 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
|
|
||||||
|
|
||||||
const errorReportingIdValue = errorReportingId();
|
const errorReportingIdValue = errorReportingId();
|
||||||
const protectionsDisabledUntil = getProtectionsDisabledUntil();
|
|
||||||
const canAddPasscode = !application.isEphemeralSession();
|
const canAddPasscode = !application.isEphemeralSession();
|
||||||
const keyStorageInfo = StringUtils.keyStorageInfo(application);
|
const keyStorageInfo = StringUtils.keyStorageInfo(application);
|
||||||
const passcodeAutoLockOptions = application.getAutolockService().getAutoLockIntervalOptions();
|
const passcodeAutoLockOptions = application.getAutolockService().getAutoLockIntervalOptions();
|
||||||
@@ -133,11 +140,13 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const openPasswordWizard = () => {
|
const openPasswordWizard = () => {
|
||||||
console.log('openPasswordWizard');
|
closeAccountMenu();
|
||||||
|
application.presentPasswordWizard(PasswordWizardType.ChangePassword);
|
||||||
};
|
};
|
||||||
|
|
||||||
const openSessionsModal = () => {
|
const openSessionsModal = () => {
|
||||||
console.log('openSessionsModal');
|
closeAccountMenu();
|
||||||
|
appState.openSessionsModal();
|
||||||
};
|
};
|
||||||
|
|
||||||
const getEncryptionStatusForNotes = () => {
|
const getEncryptionStatusForNotes = () => {
|
||||||
@@ -146,27 +155,85 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const enableProtections = () => {
|
const enableProtections = () => {
|
||||||
console.log('enableProtections');
|
application.clearProtectionSession();
|
||||||
|
|
||||||
|
// Get the latest the protection status
|
||||||
|
setProtectionsDisabledUntil(getProtectionsDisabledUntil());
|
||||||
|
};
|
||||||
|
|
||||||
|
const refreshEncryptionStatus = () => {
|
||||||
|
const hasUser = application.hasAccount();
|
||||||
|
const hasPasscode = application.hasPasscode();
|
||||||
|
|
||||||
|
setHasPasscode(hasPasscode);
|
||||||
|
|
||||||
|
const encryptionEnabled = hasUser || hasPasscode;
|
||||||
|
|
||||||
|
const newEncryptionStatusString = hasUser
|
||||||
|
? STRING_E2E_ENABLED
|
||||||
|
: hasPasscode
|
||||||
|
? STRING_LOCAL_ENC_ENABLED
|
||||||
|
: STRING_ENC_NOT_ENABLED;
|
||||||
|
|
||||||
|
setEncryptionStatusString(newEncryptionStatusString);
|
||||||
|
setIsEncryptionEnabled(encryptionEnabled);
|
||||||
|
setIsBackupEncrypted(encryptionEnabled);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAddPassCode = () => {
|
const handleAddPassCode = () => {
|
||||||
console.log('handleAddPassCode');
|
setShowPasscodeForm(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
const submitPasscodeForm = () => {
|
const submitPasscodeForm = async (event: TargetedEvent<HTMLFormElement> | TargetedMouseEvent<HTMLButtonElement>) => {
|
||||||
console.log('submitPasscodeForm');
|
event.preventDefault();
|
||||||
|
|
||||||
|
if (passcode !== passcodeConfirmation) {
|
||||||
|
await alertDialog({
|
||||||
|
text: STRING_NON_MATCHING_PASSCODES,
|
||||||
|
});
|
||||||
|
passcodeInput.current.focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await preventRefreshing(
|
||||||
|
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_CHANGE,
|
||||||
|
async () => {
|
||||||
|
const successful = application.hasPasscode()
|
||||||
|
? await application.changePasscode(passcode as string)
|
||||||
|
: await application.addPasscode(passcode as string);
|
||||||
|
|
||||||
|
if (!successful) {
|
||||||
|
passcodeInput.current.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
setPasscode(undefined);
|
||||||
|
setPasscodeConfirmation(undefined);
|
||||||
|
setShowPasscodeForm(false);
|
||||||
|
|
||||||
|
setProtectionsDisabledUntil(getProtectionsDisabledUntil());
|
||||||
|
|
||||||
|
refreshEncryptionStatus();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handlePasscodeChange = () => {
|
// TODO: Vardan: check whether this (and `handleConfirmPasscodeChange`) method is required in the end
|
||||||
console.log('handlePasscodeChange');
|
const handlePasscodeChange = (event: TargetedEvent<HTMLInputElement>) => {
|
||||||
|
const { value } = event.target as HTMLInputElement;
|
||||||
|
setPasscode(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleConfirmPasscodeChange = () => {
|
const handleConfirmPasscodeChange = (event: TargetedEvent<HTMLInputElement>) => {
|
||||||
console.log('handleConfirmPasscodeChange');
|
const { value } = event.target as HTMLInputElement;
|
||||||
|
setPasscodeConfirmation(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectAutoLockInterval = (interval: number) => {
|
const selectAutoLockInterval = async (interval: number) => {
|
||||||
console.log('selectAutoLockInterval', interval);
|
if (!(await application.authorizeAutolockIntervalChange())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await application.getAutolockService().setAutoLockInterval(interval);
|
||||||
|
reloadAutoLockInterval();
|
||||||
};
|
};
|
||||||
|
|
||||||
const disableBetaWarning = () => {
|
const disableBetaWarning = () => {
|
||||||
@@ -187,13 +254,26 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
// TODO: Vardan: the name `changePasscodePressed` comes from original code; it is very similar to my `handlePasscodeChange`.
|
// TODO: Vardan: the name `changePasscodePressed` comes from original code; it is very similar to my `handlePasscodeChange`.
|
||||||
// Check if `handlePasscodeChange` is not required, remove it and rename `changePasscodePressed` to `handlePasscodeChange`
|
// Check if `handlePasscodeChange` is not required, remove it and rename `changePasscodePressed` to `handlePasscodeChange`
|
||||||
const changePasscodePressed = () => {
|
const changePasscodePressed = () => {
|
||||||
console.log('changePasscodePressed');
|
handleAddPassCode();
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Vardan: the name `removePasscodePressed` comes from original code;
|
// TODO: Vardan: the name `removePasscodePressed` comes from original code;
|
||||||
// Check if I rename`changePasscodePressed` to `handlePasscodeChange`, also rename `removePasscodePressed` to `handleRemovePasscode`
|
// Check if I rename`changePasscodePressed` to `handlePasscodeChange`, also rename `removePasscodePressed` to `handleRemovePasscode`
|
||||||
const removePasscodePressed = () => {
|
const removePasscodePressed = async () => {
|
||||||
console.log('removePasscodePressed');
|
await preventRefreshing(
|
||||||
|
STRING_CONFIRM_APP_QUIT_DURING_PASSCODE_REMOVAL,
|
||||||
|
async () => {
|
||||||
|
if (await application.removePasscode()) {
|
||||||
|
await application
|
||||||
|
.getAutolockService()
|
||||||
|
.deleteAutolockPreference();
|
||||||
|
await reloadAutoLockInterval();
|
||||||
|
refreshEncryptionStatus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
setProtectionsDisabledUntil(getProtectionsDisabledUntil());
|
||||||
};
|
};
|
||||||
|
|
||||||
const downloadDataArchive = () => {
|
const downloadDataArchive = () => {
|
||||||
@@ -219,10 +299,6 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
console.log('openErrorReportingDialog');
|
console.log('openErrorReportingDialog');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleClose = () => {
|
|
||||||
console.log('close this');
|
|
||||||
};
|
|
||||||
|
|
||||||
// TODO: check whether this works fine (e.g. remove all tags and notes and then add one and check whether UI behaves appropriately)
|
// TODO: check whether this works fine (e.g. remove all tags and notes and then add one and check whether UI behaves appropriately)
|
||||||
const notesAndTagsCount = application.getItems([ContentType.Note, ContentType.Tag]).length;
|
const notesAndTagsCount = application.getItems([ContentType.Note, ContentType.Tag]).length;
|
||||||
const hasProtections = application.hasProtectionSources();
|
const hasProtections = application.hasProtectionSources();
|
||||||
@@ -262,16 +338,9 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
setServer(host);
|
setServer(host);
|
||||||
}, [application]);
|
}, [application]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
/*
|
refreshEncryptionStatus();
|
||||||
const { searchOptions } = appState;
|
}, [refreshEncryptionStatus]);
|
||||||
|
|
||||||
const {
|
|
||||||
includeProtectedContents,
|
|
||||||
includeArchived,
|
|
||||||
includeTrashed,
|
|
||||||
} = searchOptions;
|
|
||||||
*/
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{
|
<div style={{
|
||||||
@@ -284,10 +353,10 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
position: 'absolute'
|
position: 'absolute'
|
||||||
}}>
|
}}>
|
||||||
<div className='sn-component'>
|
<div className='sn-component'>
|
||||||
<div id='account-panel-vardan' className='sk-panel'>
|
<div id='account-panel-react' className='sk-panel'>
|
||||||
<div className='sk-panel-header'>
|
<div className='sk-panel-header'>
|
||||||
<div className='sk-panel-header-title'>Account</div>
|
<div className='sk-panel-header-title'>Account</div>
|
||||||
<a className='sk-a info close-button' onClick={handleClose}>Close</a>
|
<a className='sk-a info close-button' onClick={closeAccountMenu}>Close</a>
|
||||||
</div>
|
</div>
|
||||||
<div className='sk-panel-content'>
|
<div className='sk-panel-content'>
|
||||||
{!user && !showLogin && !showRegister && (
|
{!user && !showLogin && !showRegister && (
|
||||||
@@ -514,7 +583,7 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
</p>
|
</p>
|
||||||
{protectionsDisabledUntil && (
|
{protectionsDisabledUntil && (
|
||||||
<div className='sk-panel-row'>
|
<div className='sk-panel-row'>
|
||||||
<button className='sn-button small.info' onClick={enableProtections}>
|
<button className='sn-button small info' onClick={enableProtections}>
|
||||||
Enable protections
|
Enable protections
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -554,17 +623,19 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
{showPasscodeForm && (
|
{showPasscodeForm && (
|
||||||
<form className='sk-panel-form' onSubmit={submitPasscodeForm}>
|
<form className='sk-panel-form' onSubmit={submitPasscodeForm}>
|
||||||
<div className='sk-panel-row' />
|
<div className='sk-panel-row' />
|
||||||
{/* TODO: Vardan: there are `should-focus` and `sn-autofocus`, implement them */}
|
|
||||||
<input
|
<input
|
||||||
className='sk-input contrast'
|
className='sk-input contrast'
|
||||||
type='password'
|
type='password'
|
||||||
ref={passcodeInput}
|
ref={passcodeInput}
|
||||||
|
value={passcode}
|
||||||
onChange={handlePasscodeChange}
|
onChange={handlePasscodeChange}
|
||||||
placeholder='Passcode'
|
placeholder='Passcode'
|
||||||
|
autoFocus
|
||||||
/>
|
/>
|
||||||
<input
|
<input
|
||||||
className='sk-input contrast'
|
className='sk-input contrast'
|
||||||
type='password'
|
type='password'
|
||||||
|
value={passcodeConfirmation}
|
||||||
onChange={handleConfirmPasscodeChange}
|
onChange={handleConfirmPasscodeChange}
|
||||||
placeholder='Confirm Passcode'
|
placeholder='Confirm Passcode'
|
||||||
/>
|
/>
|
||||||
@@ -588,7 +659,7 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
{passcodeAutoLockOptions.map(option => {
|
{passcodeAutoLockOptions.map(option => {
|
||||||
return (
|
return (
|
||||||
<a
|
<a
|
||||||
className={option.value === selectedAutoLockInterval ? 'boxed' : ''}
|
className={`sk-a info ${option.value === selectedAutoLockInterval ? 'boxed' : ''}`}
|
||||||
onClick={() => selectAutoLockInterval(option.value)}>
|
onClick={() => selectAutoLockInterval(option.value)}>
|
||||||
{option.label}
|
{option.label}
|
||||||
</a>
|
</a>
|
||||||
@@ -720,6 +791,7 @@ const AccountMenu = observer(({ appState, application }: Props) => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
export const AccountMenu2 = toDirective<Props>(
|
export const AccountMenuReact = toDirective<Props>(
|
||||||
AccountMenu
|
AccountMenu,
|
||||||
|
{ closeAccountMenu: '&'}
|
||||||
);
|
);
|
||||||
@@ -19,7 +19,7 @@ const ConfirmSignoutContainer = observer((props: Props) => {
|
|||||||
if (!props.appState.accountMenu.signingOut) {
|
if (!props.appState.accountMenu.signingOut) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!props.appState.accountMenu2.signingOut) {
|
if (!props.appState.accountMenuReact.signingOut) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return <ConfirmSignoutModal {...props} />;
|
return <ConfirmSignoutModal {...props} />;
|
||||||
@@ -33,15 +33,14 @@ const ConfirmSignoutModal = observer(({ application, appState }: Props) => {
|
|||||||
const cancelRef = useRef<HTMLButtonElement>();
|
const cancelRef = useRef<HTMLButtonElement>();
|
||||||
function close() {
|
function close() {
|
||||||
appState.accountMenu.setSigningOut(false);
|
appState.accountMenu.setSigningOut(false);
|
||||||
appState.accountMenu2.setSigningOut(false);
|
appState.accountMenuReact.setSigningOut(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const [localBackupsCount, setLocalBackupsCount] = useState(0);
|
const [localBackupsCount, setLocalBackupsCount] = useState(0);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
application.bridge.localBackupsCount().then(setLocalBackupsCount);
|
application.bridge.localBackupsCount().then(setLocalBackupsCount);
|
||||||
// }, [appState.accountMenu.signingOut, application.bridge]);
|
}, [appState.accountMenu.signingOut, appState.accountMenuReact.signingOut, application.bridge]);
|
||||||
}, [appState.accountMenu.signingOut, appState.accountMenu2.signingOut, application.bridge]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AlertDialog onDismiss={close} leastDestructiveRef={cancelRef}>
|
<AlertDialog onDismiss={close} leastDestructiveRef={cancelRef}>
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ const NoAccountWarning = observer(({ appState }: Props) => {
|
|||||||
onClick={(event) => {
|
onClick={(event) => {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
appState.accountMenu.setShow(true);
|
appState.accountMenu.setShow(true);
|
||||||
appState.accountMenu2.setShow(true);
|
appState.accountMenuReact.setShow(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Open Account menu
|
Open Account menu
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ function NoProtectionsNoteWarning({ appState, onViewNote }: Props) {
|
|||||||
className="sn-button small info"
|
className="sn-button small info"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
appState.accountMenu.setShow(true);
|
appState.accountMenu.setShow(true);
|
||||||
appState.accountMenu2.setShow(true);
|
appState.accountMenuReact.setShow(true);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Open account menu
|
Open account menu
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { action, makeObservable, observable } from "mobx";
|
import { action, makeObservable, observable } from "mobx";
|
||||||
import { WebApplication } from '@/ui_models/application';
|
import { WebApplication } from '@/ui_models/application';
|
||||||
|
|
||||||
export class AccountMenuState2 {
|
export class AccountMenuStateReact {
|
||||||
show = false;
|
show = false;
|
||||||
signingOut = false;
|
signingOut = false;
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ import { SyncState } from './sync_state';
|
|||||||
import { SearchOptionsState } from './search_options_state';
|
import { SearchOptionsState } from './search_options_state';
|
||||||
import { NotesState } from './notes_state';
|
import { NotesState } from './notes_state';
|
||||||
import { TagsState } from './tags_state';
|
import { TagsState } from './tags_state';
|
||||||
import { AccountMenuState2 } from '@/ui_models/app_state/account_menu_2_state';
|
import { AccountMenuStateReact } from '@/ui_models/app_state/account_menu_react_state';
|
||||||
|
|
||||||
export enum AppStateEvent {
|
export enum AppStateEvent {
|
||||||
TagChanged,
|
TagChanged,
|
||||||
@@ -62,8 +62,7 @@ export class AppState {
|
|||||||
selectedTag?: SNTag;
|
selectedTag?: SNTag;
|
||||||
showBetaWarning: boolean;
|
showBetaWarning: boolean;
|
||||||
readonly accountMenu = new AccountMenuState();
|
readonly accountMenu = new AccountMenuState();
|
||||||
// readonly accountMenu2 = new AccountMenu_2_State();
|
readonly accountMenuReact: AccountMenuStateReact;
|
||||||
readonly accountMenu2: AccountMenuState2;
|
|
||||||
readonly actionsMenu = new ActionsMenuState();
|
readonly actionsMenu = new ActionsMenuState();
|
||||||
readonly noAccountWarning: NoAccountWarningState;
|
readonly noAccountWarning: NoAccountWarningState;
|
||||||
readonly sync = new SyncState();
|
readonly sync = new SyncState();
|
||||||
@@ -99,10 +98,7 @@ export class AppState {
|
|||||||
application,
|
application,
|
||||||
this.appEventObserverRemovers
|
this.appEventObserverRemovers
|
||||||
);
|
);
|
||||||
this.accountMenu2 = new AccountMenuState2(
|
this.accountMenuReact = new AccountMenuStateReact();
|
||||||
// application,
|
|
||||||
// this.appEventObserverRemovers
|
|
||||||
);
|
|
||||||
this.searchOptions = new SearchOptionsState(
|
this.searchOptions = new SearchOptionsState(
|
||||||
application,
|
application,
|
||||||
this.appEventObserverRemovers
|
this.appEventObserverRemovers
|
||||||
|
|||||||
@@ -18,10 +18,12 @@
|
|||||||
ng-if='ctrl.showAccountMenu',
|
ng-if='ctrl.showAccountMenu',
|
||||||
application='ctrl.application'
|
application='ctrl.application'
|
||||||
)
|
)
|
||||||
account-menu2(
|
account-menu-react(
|
||||||
ng-click='$event.stopPropagation()',
|
ng-click='$event.stopPropagation()',
|
||||||
app-state='ctrl.appState'
|
app-state='ctrl.appState'
|
||||||
application='ctrl.application'
|
application='ctrl.application'
|
||||||
|
ng-if='ctrl.showAccountMenu',
|
||||||
|
close-account-menu='ctrl.closeAccountMenu()',
|
||||||
)
|
)
|
||||||
.sk-app-bar-item
|
.sk-app-bar-item
|
||||||
a.no-decoration.sk-label.title(
|
a.no-decoration.sk-label.title(
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
|
|||||||
public user?: any
|
public user?: any
|
||||||
private offline = true
|
private offline = true
|
||||||
public showAccountMenu = false
|
public showAccountMenu = false
|
||||||
public showAccountMenu2 = false
|
public showAccountMenuReact = false
|
||||||
private didCheckForOffline = false
|
private didCheckForOffline = false
|
||||||
private queueExtReload = false
|
private queueExtReload = false
|
||||||
private reloadInProgress = false
|
private reloadInProgress = false
|
||||||
@@ -116,7 +116,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
|
|||||||
this.autorun(() => {
|
this.autorun(() => {
|
||||||
const showBetaWarning = this.appState.showBetaWarning;
|
const showBetaWarning = this.appState.showBetaWarning;
|
||||||
this.showAccountMenu = this.appState.accountMenu.show;
|
this.showAccountMenu = this.appState.accountMenu.show;
|
||||||
this.showAccountMenu2 = this.appState.accountMenu2.show;
|
this.showAccountMenuReact = this.appState.accountMenuReact.show;
|
||||||
this.setState({
|
this.setState({
|
||||||
showBetaWarning: showBetaWarning,
|
showBetaWarning: showBetaWarning,
|
||||||
showDataUpgrade: !showBetaWarning
|
showDataUpgrade: !showBetaWarning
|
||||||
@@ -256,7 +256,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
|
|||||||
this.didCheckForOffline = true;
|
this.didCheckForOffline = true;
|
||||||
if (this.offline && this.application.getNoteCount() === 0) {
|
if (this.offline && this.application.getNoteCount() === 0) {
|
||||||
this.appState.accountMenu.setShow(true);
|
this.appState.accountMenu.setShow(true);
|
||||||
this.appState.accountMenu2.setShow(true);
|
this.appState.accountMenuReact.setShow(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.syncUpdated();
|
this.syncUpdated();
|
||||||
@@ -439,7 +439,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
|
|||||||
|
|
||||||
accountMenuPressed() {
|
accountMenuPressed() {
|
||||||
this.appState.accountMenu.toggleShow();
|
this.appState.accountMenu.toggleShow();
|
||||||
this.appState.accountMenu2.toggleShow();
|
this.appState.accountMenuReact.toggleShow();
|
||||||
this.closeAllRooms();
|
this.closeAllRooms();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -449,7 +449,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
|
|||||||
|
|
||||||
closeAccountMenu() {
|
closeAccountMenu() {
|
||||||
this.appState.accountMenu.setShow(false);
|
this.appState.accountMenu.setShow(false);
|
||||||
this.appState.accountMenu2.setShow(false);
|
this.appState.accountMenuReact.setShow(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
lockApp() {
|
lockApp() {
|
||||||
@@ -567,7 +567,7 @@ class FooterViewCtrl extends PureViewCtrl<unknown, {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.appState.accountMenu.setShow(false);
|
this.appState.accountMenu.setShow(false);
|
||||||
this.appState.accountMenu2.setShow(false);
|
this.appState.accountMenuReact.setShow(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
#account-panel,
|
#account-panel,
|
||||||
#account-panel-vardan,
|
#account-panel-react,
|
||||||
#sync-resolution-menu {
|
#sync-resolution-menu {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user