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() {
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() {
this.navigation.push("settings", true);
}
get kind(): string {
return "verification-cancelled";
}
}

View File

@ -32,4 +32,8 @@ export class VerificationCompleteViewModel extends ErrorReportViewModel<SegmentT
gotoSettings() {
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() {
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() {
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.
*/
import {TemplateView} from "../../general/TemplateView";
import {WaitingForOtherUserViewModel} from "../../../../../domain/session/verification/stages/WaitingForOtherUserViewModel";
import {Builder, TemplateView} from "../../general/TemplateView";
import {DeviceVerificationViewModel} from "../../../../../domain/session/verification/DeviceVerificationViewModel";
import {VerificationCancelledViewModel} from "../../../../../domain/session/verification/stages/VerificationCancelledViewModel";
import {WaitingForOtherUserView} from "./stages/WaitingForOtherUserView";
import {VerificationCancelledView} from "./stages/VerificationCancelledView";
import {SelectMethodViewModel} from "../../../../../domain/session/verification/stages/SelectMethodViewModel";
import {SelectMethodView} from "./stages/SelectMethodView";
import {VerifyEmojisViewModel} from "../../../../../domain/session/verification/stages/VerifyEmojisViewModel";
import {VerifyEmojisView} from "./stages/VerifyEmojisView";
import {VerificationCompleteViewModel} from "../../../../../domain/session/verification/stages/VerificationCompleteViewModel";
import {VerificationCompleteView} from "./stages/VerificationCompleteView";
export class DeviceVerificationView extends TemplateView<DeviceVerificationViewModel> {
render(t, vm) {
render(t: Builder<DeviceVerificationViewModel>) {
return t.div({
className: {
"middle": true,
@ -36,21 +31,22 @@ export class DeviceVerificationView extends TemplateView<DeviceVerificationViewM
}
}, [
t.mapView(vm => vm.currentStageViewModel, (stageVm) => {
if (stageVm instanceof WaitingForOtherUserViewModel) {
if (stageVm.kind === "waiting-for-user") {
return new WaitingForOtherUserView(stageVm);
}
else if (stageVm instanceof VerificationCancelledViewModel) {
else if (stageVm.kind === "verification-cancelled") {
return new VerificationCancelledView(stageVm);
}
else if (stageVm instanceof SelectMethodViewModel) {
else if (stageVm.kind === "select-method") {
return new SelectMethodView(stageVm);
}
else if (stageVm instanceof VerifyEmojisViewModel) {
else if (stageVm.kind === "verify-emojis") {
return new VerifyEmojisView(stageVm);
}
else if (stageVm instanceof VerificationCompleteViewModel) {
else if (stageVm.kind === "verification-completed") {
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.
*/
import {TemplateView} from "../../../general/TemplateView";
import {Builder, TemplateView} from "../../../general/TemplateView";
import {spinner} from "../../../common.js"
import type {SelectMethodViewModel} from "../../../../../../domain/session/verification/stages/SelectMethodViewModel";
export class SelectMethodView extends TemplateView<SelectMethodViewModel> {
render(t) {
render(t: Builder<SelectMethodViewModel>) {
return t.div({ className: "SelectMethodView" }, [
t.map(vm => vm.hasProceeded, (hasProceeded, t, vm) => {
if (hasProceeded) {

View File

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import {TemplateView} from "../../../general/TemplateView";
import {Builder, TemplateView} from "../../../general/TemplateView";
import {VerificationCancelledViewModel} from "../../../../../../domain/session/verification/stages/VerificationCancelledViewModel";
import {CancelReason} from "../../../../../../matrix/verification/SAS/channel/types";
export class VerificationCancelledView extends TemplateView<VerificationCancelledViewModel> {
render(t, vm: VerificationCancelledViewModel) {
render(t: Builder<VerificationCancelledViewModel>, vm: VerificationCancelledViewModel) {
const headerTextStart = vm.isCancelledByUs ? "You" : "The other device";
return t.div(
@ -50,10 +50,8 @@ export class VerificationCancelledView extends TemplateView<VerificationCancelle
getDescriptionFromCancellationCode(code: CancelReason, isCancelledByUs: boolean): string {
const descriptionsWhenWeCancelled = {
// [CancelReason.UserCancelled]: NO_NEED_FOR_DESCRIPTION_HERE
[CancelReason.InvalidMessage]: "You other device sent an invalid message.",
[CancelReason.KeyMismatch]: "The key could not be verified.",
// [CancelReason.OtherDeviceAccepted]: "Another device has accepted this request.",
[CancelReason.TimedOut]: "The verification process timed out.",
[CancelReason.UnexpectedMessage]: "Your other device sent an unexpected message.",
[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.InvalidMessage]: "Invalid message sent to the other device.",
[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.UnexpectedMessage]: "Unexpected message sent to the other device.",
[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.
*/
import {TemplateView} from "../../../general/TemplateView";
import {Builder, TemplateView} from "../../../general/TemplateView";
import type {VerificationCompleteViewModel} from "../../../../../../domain/session/verification/stages/VerificationCompleteViewModel";
export class VerificationCompleteView extends TemplateView<VerificationCompleteViewModel> {
render(t, vm: VerificationCompleteViewModel) {
render(t: Builder<VerificationCompleteViewModel>, vm: VerificationCompleteViewModel) {
return t.div({ className: "VerificationCompleteView" }, [
t.div({className: "VerificationCompleteView__icon"}),
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.
*/
import {TemplateView} from "../../../general/TemplateView";
import {Builder, TemplateView} from "../../../general/TemplateView";
import {spinner} from "../../../common.js"
import type {VerifyEmojisViewModel} from "../../../../../../domain/session/verification/stages/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 e = t.div({ className: "EmojiContainer" }, [
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.
*/
import {TemplateView} from "../../../general/TemplateView";
import {Builder, TemplateView} from "../../../general/TemplateView";
import {spinner} from "../../../common.js";
import {WaitingForOtherUserViewModel} from "../../../../../../domain/session/verification/stages/WaitingForOtherUserViewModel";
export class WaitingForOtherUserView extends TemplateView<WaitingForOtherUserViewModel> {
render(t, vm) {
render(t: Builder<WaitingForOtherUserViewModel>, vm: WaitingForOtherUserViewModel) {
return t.div({ className: "WaitingForOtherUserView" }, [
t.div({ className: "WaitingForOtherUserView__heading" }, [
spinner(t),