Skip to content

Commit

Permalink
feat: save commit message for later use
Browse files Browse the repository at this point in the history
fixes #32
  • Loading branch information
domiSchenk committed Sep 16, 2021
1 parent 361af9b commit 591033f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/core/services/store/store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class StoreService {
this.logger.warn(`Tring to create the settings folder ${e}`);
this.createDir(path);
}
catch (e2) {
catch (e2: any) {
this.logger.error(e2);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { RepositoryService } from '../repository.service';
import { filter, first } from 'rxjs/operators';
import { interval } from 'rxjs';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { basename, sleep, LoadingState } from '@shared/functions';
import { basename, sleep, LoadingState, LocalStorage } from '@shared/functions';

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

fileTree: GroupedChangedFiles = [];
formDisabled = false;
commitMessage = '';

@LocalStorage('commitMessage') commitMessage: string;
private hasStaged = false;
isDiffLoading = false;
isLoading: LoadingState = 'default';
Expand Down
1 change: 1 addition & 0 deletions src/app/shared/functions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from './diff';
export * from './sleep';
export * from './group';
export * from './sort';
export * from './localstorage.decorator';
21 changes: 21 additions & 0 deletions src/app/shared/functions/localstorage.decorator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export function LocalStorage(key: string) {
return function (target: any, propertyKey: string) {
if (!propertyKey) {
throw new Error('Property key is required');
}
const key = propertyKey.toLocaleLowerCase();

const getter = function () {
return localStorage.getItem(key);
};

const setter = function (newVal: string) {
localStorage.setItem(key, newVal);
};

Object.defineProperty(target, propertyKey, {
get: getter,
set: setter
});
}
}

0 comments on commit 591033f

Please sign in to comment.