mirror of
https://gitlab.com/openstapps/openstapps.git
synced 2026-01-20 08:33:11 +00:00
feat: separate prettier from eslint
This commit is contained in:
committed by
Thea Schöbl
parent
939fb6ef0f
commit
a88d000ccd
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -19,10 +19,7 @@
|
||||
export function hashStringToInt(string_: string): number {
|
||||
return [...string_].reduce(
|
||||
(accumulator, current) =>
|
||||
(current.codePointAt(0) ?? 0) +
|
||||
(accumulator << 6) +
|
||||
(accumulator << 16) -
|
||||
accumulator,
|
||||
(current.codePointAt(0) ?? 0) + (accumulator << 6) + (accumulator << 16) - accumulator,
|
||||
0,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
/*
|
||||
* Copyright (C) 2022 StApps
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
* This program is free software: you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the Free
|
||||
* Software Foundation, version 3.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {Injectable, OnDestroy} from '@angular/core';
|
||||
@@ -51,12 +51,10 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
) {}
|
||||
|
||||
init() {
|
||||
this.scheduleProvider.uuids$
|
||||
.pipe(filter(uuids => uuids?.length > 0))
|
||||
.subscribe(uuids => {
|
||||
this.uuids = uuids;
|
||||
void this.syncNativeCalendar();
|
||||
});
|
||||
this.scheduleProvider.uuids$.pipe(filter(uuids => uuids?.length > 0)).subscribe(uuids => {
|
||||
this.uuids = uuids;
|
||||
void this.syncNativeCalendar();
|
||||
});
|
||||
}
|
||||
|
||||
uuids: SCUuid[];
|
||||
@@ -72,10 +70,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
}
|
||||
|
||||
private async isNotificationsEnabled(): Promise<boolean> {
|
||||
return getCalendarSetting(
|
||||
this.storageProvider,
|
||||
CALENDAR_NOTIFICATIONS_ENABLED_KEY,
|
||||
);
|
||||
return getCalendarSetting(this.storageProvider, CALENDAR_NOTIFICATIONS_ENABLED_KEY);
|
||||
}
|
||||
|
||||
async enable() {
|
||||
@@ -84,10 +79,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
await BackgroundFetch.stop();
|
||||
|
||||
if (
|
||||
[
|
||||
this.isSyncEnabled.bind(this),
|
||||
this.isNotificationsEnabled.bind(this),
|
||||
].some(async it => await it())
|
||||
[this.isSyncEnabled.bind(this), this.isNotificationsEnabled.bind(this)].some(async it => await it())
|
||||
) {
|
||||
const status = await BackgroundFetch.configure(
|
||||
{
|
||||
@@ -95,10 +87,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
requiredNetworkType: 1,
|
||||
},
|
||||
async taskId => {
|
||||
await Promise.all([
|
||||
this.postDifferencesNotification(),
|
||||
this.syncNativeCalendar(),
|
||||
]);
|
||||
await Promise.all([this.postDifferencesNotification(), this.syncNativeCalendar()]);
|
||||
|
||||
await BackgroundFetch.finish(taskId);
|
||||
},
|
||||
@@ -110,9 +99,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
'The user explicitly disabled background behavior for this app or for the whole system.',
|
||||
);
|
||||
} else if (status === BackgroundFetch.STATUS_RESTRICTED) {
|
||||
console.error(
|
||||
'Background updates are unavailable and the user cannot enable them again.',
|
||||
);
|
||||
console.error('Background updates are unavailable and the user cannot enable them again.');
|
||||
}
|
||||
} else {
|
||||
console.info('Starting background fetch.');
|
||||
@@ -122,14 +109,10 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
async getDifferences(): Promise<
|
||||
ChangesOf<SCDateSeries, DateSeriesRelevantData>[]
|
||||
> {
|
||||
async getDifferences(): Promise<ChangesOf<SCDateSeries, DateSeriesRelevantData>[]> {
|
||||
const partialEvents = this.scheduleProvider.partialEvents$.getValue();
|
||||
|
||||
const result = (
|
||||
await this.scheduleProvider.getDateSeries(partialEvents.map(it => it.uid))
|
||||
).dates;
|
||||
const result = (await this.scheduleProvider.getDateSeries(partialEvents.map(it => it.uid))).dates;
|
||||
|
||||
return result
|
||||
.map(it => ({
|
||||
@@ -148,15 +131,11 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
}));
|
||||
}
|
||||
|
||||
private formatChanges(
|
||||
changes: ChangesOf<SCDateSeries, DateSeriesRelevantData>,
|
||||
): string[] {
|
||||
private formatChanges(changes: ChangesOf<SCDateSeries, DateSeriesRelevantData>): string[] {
|
||||
return changes.changes.map(
|
||||
change =>
|
||||
`${
|
||||
this.translator.translator.translatedPropertyNames<SCDateSeries>(
|
||||
SCThingType.DateSeries,
|
||||
)?.[change]
|
||||
this.translator.translator.translatedPropertyNames<SCDateSeries>(SCThingType.DateSeries)?.[change]
|
||||
}: ${formatRelevantKeys[change](
|
||||
changes.new[change] as never,
|
||||
this.dateFormatPipe,
|
||||
@@ -168,8 +147,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
async syncNativeCalendar() {
|
||||
if (!(await this.isSyncEnabled())) return;
|
||||
|
||||
const dateSeries = (await this.scheduleProvider.getDateSeries(this.uuids))
|
||||
.dates;
|
||||
const dateSeries = (await this.scheduleProvider.getDateSeries(this.uuids)).dates;
|
||||
|
||||
const events = dateSeries.flatMap(event =>
|
||||
toICal(event, this.translator.translator, {
|
||||
@@ -184,9 +162,7 @@ export class ScheduleSyncService implements OnDestroy {
|
||||
async postDifferencesNotification() {
|
||||
if (!(await this.isNotificationsEnabled())) return;
|
||||
|
||||
const differences = (await this.getDifferences()).filter(
|
||||
it => it.changes.length > 0,
|
||||
);
|
||||
const differences = (await this.getDifferences()).filter(it => it.changes.length > 0);
|
||||
if (differences.length === 0) return;
|
||||
|
||||
if (Capacitor.isNativePlatform()) {
|
||||
|
||||
Reference in New Issue
Block a user