MOBILE-3975 calendar: Move default reminder initial value to config
parent
85eaeb44fe
commit
a776e37852
|
@ -101,5 +101,6 @@
|
|||
"ios": "id633359593"
|
||||
},
|
||||
"wsrequestqueuelimit": 10,
|
||||
"wsrequestqueuedelay": 100
|
||||
"wsrequestqueuedelay": 100,
|
||||
"calendarreminderdefaultvalue": 3600
|
||||
}
|
||||
|
|
|
@ -108,7 +108,6 @@ export class AddonCalendarProvider {
|
|||
static readonly COMPONENT = 'AddonCalendarEvents';
|
||||
static readonly DEFAULT_NOTIFICATION_TIME_CHANGED = 'AddonCalendarDefaultNotificationTimeChangedEvent';
|
||||
static readonly DEFAULT_NOTIFICATION_TIME_SETTING = 'mmaCalendarDefaultNotifTime';
|
||||
static readonly DEFAULT_NOTIFICATION_TIME = 3600;
|
||||
static readonly STARTING_WEEK_DAY = 'addon_calendar_starting_week_day';
|
||||
static readonly NEW_EVENT_EVENT = 'addon_calendar_new_event';
|
||||
static readonly NEW_EVENT_DISCARDED_EVENT = 'addon_calendar_new_event_discarded';
|
||||
|
@ -638,7 +637,7 @@ export class AddonCalendarProvider {
|
|||
|
||||
const key = AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME_SETTING + '#' + siteId;
|
||||
|
||||
return CoreConfig.get(key, AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME);
|
||||
return CoreConfig.get(key, CoreConstants.CONFIG.calendarreminderdefaultvalue || 3600);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,9 +13,10 @@
|
|||
// limitations under the License.
|
||||
|
||||
import { SQLiteDB } from '@classes/sqlitedb';
|
||||
import { CoreConfig } from '@services/config';
|
||||
import { CoreSiteSchema } from '@services/sites';
|
||||
import { CoreUtils } from '@services/utils/utils';
|
||||
import { AddonCalendar, AddonCalendarEventType } from '../calendar';
|
||||
import { AddonCalendar, AddonCalendarEventType, AddonCalendarProvider } from '../calendar';
|
||||
|
||||
/**
|
||||
* Database variables for AddonDatabase service.
|
||||
|
@ -216,13 +217,17 @@ export const CALENDAR_SITE_SCHEMA: CoreSiteSchema = {
|
|||
}
|
||||
|
||||
if (oldVersion < 4) {
|
||||
// Migrate reminders. New format @since 4.0.
|
||||
const defaultTime = await CoreUtils.ignoreErrors(AddonCalendar.getDefaultNotificationTime(siteId));
|
||||
// Migrate default notification time if it was changed.
|
||||
// Don't use getDefaultNotificationTime to be able to detect if the value was changed or not.
|
||||
const key = AddonCalendarProvider.DEFAULT_NOTIFICATION_TIME_SETTING + '#' + siteId;
|
||||
const defaultTime = await CoreUtils.ignoreErrors(CoreConfig.get(key, null));
|
||||
|
||||
if (defaultTime) {
|
||||
// Convert from minutes to seconds.
|
||||
AddonCalendar.setDefaultNotificationTime(defaultTime * 60, siteId);
|
||||
}
|
||||
|
||||
// Migrate reminders. New format @since 4.0.
|
||||
const records = await db.getAllRecords<AddonCalendarReminderDBRecord>(REMINDERS_TABLE);
|
||||
const events: Record<number, AddonCalendarEventDBRecord> = {};
|
||||
|
||||
|
|
|
@ -60,4 +60,5 @@ export interface EnvironmentConfig {
|
|||
iabToolbarColors?: 'auto' | { background: string; text?: string } | null;
|
||||
wsrequestqueuelimit: number; // Maximum number of requests allowed in the queue.
|
||||
wsrequestqueuedelay: number; // Maximum number of miliseconds to wait before processing the queue.
|
||||
calendarreminderdefaultvalue: number; // Initial value for default reminders (in seconds). User can change it later.
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue