diff --git a/assets/jsons/translations/en.json b/assets/jsons/translations/en.json index 0987426f..26c91e56 100644 --- a/assets/jsons/translations/en.json +++ b/assets/jsons/translations/en.json @@ -252,6 +252,14 @@ "error":{ "description":"An unknown error occurred." } + }, + "check-all-enabled":{ + "title": "OneClick Disabled", + "description": "One or more OneClick installations are disabled. Go to settings to enable them.", + "actions":{ + "settings": "Settings", + "not-remind": "Do not remind me" + } } } } diff --git a/assets/jsons/translations/es.json b/assets/jsons/translations/es.json index dc6ab660..92030fdf 100644 --- a/assets/jsons/translations/es.json +++ b/assets/jsons/translations/es.json @@ -252,6 +252,14 @@ "error":{ "description":"Ocurrió un error desconocido." } + }, + "check-all-enabled":{ + "title": "OneClick deshabilitado", + "description": "Una o más instalaciones de OneClick están deshabilitadas. Vaya a la configuración para habilitarlas.", + "actions":{ + "settings": "Ajustes", + "not-remind": "No volver a recordarme" + } } } } diff --git a/assets/jsons/translations/fr.json b/assets/jsons/translations/fr.json index d6365a2b..b9eb7f7c 100644 --- a/assets/jsons/translations/fr.json +++ b/assets/jsons/translations/fr.json @@ -252,6 +252,14 @@ "error":{ "description":"Une erreur inconnue s'est produite." } + }, + "check-all-enabled":{ + "title": "OneClick désactivée(s)", + "description": "Une ou plusieurs installations OneClick sont désactivées. Rendez-vous dans les paramètres pour les activer.", + "actions":{ + "settings": "Paramètres", + "not-remind": "Ne plus me rappeler" + } } } } diff --git a/src/renderer/components/notification/notification-item.component.tsx b/src/renderer/components/notification/notification-item.component.tsx index a0838bd9..3e9522fb 100644 --- a/src/renderer/components/notification/notification-item.component.tsx +++ b/src/renderer/components/notification/notification-item.component.tsx @@ -37,7 +37,7 @@ export function NotificationItem({resolver, notification}: {resolver?: (value: N } return ( - +
diff --git a/src/renderer/components/settings/setting-container.component.tsx b/src/renderer/components/settings/setting-container.component.tsx index 9b625748..e86ced16 100644 --- a/src/renderer/components/settings/setting-container.component.tsx +++ b/src/renderer/components/settings/setting-container.component.tsx @@ -1,12 +1,21 @@ import { ReactNode } from "react"; import { useTranslation } from "renderer/hooks/use-translation.hook"; -export function SettingContainer({className, title, minorTitle, description, children}: {className?: string, title?: string, minorTitle?: string, description?: string, children?: ReactNode}) { +type Props = { + id?: string, + className?: string, + title?: string, + minorTitle?: string, + description?: string, + children?: ReactNode +} + +export function SettingContainer({id, className, title, minorTitle, description, children}: Props) { const t = useTranslation(); return ( -
+
{ title &&

{t(title)}

} { minorTitle &&

{t(minorTitle)}

} { description &&

{t(description)}

} diff --git a/src/renderer/pages/settings-page.component.tsx b/src/renderer/pages/settings-page.component.tsx index 39b5bb38..df45dda2 100644 --- a/src/renderer/pages/settings-page.component.tsx +++ b/src/renderer/pages/settings-page.component.tsx @@ -229,7 +229,7 @@ export function SettingsPage() { - +
  • diff --git a/src/renderer/windows/App.tsx b/src/renderer/windows/App.tsx index b4b95473..1cd2e173 100644 --- a/src/renderer/windows/App.tsx +++ b/src/renderer/windows/App.tsx @@ -1,6 +1,6 @@ import { NavBar } from "../components/nav-bar/nav-bar.component"; import TitleBar from "../components/title-bar/title-bar.component"; -import { Routes, Route, useLocation } from "react-router-dom"; +import { Routes, Route, useLocation, useNavigate } from "react-router-dom"; import { AvailableVersionsList } from "../pages/available-versions-list.components"; import { VersionViewer } from "../pages/version-viewer.component"; import { Modal } from "../components/modal/modal.component"; @@ -14,24 +14,83 @@ import { MapsPage } from "../pages/maps-page.component"; import "tailwindcss/tailwind.css"; import { BsmIframeView } from "../components/shared/bsm-map-preview.component"; import 'tippy.js/dist/tippy.css'; +import { MapsManagerService } from "renderer/services/maps-manager.service"; +import { PlaylistsManagerService } from "renderer/services/playlists-manager.service"; +import { ModelsManagerService } from "renderer/services/models-manager.service"; +import { NotificationService } from "renderer/services/notification.service"; +import { timer } from "rxjs"; +import { ConfigurationService } from "renderer/services/configuration.service"; export default function App() { const themeService = ThemeService.getInstance(); const pageState = PageStateService.getInstance(); + const maps = MapsManagerService.getInstance(); + const playlists = PlaylistsManagerService.getInstance(); + const models = ModelsManagerService.getInstance(); + const notification = NotificationService.getInstance(); + const config = ConfigurationService.getInstance(); const location = useLocation(); + const navigate = useNavigate(); useEffect(() => { themeService.theme$.subscribe(() => { if(themeService.isDark || (themeService.isOS && window.matchMedia('(prefers-color-scheme: dark)').matches)){ return document.documentElement.classList.add('dark'); } document.documentElement.classList.remove('dark'); }); + + checkOneClicks(); + }, []); + const checkOneClicks = async () => { + + if(config.get("not-remind-oneclick") === true){ return; } + + await timer(2_000).toPromise(); + + const oneClicks = await Promise.all([ + maps.isDeepLinksEnabled(), + playlists.isDeepLinksEnabled(), + models.isDeepLinksEnabled() + ]); + + if(!oneClicks.some(enabled => enabled === false)){ return; } + + const choice = await notification.notifyWarning({ + title: "notifications.settings.additional-content.deep-link.check-all-enabled.title", + desc: "notifications.settings.additional-content.deep-link.check-all-enabled.description", + duration: 10_000, + actions: [ + {id: "0", title: "notifications.settings.additional-content.deep-link.check-all-enabled.actions.settings"}, + {id: "1", title: "notifications.settings.additional-content.deep-link.check-all-enabled.actions.not-remind", cancel: true} + ] + }); + + if(choice === "0"){ + return navigate("/settings#one-clicks"); + } + + if(choice === "1"){ + config.set("not-remind-oneclick", true); + } + + } useEffect(() => { + pageState.setLocation(location); + + if(!location.hash){ return; } + + const hash = location.hash.replace("#", ""); + const el = document.getElementById(hash); + + if(!el){ return; } + + el.scrollIntoView({block: "start", behavior: "smooth"}); + }, [location])