[chore] reimplement login with meta

This commit is contained in:
MathieuG-P
2024-12-24 12:01:24 +01:00
parent 8eec1fe611
commit cda8a8a3f3
18 changed files with 187 additions and 75 deletions
@@ -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"));
}
}