From 07ebf3926b5077435ac5891215a8bc4151b5f15e Mon Sep 17 00:00:00 2001 From: redphx <96280+redphx@users.noreply.github.com> Date: Sat, 7 Sep 2024 16:43:56 +0700 Subject: [PATCH] Update script in app when clicking on the "Version x available" button --- src/modules/ui/dialog/settings-dialog.ts | 19 +++++++++----- src/utils/html.ts | 2 +- .../global-settings-storage.ts | 2 +- src/utils/translation.ts | 25 +++++++++++++++++-- 4 files changed, 38 insertions(+), 10 deletions(-) diff --git a/src/modules/ui/dialog/settings-dialog.ts b/src/modules/ui/dialog/settings-dialog.ts index d525d20..64e7309 100644 --- a/src/modules/ui/dialog/settings-dialog.ts +++ b/src/modules/ui/dialog/settings-dialog.ts @@ -1,5 +1,5 @@ import { onChangeVideoPlayerType, updateVideoPlayer } from "@/modules/stream/stream-settings-utils"; -import { ButtonStyle, CE, createButton, createSvgIcon, removeChildElements } from "@/utils/html"; +import { ButtonStyle, CE, createButton, createSvgIcon, removeChildElements, type BxButton } from "@/utils/html"; import { NavigationDialog, NavigationDirection } from "./navigation-dialog"; import { ControllerShortcut } from "@/modules/controller-shortcut"; import { MkbRemapper } from "@/modules/mkb/mkb-remapper"; @@ -97,12 +97,19 @@ export class SettingsNavigationDialog extends NavigationDialog { // "New version available" button if (!SCRIPT_VERSION.includes('beta') && PREF_LATEST_VERSION && PREF_LATEST_VERSION != SCRIPT_VERSION) { - // Show new version indicator - topButtons.push(createButton({ - label: `🌟 Version ${PREF_LATEST_VERSION} available`, + // Show new version button + const opts = { + label: '🌟 ' + t('new-version-available', {version: PREF_LATEST_VERSION}), style: ButtonStyle.PRIMARY | ButtonStyle.FOCUSABLE | ButtonStyle.FULL_WIDTH, - url: 'https://github.com/redphx/better-xcloud/releases/latest', - })); + } as BxButton; + + if (AppInterface && AppInterface.updateLatestScript) { + opts.onClick = e => AppInterface.updateLatestScript(); + } else { + opts.url = 'https://github.com/redphx/better-xcloud/releases/latest'; + } + + topButtons.push(createButton(opts)); } // Buttons for Android app diff --git a/src/utils/html.ts b/src/utils/html.ts index fb67328..3e921b3 100644 --- a/src/utils/html.ts +++ b/src/utils/html.ts @@ -32,7 +32,7 @@ const ButtonStyleClass = { [ButtonStyle.NORMAL_LINK]: 'bx-normal-link', } -type BxButton = { +export type BxButton = { style?: ButtonStyle; url?: string; classes?: string[]; diff --git a/src/utils/settings-storages/global-settings-storage.ts b/src/utils/settings-storages/global-settings-storage.ts index 0b2efa1..4ea79a7 100644 --- a/src/utils/settings-storages/global-settings-storage.ts +++ b/src/utils/settings-storages/global-settings-storage.ts @@ -584,7 +584,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage { default: 'default', options: { 'default': t('default'), - 'low-power': t('low-power'), + 'low-power': t('battery-saving'), 'high-performance': t('high-performance'), }, suggest: { diff --git a/src/utils/translation.ts b/src/utils/translation.ts index bb27696..f419cc7 100644 --- a/src/utils/translation.ts +++ b/src/utils/translation.ts @@ -47,6 +47,7 @@ const Texts = { "badge-playtime": "Playtime", "badge-server": "Server", "badge-video": "Video", + "battery-saving": "Battery saving", "better-xcloud": "Better xCloud", "bitrate-audio-maximum": "Maximum audio bitrate", "bitrate-video-maximum": "Maximum video bitrate", @@ -142,7 +143,6 @@ const Texts = { "load-failed-message": "Failed to run Better xCloud", "loading-screen": "Loading screen", "local-co-op": "Local co-op", - "low-power": "Low power", "lowest-quality": "Lowest quality", "map-mouse-to": "Map mouse to", "may-not-work-properly": "May not work properly!", @@ -157,6 +157,27 @@ const Texts = { "name": "Name", "native-mkb": "Native Mouse & Keyboard", "new": "New", + "new-version-available": [ + (e: any) => `Version ${e.version} available`, + , + , + , + , + , + , + , + (e: any) => `Ver ${e.version} が利用可能です`, + (e: any) => `${e.version} 버전 사용가능`, + , + , + , + , + , + , + (e: any) => `Đã có phiên bản ${e.version}`, + , + , + ], "no-consoles-found": "No consoles found", "normal": "Normal", "off": "Off", @@ -199,7 +220,7 @@ const Texts = { "recommended": "Recommended", "recommended-settings-for-device": [ (e: any) => `Recommended settings for ${e.device}`, - , + (e: any) => `Configuració recomanada per a ${e.device}`, , (e: any) => `Empfohlene Einstellungen für ${e.device}`, ,