Skip to content

Commit

Permalink
feat: save ViewMode
Browse files Browse the repository at this point in the history
  • Loading branch information
domiSchenk committed Oct 5, 2021
1 parent c790cf2 commit 21504f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/app/core/services/store/store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LoggerService } from '../logger/logger.service';
import { Injectable } from '@angular/core';
import { createDir, readDir, readTextFile, writeFile } from '@tauri-apps/api/fs';
import { localDataDir } from '@tauri-apps/api/path';
import { DiffFormate, GroupByOptions, RepositoriesSettings, Settings } from './store.types';
import { DiffFormate, GroupByOptions, RepositoriesSettings, Settings, ViewMode } from './store.types';
import { sortByProperty, Store } from '@shared/functions';

@Injectable({
Expand All @@ -18,6 +18,7 @@ export class StoreService {
@Store('') DefaultPath: string
@Store('line-by-line') DiffOutputFormat: DiffFormate;
@Store([]) Tags: Array<string>;
@Store('tree') ViewMode: ViewMode;


private fileName = 'store.json'
Expand Down
2 changes: 2 additions & 0 deletions src/app/core/services/store/store.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,5 @@ export type Settings = Partial<settings>;


export type GroupByOptions = 'none' | 'tags' | 'folder';

export type ViewMode = 'tree' | 'list';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChangeDetectorRef, Component, HostListener, OnInit, ViewChild } from '@angular/core';
import { NgForm } from '@angular/forms';
import { StoreService } from '@core/services';
import { StoreService, ViewMode } from '@core/services';
import { LoggerService } from '@core/services/logger/logger.service';
import { ChangedFile, GroupedChangedFiles, IStatusResult, TreeObject } from '@git/model';
import { GroupedChangedFile } from '@git/model/file';
Expand All @@ -10,7 +10,6 @@ import { interval } from 'rxjs';
import { filter, first } from 'rxjs/operators';
import { RepositoryService } from '../repository.service';

type ViewMode = 'tree' | 'list';

@UntilDestroy()
@Component({
Expand All @@ -24,7 +23,7 @@ export class RepositoryCommitComponent implements OnInit {

fileTree: GroupedChangedFiles = [];
formDisabled = false;
viewMode: ViewMode = 'tree';
viewMode: ViewMode = this.storeService.ViewMode;


get commitMessage(): string {
Expand Down Expand Up @@ -299,11 +298,13 @@ export class RepositoryCommitComponent implements OnInit {

changeToListView() {
this.viewMode = 'list';
this.storeService.ViewMode = 'list';
this.load();
}

changeToTreeView() {
this.viewMode = 'tree';
this.storeService.ViewMode = 'tree';
this.load();
}

Expand Down

0 comments on commit 21504f3

Please sign in to comment.