mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-21 17:12:43 +00:00
fix: background fetch crashing android app
This commit is contained in:
@@ -20,8 +20,7 @@ import moment, {duration, Moment, unitOfTime} from 'moment';
|
||||
import {Dialog} from '@capacitor/dialog';
|
||||
import {CalendarInfo} from './calendar-info';
|
||||
import {Subject} from 'rxjs';
|
||||
|
||||
const CALENDAR_NAME = 'StApps';
|
||||
import {ConfigProvider} from '../config/config.provider';
|
||||
|
||||
const RECURRENCE_PATTERNS: Partial<
|
||||
Record<unitOfTime.Diff, string | undefined>
|
||||
@@ -38,15 +37,23 @@ export class CalendarService {
|
||||
|
||||
goToDateClicked = this.goToDate.asObservable();
|
||||
|
||||
calendarName = 'StApps';
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
||||
constructor(readonly calendar: Calendar) {}
|
||||
constructor(
|
||||
readonly calendar: Calendar,
|
||||
private readonly configProvider: ConfigProvider,
|
||||
) {
|
||||
this.calendarName =
|
||||
(this.configProvider.getValue('name') as string) ?? 'StApps';
|
||||
}
|
||||
|
||||
async createCalendar(): Promise<CalendarInfo | undefined> {
|
||||
await this.calendar.createCalendar({
|
||||
calendarName: CALENDAR_NAME,
|
||||
calendarName: this.calendarName,
|
||||
calendarColor: '#ff8740',
|
||||
});
|
||||
return this.findCalendar(CALENDAR_NAME);
|
||||
return this.findCalendar(this.calendarName);
|
||||
}
|
||||
|
||||
async listCalendars(): Promise<CalendarInfo[] | undefined> {
|
||||
@@ -60,8 +67,8 @@ export class CalendarService {
|
||||
}
|
||||
|
||||
async purge(): Promise<CalendarInfo | undefined> {
|
||||
if (await this.findCalendar(CALENDAR_NAME)) {
|
||||
await this.calendar.deleteCalendar(CALENDAR_NAME);
|
||||
if (await this.findCalendar(this.calendarName)) {
|
||||
await this.calendar.deleteCalendar(this.calendarName);
|
||||
}
|
||||
return await this.createCalendar();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user