Some more changes

This commit is contained in:
RMidhunSuresh 2023-03-27 16:36:27 +05:30
parent 5fa4afa021
commit 41ebf13156
11 changed files with 38 additions and 25 deletions

View File

@ -47,4 +47,8 @@ export class SelectMethodViewModel extends ErrorReportViewModel<SegmentType, Opt
get deviceName() { get deviceName() {
return this.options.stage.otherDeviceName; return this.options.stage.otherDeviceName;
} }
get kind(): string {
return "select-method";
}
} }

View File

@ -35,4 +35,8 @@ export class VerificationCancelledViewModel extends ViewModel<SegmentType, Optio
gotoSettings() { gotoSettings() {
this.navigation.push("settings", true); this.navigation.push("settings", true);
} }
get kind(): string {
return "verification-cancelled";
}
} }

View File

@ -32,4 +32,8 @@ export class VerificationCompleteViewModel extends ErrorReportViewModel<SegmentT
gotoSettings() { gotoSettings() {
this.navigation.push("settings", true); this.navigation.push("settings", true);
} }
get kind(): string {
return "verification-completed";
}
} }

View File

@ -39,4 +39,8 @@ export class VerifyEmojisViewModel extends ErrorReportViewModel<SegmentType, Opt
get emojis() { get emojis() {
return this.options.stage.emoji; return this.options.stage.emoji;
} }
get kind(): string {
return "verify-emojis";
}
} }

View File

@ -26,4 +26,8 @@ export class WaitingForOtherUserViewModel extends ViewModel<SegmentType, Options
async cancel() { async cancel() {
await this.options.sas.abort(); await this.options.sas.abort();
} }
get kind(): string {
return "waiting-for-user";
}
} }

View File

@ -14,21 +14,16 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {TemplateView} from "../../general/TemplateView"; import {Builder, TemplateView} from "../../general/TemplateView";
import {WaitingForOtherUserViewModel} from "../../../../../domain/session/verification/stages/WaitingForOtherUserViewModel";
import {DeviceVerificationViewModel} from "../../../../../domain/session/verification/DeviceVerificationViewModel"; import {DeviceVerificationViewModel} from "../../../../../domain/session/verification/DeviceVerificationViewModel";
import {VerificationCancelledViewModel} from "../../../../../domain/session/verification/stages/VerificationCancelledViewModel";
import {WaitingForOtherUserView} from "./stages/WaitingForOtherUserView"; import {WaitingForOtherUserView} from "./stages/WaitingForOtherUserView";
import {VerificationCancelledView} from "./stages/VerificationCancelledView"; import {VerificationCancelledView} from "./stages/VerificationCancelledView";
import {SelectMethodViewModel} from "../../../../../domain/session/verification/stages/SelectMethodViewModel";
import {SelectMethodView} from "./stages/SelectMethodView"; import {SelectMethodView} from "./stages/SelectMethodView";
import {VerifyEmojisViewModel} from "../../../../../domain/session/verification/stages/VerifyEmojisViewModel";
import {VerifyEmojisView} from "./stages/VerifyEmojisView"; import {VerifyEmojisView} from "./stages/VerifyEmojisView";
import {VerificationCompleteViewModel} from "../../../../../domain/session/verification/stages/VerificationCompleteViewModel";
import {VerificationCompleteView} from "./stages/VerificationCompleteView"; import {VerificationCompleteView} from "./stages/VerificationCompleteView";
export class DeviceVerificationView extends TemplateView<DeviceVerificationViewModel> { export class DeviceVerificationView extends TemplateView<DeviceVerificationViewModel> {
render(t, vm) { render(t: Builder<DeviceVerificationViewModel>) {
return t.div({ return t.div({
className: { className: {
"middle": true, "middle": true,
@ -36,21 +31,22 @@ export class DeviceVerificationView extends TemplateView<DeviceVerificationViewM
} }
}, [ }, [
t.mapView(vm => vm.currentStageViewModel, (stageVm) => { t.mapView(vm => vm.currentStageViewModel, (stageVm) => {
if (stageVm instanceof WaitingForOtherUserViewModel) { if (stageVm.kind === "waiting-for-user") {
return new WaitingForOtherUserView(stageVm); return new WaitingForOtherUserView(stageVm);
} }
else if (stageVm instanceof VerificationCancelledViewModel) { else if (stageVm.kind === "verification-cancelled") {
return new VerificationCancelledView(stageVm); return new VerificationCancelledView(stageVm);
} }
else if (stageVm instanceof SelectMethodViewModel) { else if (stageVm.kind === "select-method") {
return new SelectMethodView(stageVm); return new SelectMethodView(stageVm);
} }
else if (stageVm instanceof VerifyEmojisViewModel) { else if (stageVm.kind === "verify-emojis") {
return new VerifyEmojisView(stageVm); return new VerifyEmojisView(stageVm);
} }
else if (stageVm instanceof VerificationCompleteViewModel) { else if (stageVm.kind === "verification-completed") {
return new VerificationCompleteView(stageVm); return new VerificationCompleteView(stageVm);
} }
return null;
}) })
]) ])
} }

View File

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {TemplateView} from "../../../general/TemplateView"; import {Builder, TemplateView} from "../../../general/TemplateView";
import {spinner} from "../../../common.js" import {spinner} from "../../../common.js"
import type {SelectMethodViewModel} from "../../../../../../domain/session/verification/stages/SelectMethodViewModel"; import type {SelectMethodViewModel} from "../../../../../../domain/session/verification/stages/SelectMethodViewModel";
export class SelectMethodView extends TemplateView<SelectMethodViewModel> { export class SelectMethodView extends TemplateView<SelectMethodViewModel> {
render(t) { render(t: Builder<SelectMethodViewModel>) {
return t.div({ className: "SelectMethodView" }, [ return t.div({ className: "SelectMethodView" }, [
t.map(vm => vm.hasProceeded, (hasProceeded, t, vm) => { t.map(vm => vm.hasProceeded, (hasProceeded, t, vm) => {
if (hasProceeded) { if (hasProceeded) {

View File

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {TemplateView} from "../../../general/TemplateView"; import {Builder, TemplateView} from "../../../general/TemplateView";
import {VerificationCancelledViewModel} from "../../../../../../domain/session/verification/stages/VerificationCancelledViewModel"; import {VerificationCancelledViewModel} from "../../../../../../domain/session/verification/stages/VerificationCancelledViewModel";
import {CancelReason} from "../../../../../../matrix/verification/SAS/channel/types"; import {CancelReason} from "../../../../../../matrix/verification/SAS/channel/types";
export class VerificationCancelledView extends TemplateView<VerificationCancelledViewModel> { export class VerificationCancelledView extends TemplateView<VerificationCancelledViewModel> {
render(t, vm: VerificationCancelledViewModel) { render(t: Builder<VerificationCancelledViewModel>, vm: VerificationCancelledViewModel) {
const headerTextStart = vm.isCancelledByUs ? "You" : "The other device"; const headerTextStart = vm.isCancelledByUs ? "You" : "The other device";
return t.div( return t.div(
@ -50,10 +50,8 @@ export class VerificationCancelledView extends TemplateView<VerificationCancelle
getDescriptionFromCancellationCode(code: CancelReason, isCancelledByUs: boolean): string { getDescriptionFromCancellationCode(code: CancelReason, isCancelledByUs: boolean): string {
const descriptionsWhenWeCancelled = { const descriptionsWhenWeCancelled = {
// [CancelReason.UserCancelled]: NO_NEED_FOR_DESCRIPTION_HERE
[CancelReason.InvalidMessage]: "You other device sent an invalid message.", [CancelReason.InvalidMessage]: "You other device sent an invalid message.",
[CancelReason.KeyMismatch]: "The key could not be verified.", [CancelReason.KeyMismatch]: "The key could not be verified.",
// [CancelReason.OtherDeviceAccepted]: "Another device has accepted this request.",
[CancelReason.TimedOut]: "The verification process timed out.", [CancelReason.TimedOut]: "The verification process timed out.",
[CancelReason.UnexpectedMessage]: "Your other device sent an unexpected message.", [CancelReason.UnexpectedMessage]: "Your other device sent an unexpected message.",
[CancelReason.UnknownMethod]: "Your other device is using an unknown method for verification.", [CancelReason.UnknownMethod]: "Your other device is using an unknown method for verification.",
@ -66,7 +64,6 @@ export class VerificationCancelledView extends TemplateView<VerificationCancelle
[CancelReason.UserCancelled]: "Your other device cancelled the verification!", [CancelReason.UserCancelled]: "Your other device cancelled the verification!",
[CancelReason.InvalidMessage]: "Invalid message sent to the other device.", [CancelReason.InvalidMessage]: "Invalid message sent to the other device.",
[CancelReason.KeyMismatch]: "The other device could not verify our keys", [CancelReason.KeyMismatch]: "The other device could not verify our keys",
// [CancelReason.OtherDeviceAccepted]: "Another device has accepted this request.",
[CancelReason.TimedOut]: "The verification process timed out.", [CancelReason.TimedOut]: "The verification process timed out.",
[CancelReason.UnexpectedMessage]: "Unexpected message sent to the other device.", [CancelReason.UnexpectedMessage]: "Unexpected message sent to the other device.",
[CancelReason.UnknownMethod]: "Your other device does not understand the method you chose", [CancelReason.UnknownMethod]: "Your other device does not understand the method you chose",

View File

@ -14,11 +14,11 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {TemplateView} from "../../../general/TemplateView"; import {Builder, TemplateView} from "../../../general/TemplateView";
import type {VerificationCompleteViewModel} from "../../../../../../domain/session/verification/stages/VerificationCompleteViewModel"; import type {VerificationCompleteViewModel} from "../../../../../../domain/session/verification/stages/VerificationCompleteViewModel";
export class VerificationCompleteView extends TemplateView<VerificationCompleteViewModel> { export class VerificationCompleteView extends TemplateView<VerificationCompleteViewModel> {
render(t, vm: VerificationCompleteViewModel) { render(t: Builder<VerificationCompleteViewModel>, vm: VerificationCompleteViewModel) {
return t.div({ className: "VerificationCompleteView" }, [ return t.div({ className: "VerificationCompleteView" }, [
t.div({className: "VerificationCompleteView__icon"}), t.div({className: "VerificationCompleteView__icon"}),
t.div({ className: "VerificationCompleteView__heading" }, [ t.div({ className: "VerificationCompleteView__heading" }, [

View File

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {TemplateView} from "../../../general/TemplateView"; import {Builder, TemplateView} from "../../../general/TemplateView";
import {spinner} from "../../../common.js" import {spinner} from "../../../common.js"
import type {VerifyEmojisViewModel} from "../../../../../../domain/session/verification/stages/VerifyEmojisViewModel"; import type {VerifyEmojisViewModel} from "../../../../../../domain/session/verification/stages/VerifyEmojisViewModel";
export class VerifyEmojisView extends TemplateView<VerifyEmojisViewModel> { export class VerifyEmojisView extends TemplateView<VerifyEmojisViewModel> {
render(t, vm: VerifyEmojisViewModel) { render(t: Builder<VerifyEmojisViewModel>, vm: VerifyEmojisViewModel) {
const emojiList = vm.emojis.reduce((acc, [emoji, name]) => { const emojiList = vm.emojis.reduce((acc, [emoji, name]) => {
const e = t.div({ className: "EmojiContainer" }, [ const e = t.div({ className: "EmojiContainer" }, [
t.div({ className: "EmojiContainer__emoji" }, emoji), t.div({ className: "EmojiContainer__emoji" }, emoji),

View File

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import {TemplateView} from "../../../general/TemplateView"; import {Builder, TemplateView} from "../../../general/TemplateView";
import {spinner} from "../../../common.js"; import {spinner} from "../../../common.js";
import {WaitingForOtherUserViewModel} from "../../../../../../domain/session/verification/stages/WaitingForOtherUserViewModel"; import {WaitingForOtherUserViewModel} from "../../../../../../domain/session/verification/stages/WaitingForOtherUserViewModel";
export class WaitingForOtherUserView extends TemplateView<WaitingForOtherUserViewModel> { export class WaitingForOtherUserView extends TemplateView<WaitingForOtherUserViewModel> {
render(t, vm) { render(t: Builder<WaitingForOtherUserViewModel>, vm: WaitingForOtherUserViewModel) {
return t.div({ className: "WaitingForOtherUserView" }, [ return t.div({ className: "WaitingForOtherUserView" }, [
t.div({ className: "WaitingForOtherUserView__heading" }, [ t.div({ className: "WaitingForOtherUserView__heading" }, [
spinner(t), spinner(t),