mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
handle download error with notifications
This commit is contained in:
@@ -128,7 +128,7 @@ export class BSInstallerService{
|
||||
this.utils.newIpcSenc("bs-download.[Warning]", {success: true, data: out[1]});
|
||||
}
|
||||
else if(out[0] === "[Error]" as DownloadEventType){
|
||||
reject(out);
|
||||
reject(out[1]);
|
||||
this.killDownloadProcess();
|
||||
log.error("Download Event, Error", data.toString());
|
||||
}
|
||||
|
||||
@@ -9,16 +9,25 @@ import { BsmProgressBar } from "./components/progress-bar/bsm-progress-bar.compo
|
||||
import { useEffect } from "react";
|
||||
import { ThemeService } from "./services/theme.service";
|
||||
import { NotificationOverlay } from "./components/notification/notification-overlay.component";
|
||||
import { BsDownloaderService } from "./services/bs-downloader.service";
|
||||
import { NotificationService } from "./services/notification.service";
|
||||
import { distinctUntilChanged, filter, throttleTime } from "rxjs";
|
||||
|
||||
export default function App() {
|
||||
|
||||
const themeService = ThemeService.getInstance();
|
||||
const bsDownloadService = BsDownloaderService.getInstance();
|
||||
const notificationService = NotificationService.getInstance();
|
||||
|
||||
useEffect(() => {
|
||||
themeService.theme$.subscribe(() => {
|
||||
if(themeService.isDark || (themeService.isOS && window.matchMedia('(prefers-color-scheme: dark)').matches)){ document.documentElement.classList.add('dark'); }
|
||||
else { document.documentElement.classList.remove('dark'); }
|
||||
});
|
||||
|
||||
bsDownloadService.downloadWarning$.pipe(throttleTime(1000), filter(v => !!v), distinctUntilChanged()).subscribe(() => {
|
||||
notificationService.notifyWarning({title: "Warning", desc: "Your connection seems unstable"});
|
||||
});
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import { ProgressBarService } from "renderer/services/progress-bar.service";
|
||||
import { BsmButton } from "renderer/components/shared/bsm-button.component";
|
||||
import { AnimatePresence, motion } from "framer-motion";
|
||||
import { distinctUntilChanged } from "rxjs";
|
||||
import { NotificationService } from "renderer/services/notification.service";
|
||||
|
||||
export function AvailableVersionsList() {
|
||||
|
||||
@@ -21,6 +22,7 @@ export function AvailableVersionsList() {
|
||||
];
|
||||
const bsDownloaderService: BsDownloaderService = BsDownloaderService.getInstance();
|
||||
const progressBarService: ProgressBarService = ProgressBarService.getInstance();
|
||||
const notificationService: NotificationService = NotificationService.getInstance();
|
||||
|
||||
const [versionSelected, setVersionSelected] = useState(null as BSVersion);
|
||||
const [progressBarVisible, setProgressBarVisible] = useState(false);
|
||||
@@ -28,8 +30,11 @@ export function AvailableVersionsList() {
|
||||
const startDownload = () => {
|
||||
if(progressBarService.visible$.value){ return; }
|
||||
progressBarService.show(bsDownloaderService.downloadProgress$);
|
||||
bsDownloaderService.download(versionSelected).then(() => {
|
||||
bsDownloaderService.download(versionSelected).then(res => {
|
||||
progressBarService.hide(true);
|
||||
|
||||
if(res.success){ notificationService.notifySuccess({title: 'Download Complete', duration: 3000}); }
|
||||
else{ notificationService.notifyError({title: 'Error', desc: res.data as any as string}); }
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
import { DownloadEvent } from 'main/services/bs-installer.service';
|
||||
import { BehaviorSubject, distinctUntilChanged, Observable, Subscription } from 'rxjs';
|
||||
import { BehaviorSubject, distinctUntilChanged } from 'rxjs';
|
||||
import { IpcResponse } from 'shared/models/ipc-models.model';
|
||||
import { DownloadInfo } from '../../main/ipcs/bs-download-ipcs';
|
||||
import { BSVersion } from '../../main/services/bs-version-manager.service'
|
||||
import { AuthUserService } from './auth-user.service';
|
||||
import { BSVersionManagerService } from './bs-version-manager.service';
|
||||
import { ConfigurationService } from './configuration.service';
|
||||
import { IpcService } from './ipc.service';
|
||||
import { ModalExitCode, ModalService, ModalType } from './modale.service';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user