Prompt refresh when build UUID changes (#24)
This commit is contained in:
@@ -10,6 +10,7 @@ import ApiResponse from '../structures/ApiResponse';
|
||||
export class ApiService {
|
||||
protected baseEndpoint: string = environment.backendBase;
|
||||
protected statUrl: string = environment.statUrl;
|
||||
protected versionUrl: string = environment.versionUrl;
|
||||
|
||||
constructor(
|
||||
protected http: HttpClient,
|
||||
@@ -31,6 +32,17 @@ export class ApiService {
|
||||
return this._request(this.statUrl);
|
||||
}
|
||||
|
||||
public version(): Promise<string> {
|
||||
return new Promise((res, rej) => {
|
||||
this._request(this.versionUrl).subscribe({
|
||||
next: result => {
|
||||
res(result.data.text.trim());
|
||||
},
|
||||
error: rej,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
protected _request(endpoint, params = {}, method: 'get'|'post' = 'get'): Observable<ApiResponse> {
|
||||
return new Observable<ApiResponse>(sub => {
|
||||
let data: any = {}
|
||||
|
||||
@@ -11,6 +11,7 @@ export class SessionService {
|
||||
protected data: any = {};
|
||||
protected saveTriggered = false;
|
||||
protected saving = false;
|
||||
protected loadedVersion = '';
|
||||
protected privTriggerSave = debounce(() => {
|
||||
if ( this.saving ) {
|
||||
this.triggerSave();
|
||||
@@ -26,11 +27,21 @@ export class SessionService {
|
||||
this.privTriggerSave();
|
||||
}
|
||||
|
||||
public get version() {
|
||||
return this.loadedVersion;
|
||||
}
|
||||
|
||||
constructor(
|
||||
protected readonly api: ApiService,
|
||||
) { }
|
||||
|
||||
async newVersionAvailable() {
|
||||
return (await this.api.version()) !== this.loadedVersion;
|
||||
}
|
||||
|
||||
async stat() {
|
||||
this.loadedVersion = await this.api.version();
|
||||
|
||||
return new Promise((res, rej) => {
|
||||
this.api.stat().subscribe(response => {
|
||||
res(response.data);
|
||||
|
||||
Reference in New Issue
Block a user