TP-37153 | FGS update support added

This commit is contained in:
Aman Chaturvedi
2023-08-31 11:41:52 +05:30
parent 5607670eb0
commit 4edbca352d
2 changed files with 13 additions and 10 deletions

View File

@@ -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();

View File

@@ -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);
}