From aa8c8377edd69dc5ac50441ec2816b5711d0e128 Mon Sep 17 00:00:00 2001 From: Rémy Raes Date: Mon, 12 Jun 2023 22:43:08 +0200 Subject: fix: Display install messages even outside mod view (#391) --- src-vue/src/components/ThunderstoreModCard.vue | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src-vue') diff --git a/src-vue/src/components/ThunderstoreModCard.vue b/src-vue/src/components/ThunderstoreModCard.vue index c25b19a2..2fbbac40 100644 --- a/src-vue/src/components/ThunderstoreModCard.vue +++ b/src-vue/src/components/ThunderstoreModCard.vue @@ -251,8 +251,11 @@ export default defineComponent({ this.isBeingInstalled = true; } - await invoke("install_mod_caller", { gameInstall: game_install, thunderstoreModString: this.latestVersion.full_name }).then((message) => { - showNotification(this.$t('mods.card.install_success', { modName: mod.name }), message); + // Capture translation method in a context, so it can be used outside Vue component context. + // (see https://github.com/R2NorthstarTools/FlightCore/issues/384) + (async (translate: Function) => { + await invoke("install_mod_caller", { gameInstall: game_install, thunderstoreModString: this.latestVersion.full_name }).then((message) => { + showNotification(translate('mods.card.install_success', { modName: mod.name }), message); }) .catch((error) => { showErrorNotification(error); @@ -262,6 +265,9 @@ export default defineComponent({ this.isBeingUpdated = false; this.$store.commit('loadInstalledMods'); }); + // @ts-ignore + })(this.$i18n.t); + }, } }); -- cgit v1.2.3