refactor: update to latest snjs
This commit is contained in:
@@ -8,7 +8,6 @@ import {
|
||||
SNAlertService,
|
||||
platformFromString,
|
||||
Challenge,
|
||||
ChallengeOrchestrator,
|
||||
ProtectedAction
|
||||
} from 'snjs';
|
||||
import angular from 'angular';
|
||||
@@ -160,14 +159,13 @@ export class WebApplication extends SNApplication {
|
||||
angular.element(document.body).append(el);
|
||||
}
|
||||
|
||||
promptForChallenge(challenge: Challenge, orchestrator: ChallengeOrchestrator) {
|
||||
promptForChallenge(challenge: Challenge) {
|
||||
const scope: any = this.scope!.$new(true);
|
||||
scope.challenge = challenge;
|
||||
scope.orchestrator = orchestrator;
|
||||
scope.application = this;
|
||||
const el = this.$compile!(
|
||||
"<challenge-modal " +
|
||||
"class='sk-modal' application='application' challenge='challenge' orchestrator='orchestrator'>" +
|
||||
"class='sk-modal' application='application' challenge='challenge'>" +
|
||||
"</challenge-modal>"
|
||||
)(scope);
|
||||
angular.element(document.body).append(el);
|
||||
|
||||
@@ -5,7 +5,6 @@ import {
|
||||
ChallengeValue,
|
||||
removeFromArray,
|
||||
Challenge,
|
||||
ChallengeOrchestrator
|
||||
} from 'snjs';
|
||||
import { PureViewCtrl } from '@Views/abstract/pure_view_ctrl';
|
||||
import { WebDirective } from '@/types';
|
||||
@@ -14,11 +13,6 @@ type InputValue = {
|
||||
value: string
|
||||
invalid: boolean
|
||||
}
|
||||
type ChallengeModalScope = {
|
||||
application: WebApplication
|
||||
challenge: Challenge
|
||||
orchestrator: ChallengeOrchestrator
|
||||
}
|
||||
|
||||
type Values = Record<ChallengeType, InputValue>
|
||||
|
||||
@@ -28,12 +22,11 @@ type ChallengeModalState = {
|
||||
processing: boolean
|
||||
}
|
||||
|
||||
class ChallengeModalCtrl extends PureViewCtrl implements ChallengeModalScope {
|
||||
class ChallengeModalCtrl extends PureViewCtrl {
|
||||
private $element: JQLite
|
||||
private processingTypes: ChallengeType[] = []
|
||||
application!: WebApplication
|
||||
challenge!: Challenge
|
||||
orchestrator!: ChallengeOrchestrator
|
||||
|
||||
/* @ngInject */
|
||||
constructor(
|
||||
@@ -63,26 +56,26 @@ class ChallengeModalCtrl extends PureViewCtrl implements ChallengeModalScope {
|
||||
values: values,
|
||||
processing: false
|
||||
});
|
||||
this.orchestrator.setCallbacks(
|
||||
(value) => {
|
||||
this.application.setChallengeCallbacks({
|
||||
challenge: this.challenge,
|
||||
onValidValue: (value) => {
|
||||
this.getState().values[value.type]!.invalid = false;
|
||||
removeFromArray(this.processingTypes, value.type);
|
||||
this.reloadProcessingStatus();
|
||||
},
|
||||
(value) => {
|
||||
onInvalidValue: (value) => {
|
||||
this.getState().values[value.type]!.invalid = true;
|
||||
removeFromArray(this.processingTypes, value.type);
|
||||
this.reloadProcessingStatus();
|
||||
},
|
||||
() => {
|
||||
onComplete: () => {
|
||||
this.dismiss();
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
deinit() {
|
||||
(this.application as any) = undefined;
|
||||
(this.orchestrator as any) = undefined;
|
||||
(this.challenge as any) = undefined;
|
||||
super.deinit();
|
||||
}
|
||||
@@ -141,7 +134,11 @@ class ChallengeModalCtrl extends PureViewCtrl implements ChallengeModalScope {
|
||||
values.push(value);
|
||||
}
|
||||
this.processingTypes = values.map((v) => v.type);
|
||||
this.orchestrator.submitValues(values);
|
||||
if (values.length > 0) {
|
||||
this.application.submitValuesForChallenge(this.challenge, values);
|
||||
} else {
|
||||
this.setState({ processing: false });
|
||||
}
|
||||
}
|
||||
|
||||
dismiss() {
|
||||
@@ -162,7 +159,6 @@ export class ChallengeModal extends WebDirective {
|
||||
this.bindToController = true;
|
||||
this.scope = {
|
||||
challenge: '=',
|
||||
orchestrator: '=',
|
||||
application: '='
|
||||
};
|
||||
}
|
||||
|
||||
15
package-lock.json
generated
15
package-lock.json
generated
@@ -9792,19 +9792,8 @@
|
||||
"from": "github:standardnotes/sncrypto#7e76ab9977f85039d9399b935aecfe495a951edb"
|
||||
},
|
||||
"snjs": {
|
||||
"version": "github:standardnotes/snjs#0c306de70c5afffe16096424c6c3326eaa1dd4fd",
|
||||
"from": "github:standardnotes/snjs#0c306de70c5afffe16096424c6c3326eaa1dd4fd",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"sncrypto": "github:standardnotes/sncrypto#6625bbcc141161eb866475d9786238001f3c514d"
|
||||
},
|
||||
"dependencies": {
|
||||
"sncrypto": {
|
||||
"version": "github:standardnotes/sncrypto#6625bbcc141161eb866475d9786238001f3c514d",
|
||||
"from": "github:standardnotes/sncrypto#6625bbcc141161eb866475d9786238001f3c514d",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
"version": "github:standardnotes/snjs#1c43ab79fb548962837c1061d6ec3bc2a8af2b4f",
|
||||
"from": "github:standardnotes/snjs#1c43ab79fb548962837c1061d6ec3bc2a8af2b4f"
|
||||
},
|
||||
"sockjs": {
|
||||
"version": "0.3.19",
|
||||
|
||||
@@ -57,7 +57,6 @@
|
||||
"sass-loader": "^8.0.2",
|
||||
"serve-static": "^1.14.1",
|
||||
"sn-stylekit": "2.0.22",
|
||||
"snjs": "github:standardnotes/snjs#0c306de70c5afffe16096424c6c3326eaa1dd4fd",
|
||||
"ts-loader": "^6.2.2",
|
||||
"typescript": "^3.8.3",
|
||||
"typescript-eslint": "0.0.1-alpha.0",
|
||||
@@ -67,6 +66,7 @@
|
||||
"webpack-merge": "^4.2.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"sncrypto": "github:standardnotes/sncrypto#7e76ab9977f85039d9399b935aecfe495a951edb"
|
||||
"sncrypto": "github:standardnotes/sncrypto#7e76ab9977f85039d9399b935aecfe495a951edb",
|
||||
"snjs": "github:standardnotes/snjs#1c43ab79fb548962837c1061d6ec3bc2a8af2b4f"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user