TP-37153 | FGS update support added
This commit is contained in:
@@ -35,10 +35,9 @@ export const getPermissionsToRequest = async () => {
|
||||
if (!notificationStatus) {
|
||||
permissionsToRequest.push(permission);
|
||||
} else {
|
||||
const fgsTasks = CosmosForegroundService.getFgsTasks();
|
||||
const isFGSRunning = await CosmosForegroundService.isRunning();
|
||||
if (fgsTasks.length && !isFGSRunning) {
|
||||
CosmosForegroundService.start(fgsTasks);
|
||||
if (!isFGSRunning) {
|
||||
CosmosForegroundService.start();
|
||||
}
|
||||
if (!isNotificationPermissionEnabled) {
|
||||
CosmosForegroundService.update();
|
||||
|
||||
@@ -33,17 +33,18 @@ class CosmosForegroundService {
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public static getFgsTasks() {
|
||||
return CosmosForegroundService.fgsTasks;
|
||||
}
|
||||
|
||||
static async start(tasks: IForegroundTask[]) {
|
||||
static async start(tasks?: IForegroundTask[]) {
|
||||
if (GLOBAL.IS_IMPERSONATED) {
|
||||
return;
|
||||
}
|
||||
CosmosForegroundService.fgsTasks = tasks;
|
||||
if (!tasks && !this.fgsTasks.length) {
|
||||
return;
|
||||
}
|
||||
if (tasks?.length) {
|
||||
this.fgsTasks = tasks;
|
||||
}
|
||||
try {
|
||||
for (const currentTask of tasks) {
|
||||
for (const currentTask of this.fgsTasks) {
|
||||
if (!ForegroundService.is_running() || !ForegroundService.get_task(currentTask.taskId)) {
|
||||
if (!ForegroundService.is_running()) {
|
||||
//@ts-expect-error
|
||||
@@ -62,6 +63,9 @@ class CosmosForegroundService {
|
||||
if (GLOBAL.IS_IMPERSONATED) {
|
||||
return;
|
||||
}
|
||||
if (!this.fgsTasks.length) {
|
||||
return;
|
||||
}
|
||||
//@ts-expect-error
|
||||
ForegroundService.update(FOREGROUND_SERVICE_CONFIG);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user