Skip to content

Commit

Permalink
feat(sharedTaskList): make tags a global model
Browse files Browse the repository at this point in the history
  • Loading branch information
johannesjo committed Mar 11, 2020
1 parent eeb67d9 commit 7e30867
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 14 deletions.
3 changes: 3 additions & 0 deletions src/app/app.component.ts
Expand Up @@ -29,6 +29,7 @@ import {LanguageService} from './core/language/language.service';
import {ElectronService} from './core/electron/electron.service';
import {AttachmentService} from './features/attachment/attachment.service';
import {WorkContextService} from './features/work-context/work-context.service';
import {TagService} from './features/tag/tag.service';


@Component({
Expand Down Expand Up @@ -76,6 +77,7 @@ export class AppComponent implements OnDestroy {
private _languageService: LanguageService,
private _attachmentService: AttachmentService,
private _workContextService: WorkContextService,
private _tagService: TagService,
public readonly layoutService: LayoutService,
public readonly bookmarkService: BookmarkService,
public readonly taskService: TaskService,
Expand Down Expand Up @@ -106,6 +108,7 @@ export class AppComponent implements OnDestroy {
this._projectService.load();
this._configService.load();
this._workContextService.load();
this._tagService.load();

// init theme and body class handlers
this._globalThemeService.init();
Expand Down
6 changes: 3 additions & 3 deletions src/app/core/persistence/persistence.service.ts
Expand Up @@ -84,10 +84,10 @@ export class PersistenceService {
);

// TASK_RELATED_MODELS
taskTag = this._cmProject<TagState, Tag>(
taskTag = this._cmBase<TagState>(
LS_TASK_TAG_STATE,
'taskTag',
tagReducer);
'tag'
);
taskAttachment = this._cmBase<AttachmentState>(
LS_TASK_ATTACHMENT_STATE,
'taskAttachment',
Expand Down
3 changes: 0 additions & 3 deletions src/app/features/project/store/project.effects.ts
Expand Up @@ -33,7 +33,6 @@ import {Router} from '@angular/router';
import {BannerId} from '../../../core/banner/banner.model';
import {GlobalConfigService} from '../../config/global-config.service';
import {TaskRepeatCfgService} from '../../task-repeat-cfg/task-repeat-cfg.service';
import {TagService} from '../../tag/tag.service';
import {T} from '../../../t.const';
import {isShowFinishDayNotification} from '../util/is-show-finish-day-notification';

Expand Down Expand Up @@ -179,7 +178,6 @@ export class ProjectEffects {
// TODO automatize
this._noteService.loadStateForProject(projectId),
this._bookmarkService.loadStateForProject(projectId),
this._tagService.loadStateForProject(projectId),
this._taskService.loadStateForProject(projectId),
this._metricService.loadStateForProject(projectId),
this._improvementService.loadStateForProject(projectId),
Expand Down Expand Up @@ -307,7 +305,6 @@ export class ProjectEffects {
private _bannerService: BannerService,
private _globalConfigService: GlobalConfigService,
private _attachmentService: AttachmentService,
private _tagService: TagService,
private _reminderService: ReminderService,
private _metricService: MetricService,
private _obstructionService: ObstructionService,
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/tag/store/tag.effects.ts
Expand Up @@ -34,7 +34,7 @@ export class TagEffects {
private _saveToLs([action, currentProjectId, tagState]) {
if (currentProjectId) {
this._persistenceService.saveLastActive();
this._persistenceService.taskTag.save(currentProjectId, tagState);
this._persistenceService.taskTag.saveState(tagState);
} else {
throw new Error('No current project id');
}
Expand Down
1 change: 0 additions & 1 deletion src/app/features/tag/tag-list/tag-list.component.ts
Expand Up @@ -34,7 +34,6 @@ export class TagListComponent implements OnInit, AfterViewInit {

@ViewChild('tagListEl', {static: true}) tagListEl;

counter = 0;
editingTag: undefined | Partial<Tag> = undefined;
private _tagIds;
private _tagIds$ = new BehaviorSubject([]);
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/tag/tag.service.ts
Expand Up @@ -40,8 +40,8 @@ export class TagService {
return this._store$.pipe(select(selectTagByName, {name}));
}

public async loadStateForProject(projectId) {
const lsTagState = await this._persistenceService.taskTag.load(projectId) || initialTagState;
async load() {
const lsTagState = await this._persistenceService.taskTag.loadState() || initialTagState;
this.loadState(lsTagState || initialTagState);
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/features/tasks/migrate-task-state.util.ts
Expand Up @@ -5,7 +5,7 @@ import {MODEL_VERSION_KEY, WORKLOG_DATE_STR_FORMAT} from '../../app.constants';
import * as moment from 'moment';
import {convertToWesternArabic} from '../../util/numeric-converter';

const MODEL_VERSION = 3.1;
const MODEL_VERSION = 3.13;
export const LEGACY_GITHUB_TYPE = 'GIT';

export const migrateTaskState = (taskState: TaskState): TaskState => {
Expand Down
4 changes: 1 addition & 3 deletions src/app/imex/sync/sync.model.ts
Expand Up @@ -20,6 +20,7 @@ export interface AppBaseData {
globalConfig: GlobalConfigState;
reminders?: Reminder[];
task: TaskState;
tag: TagState;
taskArchive: TaskArchive;
taskAttachment: AttachmentState;
context: WorkContextState;
Expand All @@ -30,9 +31,6 @@ export interface AppDataForProjects {
note?: {
[key: string]: NoteState;
};
taskTag?: {
[key: string]: TagState
};
bookmark?: {
[key: string]: BookmarkState;
};
Expand Down

0 comments on commit 7e30867

Please sign in to comment.