clear configuration logic add. but not appearence

This commit is contained in:
leejinho 2020-02-18 16:05:07 +09:00
parent 1f83038abc
commit ae56f389c5
8 changed files with 56 additions and 2 deletions

View File

@ -420,6 +420,13 @@ ipcMain.on(
}
);
ipcMain.on(
MessengerChannel.ClearAppStorage,
(event: IpcMainEvent, ...args: any[]) => {
appStorage.reset();
}
);
ipcMain.on(
MessengerChannel.ChangeAutoLaunch,
(event: IpcMainEvent, ...args: any[]) => {

View File

@ -53,6 +53,15 @@ export class Storage {
get constDefaultDownloadFolder(): string {
return DOWNLOAD_FOLDER_PATH;
}
reset(): void {
this.store.set({
options: {
startupHideWindow: false,
downloadPath: path.join(app.getPath('documents'), DOWNLOAD_FOLDER_PATH)
}
});
}
}
export const appStorage: Storage = new Storage();

View File

@ -124,6 +124,13 @@
</div>
</mat-card-content>
<mat-card-actions class="button-farm flex-row">
<!-- <button
mat-stroked-button
(click)="onClickClearSettingAndLogout()"
class="mat-primary"
>
Clear Setting & Logout
</button> -->
<button
mat-stroked-button
(click)="onClickChoice(false)"

View File

@ -1,18 +1,27 @@
import { Component, OnInit, Inject, Renderer2, OnDestroy } from '@angular/core';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { KEY_LOGIN_RES_INFO, KEY_VER_INFO } from '@app/types';
import {
KEY_LOGIN_RES_INFO,
KEY_VER_INFO,
KEY_LOGIN_INFO,
KEY_URL_INFO,
KEY_AUTH_INFO,
KEY_LOGOUT_INFO
} from '@app/types';
import {
SessionStorageService,
LocalStorageService
} from '@ucap-webmessenger/web-storage';
import { Store } from '@ngrx/store';
import * as AuthenticationStore from '@app/store/account/authentication';
import clone from 'clone';
import {
TranslateService as UCapTranslateService,
DateService as UCapDateService
DateService as UCapDateService,
DialogService
} from '@ucap-webmessenger/ui';
import { VersionInfo2Response } from '@ucap-webmessenger/api-public';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
@ -69,6 +78,7 @@ export class MessengerSettingsDialogComponent implements OnInit, OnDestroy {
@Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService,
private translateService: TranslateService,
private store: Store<any>,
private dialogService: DialogService,
@Inject(DOCUMENT) private document: Document,
private renderer2: Renderer2
) {
@ -200,4 +210,17 @@ export class MessengerSettingsDialogComponent implements OnInit, OnDestroy {
return modSettings;
}
onClickClearSettingAndLogout() {
this.localStorageService.remove(KEY_APP_USER_INFO);
this.sessionStorageService.remove(KEY_LOGIN_RES_INFO);
this.sessionStorageService.remove(KEY_VER_INFO);
this.sessionStorageService.remove(KEY_LOGIN_INFO);
this.sessionStorageService.remove(KEY_URL_INFO);
this.sessionStorageService.remove(KEY_AUTH_INFO);
this.sessionStorageService.remove(KEY_LOGOUT_INFO);
this.nativeService.clearAppStorage();
this.dialogService.closeAll();
this.store.dispatch(AuthenticationStore.loginRedirect());
}
}

View File

@ -84,6 +84,8 @@ export class BrowserNativeService extends NativeService {
});
}
clearAppStorage(): void {}
changeAutoLaunch(autoLaunch: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
resolve(true);

View File

@ -132,6 +132,10 @@ export class ElectronNativeService implements NativeService {
return this.showSetting$;
}
clearAppStorage(): void {
this.ipcRenderer.send(MessengerChannel.ClearAppStorage);
}
changeAutoLaunch(autoLaunch: boolean): Promise<boolean> {
return new Promise<boolean>((resolve, reject) => {
try {

View File

@ -2,6 +2,7 @@ export enum MessengerChannel {
Logout = 'UCAP::messenger::logout',
ChangeStatus = 'UCAP::messenger::changeStatus',
ShowSetting = 'UCAP::messenger::showSetting',
ClearAppStorage = 'UCAP::messenger::clearAppStorage',
ChangeAutoLaunch = 'UCAP::messenger::changeAutoLaunch',
ChangeStartupHideWindow = 'UCAP::messenger::changeStartupHideWindow',
ChangeDownloadPath = 'UCAP::messenger::changeDownloadPath',

View File

@ -27,6 +27,7 @@ export abstract class NativeService {
abstract getNetworkInfo(): Promise<any>;
abstract getVersionInfo(): Promise<string>;
abstract clearAppStorage(): void;
abstract changeAutoLaunch(autoLaunch: boolean): Promise<boolean>;
abstract changeStartupHideWindow(
startupHideWindow: boolean