refactor: improve router type safety and usage

- Add explicit Router type imports across views
- Replace $router type casting with proper typing
- Use $router.back() instead of $router.go(-1) for consistency
- Add proper route and router typings to components
- Clean up router navigation methods
- Fix router push/back method calls

This commit improves type safety and consistency in router usage across
the application's view components.
This commit is contained in:
Matthew Raymer
2025-02-26 06:50:08 +00:00
parent 61da40596c
commit 03178d35e7
56 changed files with 581 additions and 251 deletions

View File

@@ -66,7 +66,11 @@
<script lang="ts">
import axios from "axios";
import { Component, Vue } from "vue-facing-decorator";
import { RouteLocationRaw, Router } from "vue-router";
import {
RouteLocationNormalizedLoaded,
RouteLocationRaw,
Router,
} from "vue-router";
import PhotoDialog from "../components/PhotoDialog.vue";
import QuickNav from "../components/QuickNav.vue";
@@ -83,6 +87,8 @@ import { base64ToBlob, SHARED_PHOTO_BASE64_KEY } from "../libs/util";
@Component({ components: { PhotoDialog, QuickNav } })
export default class SharedPhotoView extends Vue {
$notify!: (notification: NotificationIface, timeout?: number) => void;
$router!: Router;
$route!: RouteLocationNormalizedLoaded;
activeDid: string | undefined = undefined;
imageBlob: Blob | undefined = undefined;
@@ -105,9 +111,7 @@ export default class SharedPhotoView extends Vue {
// clear the temp image
db.temp.delete(SHARED_PHOTO_BASE64_KEY);
this.imageFileName = (this.$route as Router).query[
"fileName"
] as string;
this.imageFileName = this.$route.query["fileName"] as string;
} else {
console.error("No appropriate image found in temp storage.", temp);
}
@@ -138,7 +142,7 @@ export default class SharedPhotoView extends Vue {
recipientDid: this.activeDid,
},
} as RouteLocationRaw;
(this.$router as Router).push(route);
this.$router.push(route);
}
});
}
@@ -149,7 +153,7 @@ export default class SharedPhotoView extends Vue {
await db.settings.update(MASTER_SETTINGS_KEY, {
profileImageUrl: imgUrl,
});
(this.$router as Router).push({ name: "account" });
this.$router.push({ name: "account" });
},
IMAGE_TYPE_PROFILE,
true,
@@ -161,7 +165,7 @@ export default class SharedPhotoView extends Vue {
async cancel() {
this.imageBlob = undefined;
this.imageFileName = undefined;
(this.$router as Router).push({ name: "home" });
this.$router.push({ name: "home" });
}
async sendToImageServer(imageType: string) {