From 55d593904babca247e1010743eb3ea95c0674d72 Mon Sep 17 00:00:00 2001 From: leejh Date: Fri, 11 Oct 2019 11:39:19 +0900 Subject: [PATCH] save sessionstorage for verinfo2 response data --- .../src/app/resolvers/messenger.resolver.ts | 2 ++ .../src/app/types/ver-info.type.ts | 20 +++++++++++ .../components/user-list-item.component.ts | 35 ++++++++++++------- 3 files changed, 44 insertions(+), 13 deletions(-) create mode 100644 projects/ucap-webmessenger-app/src/app/types/ver-info.type.ts diff --git a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts index d20fadb4..da7c8781 100644 --- a/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts +++ b/projects/ucap-webmessenger-app/src/app/resolvers/messenger.resolver.ts @@ -44,6 +44,7 @@ import * as VersionInfoStore from '@app/store/setting/version-info'; import * as OptionStore from '@app/store/messenger/option'; import * as QueryStore from '@app/store/messenger/query'; import * as SyncStore from '@app/store/messenger/sync'; +import { VerInfo2, KEY_VER_INFO } from '@app/types/ver-info.type'; @Injectable() export class AppMessengerResolver implements Resolve { @@ -83,6 +84,7 @@ export class AppMessengerResolver implements Resolve { .pipe( take(1), tap(res => { + this.sessionStorageService.set(KEY_VER_INFO, res); this.store.dispatch(VersionInfoStore.versionInfo2Success({ res })); }), switchMap(res => { diff --git a/projects/ucap-webmessenger-app/src/app/types/ver-info.type.ts b/projects/ucap-webmessenger-app/src/app/types/ver-info.type.ts new file mode 100644 index 00000000..4268a1b8 --- /dev/null +++ b/projects/ucap-webmessenger-app/src/app/types/ver-info.type.ts @@ -0,0 +1,20 @@ +import { SyncMode } from '@ucap-webmessenger/api-public'; + +export const KEY_VER_INFO = 'ucap::VER_INFO'; + +export interface VerInfo2 { + protocolCode?: number; + syncMode?: SyncMode; + appVersion?: string; + installUrl?: string; + serverIp?: string; + uploadUrl?: string; + downloadUrl?: string; + profileUploadUrl?: string; + profileRoot?: string; + fileTerm?: number; + fileAllowSize?: number; + authIp?: boolean; + launcherAppVersion?: string; + launcherInstallUrl?: string; +} diff --git a/projects/ucap-webmessenger-ui-profile/src/lib/components/user-list-item.component.ts b/projects/ucap-webmessenger-ui-profile/src/lib/components/user-list-item.component.ts index 4b2ff2ea..541eecea 100644 --- a/projects/ucap-webmessenger-ui-profile/src/lib/components/user-list-item.component.ts +++ b/projects/ucap-webmessenger-ui-profile/src/lib/components/user-list-item.component.ts @@ -11,6 +11,8 @@ import * as AppStore from '@app/store'; import { Subscription } from 'rxjs'; import { NGXLogger } from 'ngx-logger'; import { tap } from 'rxjs/operators'; +import { SessionStorageService } from '@ucap-webmessenger/web-storage'; +import { KEY_VER_INFO, VerInfo2 } from '@app/types/ver-info.type'; @Component({ selector: 'ucap-profile-user-list-item', @@ -29,24 +31,31 @@ export class UserListItemComponent implements OnInit, OnDestroy { @Input() compactable = false; - private profileImageRootSubscription: Subscription; + // private profileImageRootSubscription: Subscription; - constructor(private store: Store, private logger: NGXLogger) {} + constructor( + private store: Store, + private logger: NGXLogger, + private sessionStorageService: SessionStorageService + ) {} ngOnInit() { - this.profileImageRootSubscription = this.store - .pipe( - select(AppStore.SettingSelector.VersionInfoSelector.profileImageRoot), - tap(profileImageRoot => { - this.profileImageRoot = this.profileImageRoot || profileImageRoot; - }) - ) - .subscribe(); + // this.profileImageRootSubscription = this.store + // .pipe( + // select(AppStore.SettingSelector.VersionInfoSelector.profileImageRoot), + // tap(profileImageRoot => { + // this.profileImageRoot = this.profileImageRoot || profileImageRoot; + // }) + // ) + // .subscribe(); + + const verInfo = this.sessionStorageService.get(KEY_VER_INFO); + this.profileImageRoot = this.profileImageRoot || verInfo.profileRoot; } ngOnDestroy(): void { - if (!!this.profileImageRootSubscription) { - this.profileImageRootSubscription.unsubscribe(); - } + // if (!!this.profileImageRootSubscription) { + // this.profileImageRootSubscription.unsubscribe(); + // } } }