Skip to content

Commit

Permalink
feat: new linting #3
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Jul 5, 2020
1 parent 2ac4cd2 commit 11c854b
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/app/core/persistence/persistence.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,68 +66,69 @@ import { devError } from '../../util/dev-error';
export class PersistenceService {

// handled as private but needs to be assigned before the creations
_baseModels = [];
_projectModels = [];
_baseModels: PersistenceBaseModel<any>[] = [];
_projectModels: PersistenceForProjectModel<any, any>[] = [];

// TODO auto generate ls keys from appDataKey where possible
globalConfig = this._cmBase<GlobalConfigState>(LS_GLOBAL_CFG, 'globalConfig', migrateGlobalConfigState);
reminders = this._cmBase<Reminder[]>(LS_REMINDER, 'reminders');
globalConfig: PersistenceBaseModel<GlobalConfigState> = this._cmBase<GlobalConfigState>(LS_GLOBAL_CFG, 'globalConfig', migrateGlobalConfigState);
reminders: PersistenceBaseModel<Reminder[]> = this._cmBase<Reminder[]>(LS_REMINDER, 'reminders');

project = this._cmBaseEntity<ProjectState, Project>(
project: PersistenceBaseEntityModel<ProjectState, Project> = this._cmBaseEntity<ProjectState, Project>(
LS_PROJECT_META_LIST,
'project',
projectReducer,
migrateProjectState,
);
tag = this._cmBaseEntity<TagState, Tag>(

tag: PersistenceBaseEntityModel<TagState, Tag> = this._cmBaseEntity<TagState, Tag>(
LS_TAG_STATE,
'tag',
tagReducer,
);
simpleCounter = this._cmBaseEntity<SimpleCounterState, SimpleCounter>(
simpleCounter: PersistenceBaseEntityModel<SimpleCounterState, SimpleCounter> = this._cmBaseEntity<SimpleCounterState, SimpleCounter>(
LS_SIMPLE_COUNTER_STATE,
'simpleCounter',
simpleCounterReducer,
);

// MAIN TASK MODELS
task = this._cmBaseEntity<TaskState, Task>(
task: PersistenceBaseEntityModel<TaskState, Task> = this._cmBaseEntity<TaskState, Task>(
LS_TASK_STATE,
'task',
taskReducer,
migrateTaskState,
);
taskArchive = this._cmBaseEntity<TaskArchive, ArchiveTask>(
taskArchive: PersistenceBaseEntityModel<TaskArchive, ArchiveTask> = this._cmBaseEntity<TaskArchive, ArchiveTask>(
LS_TASK_ARCHIVE,
'taskArchive',
taskReducer,
migrateTaskArchiveState,
);
taskRepeatCfg = this._cmBaseEntity<TaskRepeatCfgState, TaskRepeatCfg>(
taskRepeatCfg: PersistenceBaseEntityModel<TaskRepeatCfgState, TaskRepeatCfg> = this._cmBaseEntity<TaskRepeatCfgState, TaskRepeatCfg>(
LS_TASK_REPEAT_CFG_STATE,
'taskRepeatCfg',
taskRepeatCfgReducer,
migrateTaskRepeatCfgState,
);

// PROJECT MODELS
bookmark = this._cmProject<BookmarkState, Bookmark>(
bookmark: PersistenceForProjectModel<BookmarkState, Bookmark> = this._cmProject<BookmarkState, Bookmark>(
LS_BOOKMARK_STATE,
'bookmark',
);
note = this._cmProject<NoteState, Note>(
note: PersistenceForProjectModel<NoteState, Note> = this._cmProject<NoteState, Note>(
LS_NOTE_STATE,
'note',
);
metric = this._cmProject<MetricState, Metric>(
metric: PersistenceForProjectModel<MetricState, Metric> = this._cmProject<MetricState, Metric>(
LS_METRIC_STATE,
'metric',
);
improvement = this._cmProject<ImprovementState, Improvement>(
improvement: PersistenceForProjectModel<ImprovementState, Improvement> = this._cmProject<ImprovementState, Improvement>(
LS_IMPROVEMENT_STATE,
'improvement',
);
obstruction = this._cmProject<ObstructionState, Obstruction>(
obstruction: PersistenceForProjectModel<ObstructionState, Obstruction> = this._cmProject<ObstructionState, Obstruction>(
LS_OBSTRUCTION_STATE,
'obstruction',
);
Expand All @@ -148,7 +149,7 @@ export class PersistenceService {
);

private _inMemoryComplete: AppDataComplete;
private _isBlockSaving = false;
private _isBlockSaving: boolean = false;

constructor(
private _snackService: SnackService,
Expand All @@ -167,11 +168,11 @@ export class PersistenceService {
});
}

async saveProjectArchive(data: ProjectArchive, isDataImport = false): Promise<any> {
async saveProjectArchive(data: ProjectArchive, isDataImport: boolean = false): Promise<any> {
return await this._saveToDb({dbKey: 'archivedProjects', data, isDataImport});
}

async loadArchivedProject(projectId): Promise<ProjectArchivedRelatedData> {
async loadArchivedProject(projectId: string): Promise<ProjectArchivedRelatedData> {
const archive = await this._loadFromDb({dbKey: 'project', legacyDBKey: LS_PROJECT_ARCHIVE, projectId});
const projectDataCompressed = archive[projectId];
const decompressed = await this._compressionService.decompress(projectDataCompressed);
Expand All @@ -180,7 +181,7 @@ export class PersistenceService {
return parsed;
}

async removeArchivedProject(projectId): Promise<any> {
async removeArchivedProject(projectId: string): Promise<any> {
const archive = await this._loadFromDb({
dbKey: 'archivedProjects',
legacyDBKey: LS_PROJECT_ARCHIVE
Expand All @@ -189,7 +190,7 @@ export class PersistenceService {
await this.saveProjectArchive(archive);
}

async saveArchivedProject(projectId, archivedProject: ProjectArchivedRelatedData) {
async saveArchivedProject(projectId: string, archivedProject: ProjectArchivedRelatedData) {
const current = await this.loadProjectArchive() || {};
const jsonStr = JSON.stringify(archivedProject);
const compressedData = await this._compressionService.compress(jsonStr);
Expand Down Expand Up @@ -361,7 +362,7 @@ export class PersistenceService {
lsKey: string,
appDataKey: keyof AppBaseData,
migrateFn: (state: T) => T = (v) => v,
isSkipPush = false,
isSkipPush: boolean = false,
): PersistenceBaseModel<T> {
const model = {
appDataKey,
Expand Down Expand Up @@ -483,7 +484,7 @@ export class PersistenceService {
return await Promise.all(promises);
}

private _makeProjectKey(projectId, subKey, additional?) {
private _makeProjectKey(projectId: string, subKey: string, additional?: string) {
return LS_PROJECT_PREFIX + projectId + '_' + subKey + (additional ? '_' + additional : '');
}

Expand Down

0 comments on commit 11c854b

Please sign in to comment.