mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
add oneClick system notifications translations
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
import { SystemNotificationOptions } from "shared/models/notification/system-notification.model";
|
||||
import { I18nService } from "./i18n.service";
|
||||
import { IpcService } from "./ipc.service";
|
||||
|
||||
export class NotificationService{
|
||||
@@ -17,11 +16,9 @@ export class NotificationService{
|
||||
public readonly notifications$: BehaviorSubject<ResolvableNotification[]>;
|
||||
|
||||
private readonly ipc: IpcService;
|
||||
private readonly i18n: I18nService;
|
||||
|
||||
private constructor(){
|
||||
this.ipc = IpcService.getInstance();
|
||||
this.i18n = I18nService.getInstance();
|
||||
this.notifications$ = new BehaviorSubject<ResolvableNotification[]>([]);
|
||||
}
|
||||
|
||||
@@ -57,10 +54,6 @@ export class NotificationService{
|
||||
}
|
||||
|
||||
public notifySystem(options: SystemNotificationOptions){
|
||||
|
||||
options.body = options.body && this.i18n.translate(options.body);
|
||||
options.title = options.title && this.i18n.translate(options.title);
|
||||
|
||||
this.ipc.sendLazy<SystemNotificationOptions>("notify-system", {args: options});
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,6 @@ export class PlaylistDownloaderService{
|
||||
|
||||
public oneClickInstallPlaylist(bpListUrl: string): Observable<DownloadPlaylistProgression>{
|
||||
|
||||
if(!this.progress.require()){ return null; }
|
||||
|
||||
this.progressWatcher$.next(null);
|
||||
|
||||
const res = new Subject<DownloadPlaylistProgression>();
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { BsmProgressBar } from "renderer/components/progress-bar/bsm-progress-bar.component";
|
||||
import { BsmImage } from "renderer/components/shared/bsm-image.component";
|
||||
import TitleBar from "renderer/components/title-bar/title-bar.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { IpcService } from "renderer/services/ipc.service";
|
||||
import { MapsDownloaderService } from "renderer/services/maps-downloader.service";
|
||||
import { NotificationService } from "renderer/services/notification.service";
|
||||
@@ -24,6 +25,7 @@ export default function OneClickDownloadMap() {
|
||||
const notification = NotificationService.getInstance();
|
||||
|
||||
const [mapInfo, setMapInfo] = useState<BsvMapDetail>(null);
|
||||
const t = useTranslation();
|
||||
|
||||
const cover = mapInfo ? mapInfo.versions.at(0).coverURL : null;
|
||||
const title = mapInfo ? mapInfo.name : null;
|
||||
@@ -49,10 +51,12 @@ export default function OneClickDownloadMap() {
|
||||
|
||||
setMapInfo(() => mapDetails);
|
||||
|
||||
await mapsDownloader.oneClickInstallMap(mapDetails);
|
||||
const res = await mapsDownloader.oneClickInstallMap(mapDetails);
|
||||
|
||||
progressBar.complete();
|
||||
|
||||
if(!res){ return reject(); }
|
||||
|
||||
await timer(300).toPromise();
|
||||
|
||||
resolve();
|
||||
@@ -66,11 +70,11 @@ export default function OneClickDownloadMap() {
|
||||
// TODO TRANSLATE
|
||||
|
||||
promise.catch(() => {
|
||||
notification.notifySystem({title: "Erreur", body: "Une erreur c'est produite lors de l'installation de la map"});
|
||||
})
|
||||
notification.notifySystem({title: t("notifications.types.error"), body: t("notifications.maps.one-click-install.error")});
|
||||
});
|
||||
|
||||
promise.then(() => {
|
||||
notification.notifySystem({title: "OneClick", body: "Installation de la map terminé"});
|
||||
notification.notifySystem({title: "OneClick", body: t("notifications.maps.one-click-install.success")});
|
||||
});
|
||||
|
||||
promise.finally(() =>{
|
||||
|
||||
@@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
|
||||
import { BsmProgressBar } from "renderer/components/progress-bar/bsm-progress-bar.component";
|
||||
import { BsmImage } from "renderer/components/shared/bsm-image.component";
|
||||
import TitleBar from "renderer/components/title-bar/title-bar.component";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { IpcService } from "renderer/services/ipc.service";
|
||||
import { ModelDownloaderService } from "renderer/services/model-downloader.service";
|
||||
import { NotificationService } from "renderer/services/notification.service";
|
||||
@@ -23,6 +24,7 @@ export default function OneClickDownloadModel() {
|
||||
const notification = NotificationService.getInstance();
|
||||
|
||||
const [model, setModel] = useState<MSModel>(null);
|
||||
const t = useTranslation();
|
||||
|
||||
const cover = model ? model.thumbnail : null;
|
||||
const title = model ? model.name : null;
|
||||
@@ -38,26 +40,32 @@ export default function OneClickDownloadModel() {
|
||||
|
||||
const infos = await ipc.send<{id: string, type: string}>("one-click-model-info");
|
||||
|
||||
if(!infos.success){ reject(); }
|
||||
if(!infos.success){ return reject(); }
|
||||
|
||||
const model = await modelSaber.getModelById(infos.data.id);
|
||||
|
||||
if(!model){ return reject(); }
|
||||
|
||||
setModel(() => model);
|
||||
|
||||
progress.open();
|
||||
|
||||
resolve(modelDownloader.oneClickInstallModel(model));
|
||||
const res = await modelDownloader.oneClickInstallModel(model);
|
||||
|
||||
if(!res){ return reject(); }
|
||||
|
||||
resolve(res);
|
||||
|
||||
});
|
||||
|
||||
// TODO TRANSLATE
|
||||
|
||||
promise.catch(() => {
|
||||
notification.notifySystem({title: "Erreur", body: "Une erreur c'est produite lors de l'installation du model"});
|
||||
notification.notifySystem({title: t("notifications.types.error"), body: t("notifications.models.one-click-install.error")});
|
||||
})
|
||||
|
||||
promise.then(() => {
|
||||
notification.notifySystem({title: "OneClick", body: "Installation du model terminé"});
|
||||
notification.notifySystem({title: "OneClick", body: t("notifications.models.one-click-install.success")});
|
||||
});
|
||||
|
||||
promise.finally(() => windows.close("oneclick-download-model.html"));
|
||||
|
||||
@@ -4,6 +4,7 @@ import { BsmProgressBar } from "renderer/components/progress-bar/bsm-progress-ba
|
||||
import { BsmImage } from "renderer/components/shared/bsm-image.component";
|
||||
import TitleBar from "renderer/components/title-bar/title-bar.component";
|
||||
import { useObservable } from "renderer/hooks/use-observable.hook";
|
||||
import { useTranslation } from "renderer/hooks/use-translation.hook";
|
||||
import { IpcService } from "renderer/services/ipc.service"
|
||||
import { NotificationService } from "renderer/services/notification.service";
|
||||
import { PlaylistDownloaderService } from "renderer/services/playlist-downloader.service";
|
||||
@@ -26,6 +27,7 @@ export default function OneClickDownloadPlaylist() {
|
||||
|
||||
const [playlist, setPlaylist] = useState<BsvPlaylist>(null);
|
||||
const downloadedMap = useObservable(playlistDownloader.progress$.pipe(filter(download => !!download), map(download => [...(download.downloadedMaps ?? []), download?.current])), []);
|
||||
const t = useTranslation();
|
||||
|
||||
const cover = playlist ? playlist.playlistImage : null;
|
||||
const title = playlist ? playlist.name : null;
|
||||
@@ -41,24 +43,26 @@ export default function OneClickDownloadPlaylist() {
|
||||
|
||||
const infos = await ipc.send<{bpListUrl: string, id: string}>("one-click-playlist-info");
|
||||
|
||||
if(!infos.success){ reject(infos.error); }
|
||||
if(!infos.success){ return reject(infos.error); }
|
||||
|
||||
bSaver.getPlaylistDetailsById(infos.data.id).then(details => setPlaylist(details));
|
||||
|
||||
const res = await playlistDownloader.oneClickInstallPlaylist(infos.data.bpListUrl).toPromise();
|
||||
|
||||
resolve(res);
|
||||
playlistDownloader.oneClickInstallPlaylist(infos.data.bpListUrl).toPromise().then(res => {
|
||||
resolve(res);
|
||||
}).catch(() => {
|
||||
reject();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// TODO TRANSLATE
|
||||
|
||||
promise.catch(() => {
|
||||
notification.notifySystem({title: "Erreur", body: "Une erreur c'est produite lors de l'installation de la playlist"});
|
||||
notification.notifySystem({title: t("notifications.types.error"), body: t("notifications.playlists.one-click-install.error")});
|
||||
})
|
||||
|
||||
promise.then(() => {
|
||||
notification.notifySystem({title: "OneClick", body: "Installation de la playlist terminé"});
|
||||
notification.notifySystem({title: "OneClick", body: t("notifications.playlists.one-click-install.success")});
|
||||
});
|
||||
|
||||
promise.finally(() => {
|
||||
|
||||
Reference in New Issue
Block a user