mirror of
https://github.com/Zagrios/bs-manager.git
synced 2026-07-03 14:08:25 +02:00
[chore] reimplement login with meta
This commit is contained in:
@@ -8,10 +8,9 @@ import { NotificationService } from "../notification.service";
|
||||
import { ModalExitCode, ModalService } from "../modale.service";
|
||||
import { DownloaderServiceInterface } from "./bs-store-downloader.interface";
|
||||
import { AbstractBsDownloaderService } from "./abstract-bs-downloader.service";
|
||||
import { DownloadInfo } from "main/services/bs-version-download/bs-steam-downloader.service";
|
||||
import { MetaAuthErrorCodes, OculusDownloaderErrorCodes } from "shared/models/bs-version-download/oculus-download.model";
|
||||
import { EnterMetaTokenModal } from "renderer/components/modal/modal-types/bs-downgrade/enter-meta-token-modal.component";
|
||||
import { addFilterStringLog } from "renderer";
|
||||
import { LoginToMetaModal } from "renderer/components/modal/modal-types/bs-downgrade/login-to-meta-modal.component";
|
||||
import { OculusDownloadInfo } from "main/services/bs-version-download/bs-oculus-downloader.service";
|
||||
|
||||
export class OculusDownloaderService extends AbstractBsDownloaderService implements DownloaderServiceInterface{
|
||||
|
||||
@@ -69,7 +68,7 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
|
||||
);
|
||||
}
|
||||
|
||||
private startDownloadBsVersion(downloadInfo: DownloadInfo): Observable<Progression<BSVersion>>{
|
||||
private startDownloadBsVersion(downloadInfo: OculusDownloadInfo): Observable<Progression<BSVersion>>{
|
||||
const ignoreCode = [MetaAuthErrorCodes.META_LOGIN_WINDOW_CLOSED_BY_USER, OculusDownloaderErrorCodes.DOWNLOAD_CANCELLED];
|
||||
return this.handleDownload(
|
||||
this.ipc.sendV2("bs-oculus-download", downloadInfo ),
|
||||
@@ -77,25 +76,16 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
|
||||
);
|
||||
}
|
||||
|
||||
private async doDownloadBsVersion(bsVersion: BSVersion, isVerification: boolean): Promise<BSVersion> {
|
||||
private async doDownloadBsVersion(bsVersion: BSVersion, isVerification: boolean): Promise<BSVersion|undefined> {
|
||||
|
||||
const autoDownloadFailed = false;
|
||||
const {exitCode, data: token} = await this.modals.openModal(LoginToMetaModal)
|
||||
|
||||
return (async () => {
|
||||
if(exitCode !== ModalExitCode.COMPLETED){
|
||||
return undefined
|
||||
}
|
||||
|
||||
const tokenRes = await this.modals.openModal(EnterMetaTokenModal);
|
||||
|
||||
if(tokenRes.exitCode !== ModalExitCode.COMPLETED){
|
||||
return false;
|
||||
}
|
||||
|
||||
addFilterStringLog(tokenRes.data);
|
||||
|
||||
return lastValueFrom(this.startDownloadBsVersion({ bsVersion, isVerification, token: tokenRes.data })).then(() => true);
|
||||
|
||||
})().then(res => {
|
||||
|
||||
if(autoDownloadFailed || !res){
|
||||
return lastValueFrom(this.startDownloadBsVersion({ bsVersion, isVerification, token })).then(() => true).then(res => {
|
||||
if(!res){
|
||||
return bsVersion;
|
||||
}
|
||||
|
||||
@@ -121,4 +111,12 @@ export class OculusDownloaderService extends AbstractBsDownloaderService impleme
|
||||
return lastValueFrom(this.ipc.sendV2("bs-oculus-stop-download"));
|
||||
}
|
||||
|
||||
public deleteMetaSession(): Promise<void>{
|
||||
return lastValueFrom(this.ipc.sendV2("delete-meta-session"));
|
||||
}
|
||||
|
||||
public metaSessionExists(): Promise<boolean>{
|
||||
return lastValueFrom(this.ipc.sendV2("meta-session-exists"));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user