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