feat: cancelable challenges
This commit is contained in:
@@ -33,9 +33,9 @@
|
||||
ng-disabled="ctrl.state.processing"
|
||||
)
|
||||
.sk-label {{ctrl.state.processing ? 'Generating Keys...' : 'Submit'}}
|
||||
.sk-panel-row(ng-if="ctrl.cancelable")
|
||||
.sk-panel-row(ng-if="ctrl.challenge.cancelable")
|
||||
a.sk-panel-row.sk-a.info.centered(
|
||||
ng-if="ctrl.cancelable"
|
||||
ng-if="ctrl.challenge.cancelable"
|
||||
ng-click="ctrl.cancel()"
|
||||
) Cancel
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class ChallengeModalCtrl extends PureViewCtrl<{}, ChallengeModalState> {
|
||||
private $element: JQLite
|
||||
application!: WebApplication
|
||||
challenge!: Challenge
|
||||
private cancelable = false
|
||||
|
||||
/* @ngInject */
|
||||
constructor(
|
||||
@@ -62,26 +61,10 @@ class ChallengeModalCtrl extends PureViewCtrl<{}, ChallengeModalState> {
|
||||
invalid: false
|
||||
};
|
||||
}
|
||||
let showForgotPasscodeLink = false;
|
||||
switch (this.challenge.reason) {
|
||||
case ChallengeReason.ApplicationUnlock:
|
||||
showForgotPasscodeLink = true;
|
||||
this.cancelable = false;
|
||||
break;
|
||||
case ChallengeReason.Migration:
|
||||
showForgotPasscodeLink = true;
|
||||
this.cancelable = false;
|
||||
break;
|
||||
case ChallengeReason.ProtocolUpgrade:
|
||||
showForgotPasscodeLink = false;
|
||||
this.cancelable = true;
|
||||
break;
|
||||
case ChallengeReason.ResaveRootKey:
|
||||
showForgotPasscodeLink = false;
|
||||
this.cancelable = true;
|
||||
break;
|
||||
}
|
||||
this.cancelable = !showForgotPasscodeLink
|
||||
const showForgotPasscodeLink = [
|
||||
ChallengeReason.ApplicationUnlock,
|
||||
ChallengeReason.Migration
|
||||
].includes(this.challenge.reason);
|
||||
this.setState({
|
||||
prompts,
|
||||
values,
|
||||
@@ -143,7 +126,7 @@ class ChallengeModalCtrl extends PureViewCtrl<{}, ChallengeModalState> {
|
||||
|
||||
/** @template */
|
||||
cancel() {
|
||||
if (this.cancelable) {
|
||||
if (this.challenge.cancelable) {
|
||||
this.application!.cancelChallenge(this.challenge);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ export declare class DesktopManager extends ApplicationService {
|
||||
updateObservers: {
|
||||
callback: UpdateObserverCallback;
|
||||
}[];
|
||||
isDesktop: any;
|
||||
isDesktop: boolean;
|
||||
dataLoaded: boolean;
|
||||
lastSearchedText?: string;
|
||||
private removeComponentObserver?;
|
||||
@@ -45,7 +45,6 @@ export declare class DesktopManager extends ApplicationService {
|
||||
};
|
||||
desktop_deregisterComponentActivationObserver(observer: ComponentActivationObserver): void;
|
||||
notifyComponentActivation(component: SNComponent): Promise<void>;
|
||||
onExtensionsReady(): void;
|
||||
desktop_requestBackupFile(): Promise<string | undefined>;
|
||||
desktop_didBeginBackup(): void;
|
||||
desktop_didFinishBackup(success: boolean): void;
|
||||
|
||||
@@ -10,7 +10,6 @@ export declare enum AppStateEvent {
|
||||
EditorFocused = 5,
|
||||
BeganBackupDownload = 6,
|
||||
EndedBackupDownload = 7,
|
||||
DesktopExtsReady = 8,
|
||||
WindowDidFocus = 9,
|
||||
WindowDidBlur = 10
|
||||
}
|
||||
@@ -64,9 +63,5 @@ export declare class AppState {
|
||||
editorDidFocus(eventSource: EventSource): void;
|
||||
beganBackupDownload(): void;
|
||||
endedBackupDownload(success: boolean): void;
|
||||
/**
|
||||
* When the desktop appplication extension server is ready.
|
||||
*/
|
||||
desktopExtensionsReady(): void;
|
||||
}
|
||||
export {};
|
||||
|
||||
@@ -5,5 +5,5 @@ export declare function getPlatformString(): string;
|
||||
export declare function dateToLocalizedString(date: Date): string;
|
||||
/** Via https://davidwalsh.name/javascript-debounce-function */
|
||||
export declare function debounce(this: any, func: any, wait: number, immediate?: boolean): () => void;
|
||||
export declare function isDesktopApplication(): any;
|
||||
export declare function preventRefreshing(message: string, operation: () => Promise<void> | void): Promise<void>;
|
||||
export declare function isDesktopApplication(): boolean;
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -10956,8 +10956,8 @@
|
||||
"from": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad"
|
||||
},
|
||||
"snjs": {
|
||||
"version": "github:standardnotes/snjs#2d44b98e3dfd1fa7fe4f83665d663d01063333c1",
|
||||
"from": "github:standardnotes/snjs#2d44b98e3dfd1fa7fe4f83665d663d01063333c1"
|
||||
"version": "github:standardnotes/snjs#403dd0ccd860c42889601446540a9e17b8f7440f",
|
||||
"from": "github:standardnotes/snjs#403dd0ccd860c42889601446540a9e17b8f7440f"
|
||||
},
|
||||
"sockjs": {
|
||||
"version": "0.3.20",
|
||||
|
||||
@@ -69,6 +69,6 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"sncrypto": "github:standardnotes/sncrypto#8794c88daa967eaae493cd5fdec7506d52b257ad",
|
||||
"snjs": "github:standardnotes/snjs#2d44b98e3dfd1fa7fe4f83665d663d01063333c1"
|
||||
"snjs": "github:standardnotes/snjs#403dd0ccd860c42889601446540a9e17b8f7440f"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user