bugfix 스티커 버그 수정.

This commit is contained in:
leejinho 2019-11-25 15:48:43 +09:00
parent 81f871bea3
commit f33df67724
6 changed files with 74 additions and 62 deletions

View File

@ -0,0 +1,5 @@
export enum MessageSearchType {
Title = 'T',
Name = 'N',
Contents = 'C'
}

View File

@ -43,12 +43,16 @@ import * as ChatStore from '@app/store/messenger/chat';
import * as RoomStore from '@app/store/messenger/room'; import * as RoomStore from '@app/store/messenger/room';
import * as SyncStore from '@app/store/messenger/sync'; import * as SyncStore from '@app/store/messenger/sync';
import { LoginResponse } from '@ucap-webmessenger/protocol-authentication'; import { LoginResponse } from '@ucap-webmessenger/protocol-authentication';
import { SessionStorageService } from '@ucap-webmessenger/web-storage'; import {
SessionStorageService,
LocalStorageService
} from '@ucap-webmessenger/web-storage';
import { import {
EnvironmentsInfo, EnvironmentsInfo,
KEY_ENVIRONMENTS_INFO, KEY_ENVIRONMENTS_INFO,
UserSelectDialogType, UserSelectDialogType,
RightDrawer RightDrawer,
KEY_STICKER_HISTORY
} from '@app/types'; } from '@app/types';
import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room'; import { RoomInfo, UserInfo, RoomType } from '@ucap-webmessenger/protocol-room';
import { tap, take, map, catchError } from 'rxjs/operators'; import { tap, take, map, catchError } from 'rxjs/operators';
@ -83,7 +87,9 @@ import {
CONST, CONST,
FileUtil, FileUtil,
StickerFilesInfo, StickerFilesInfo,
StickerUtil StickerUtil,
StickerInfo,
StickerMap
} from '@ucap-webmessenger/core'; } from '@ucap-webmessenger/core';
import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar'; import { PerfectScrollbarComponent } from 'ngx-perfect-scrollbar';
import { StatusCode } from '@ucap-webmessenger/api'; import { StatusCode } from '@ucap-webmessenger/api';
@ -162,6 +168,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
constructor( constructor(
private store: Store<any>, private store: Store<any>,
private sessionStorageService: SessionStorageService, private sessionStorageService: SessionStorageService,
private localStorageService: LocalStorageService,
private commonApiService: CommonApiService, private commonApiService: CommonApiService,
private clipboardService: ClipboardService, private clipboardService: ClipboardService,
private dialogService: DialogService, private dialogService: DialogService,
@ -198,7 +205,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
select(AppStore.MessengerSelector.RoomSelector.roomInfo), select(AppStore.MessengerSelector.RoomSelector.roomInfo),
tap(roomInfo => { tap(roomInfo => {
this.roomInfo = roomInfo; this.roomInfo = roomInfo;
this.clearView();
this.setEventMoreInit(); this.setEventMoreInit();
}) })
) )
@ -535,7 +542,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
}) })
); );
this.isShowStickerSelector = false; this.isShowStickerSelector = false;
StickerUtil.setStickerHistory(this.selectedSticker); this.setStickerHistory(this.selectedSticker);
} else if (message.trim().length > CONST.MASSTEXT_LEN) { } else if (message.trim().length > CONST.MASSTEXT_LEN) {
// MASS TEXT // MASS TEXT
this.store.dispatch( this.store.dispatch(
@ -1091,4 +1098,24 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit {
onSelectedSticker(stickerInfo: StickerFilesInfo) { onSelectedSticker(stickerInfo: StickerFilesInfo) {
this.selectedSticker = stickerInfo; this.selectedSticker = stickerInfo;
} }
setStickerHistory(sticker: StickerFilesInfo) {
const history = this.localStorageService.get<string[]>(KEY_STICKER_HISTORY);
if (!!history && history.length > 0) {
const stickers: string[] = [];
[sticker.index, ...history.filter(hist => hist !== sticker.index)].map(
(s, i) => {
if (i < 10) {
stickers.push(s);
}
}
);
this.localStorageService.set<string[]>(KEY_STICKER_HISTORY, stickers);
} else {
this.localStorageService.set<string[]>(KEY_STICKER_HISTORY, [
sticker.index
]);
}
}
} }

View File

@ -2,3 +2,4 @@ export * from './environment.type';
export * from './login-info.type'; export * from './login-info.type';
export * from './userselect.dialog.type'; export * from './userselect.dialog.type';
export * from './right-drawer.type'; export * from './right-drawer.type';
export * from './sticker-info.type';

View File

@ -1,5 +1,3 @@
import { LocalStorageService } from '@ucap-webmessenger/web-storage';
export interface StickerInfo { export interface StickerInfo {
index: string; index: string;
title: string; title: string;
@ -12,7 +10,7 @@ export interface StickerFilesInfo {
index: string; index: string;
path: string; path: string;
} }
const StickerMap: StickerInfo[] = [ export const StickerMap: StickerInfo[] = [
{ {
index: '00', index: '00',
title: 'History', title: 'History',
@ -152,11 +150,6 @@ export class StickerUtil {
); );
if (!!stickerInfos && stickerInfos.length > 0) { if (!!stickerInfos && stickerInfos.length > 0) {
if (idx === '00') {
// history.
stickerInfos[0].fileInfos = this.getStickerHistory();
}
rtnStickerList.push(stickerInfos[0]); rtnStickerList.push(stickerInfos[0]);
} }
}); });
@ -176,50 +169,4 @@ export class StickerUtil {
return stickerFilesList; return stickerFilesList;
} }
static setStickerHistory(sticker: StickerFilesInfo) {
const localStorageService = new LocalStorageService();
const history = localStorageService.get<string[]>('ucap::Sticker_History');
if (!!history && history.length > 0) {
const stickers: string[] = [];
[sticker.index, ...history.filter(hist => hist !== sticker.index)].map(
(s, i) => {
if (i < 10) {
stickers.push(s);
}
}
);
localStorageService.set<string[]>('ucap::Sticker_History', stickers);
} else {
localStorageService.set<string[]>('ucap::Sticker_History', [
sticker.index
]);
}
}
static getStickerHistory(): StickerFilesInfo[] {
const rtnArray: StickerFilesInfo[] = [];
const localStorageService = new LocalStorageService();
const history = localStorageService.get<string[]>('ucap::Sticker_History');
if (!!history && history.length > 0) {
history.forEach(sticker => {
const arr: string[] = sticker.split('_');
if (arr.length === 2) {
const sInfo: StickerInfo[] = StickerMap.filter(
stickerInfo => stickerInfo.index === arr[0]
);
if (!!sInfo && sInfo.length > 0) {
rtnArray.push(
...sInfo[0].fileInfos.filter(
fileInfo => fileInfo.index === sticker
)
);
}
}
});
}
return rtnArray;
}
} }

View File

@ -27,7 +27,7 @@
</ng-template> </ng-template>
<div fxFlex fxLayout="row" fxLayoutGap="10px"> <div fxFlex fxLayout="row" fxLayoutGap="10px">
<div <div
*ngFor="let sticker of stickerInfo.fileInfos" *ngFor="let sticker of getStickerInfos(stickerInfo)"
(click)="onClickSelectSticker(sticker)" (click)="onClickSelectSticker(sticker)"
class="sticker-item" class="sticker-item"
> >

View File

@ -2,8 +2,11 @@ import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import { import {
StickerInfo, StickerInfo,
StickerFilesInfo, StickerFilesInfo,
StickerUtil StickerUtil,
StickerMap
} from '@ucap-webmessenger/core'; } from '@ucap-webmessenger/core';
import { LocalStorageService } from '@ucap-webmessenger/web-storage';
import { KEY_STICKER_HISTORY } from '@app/types';
@Component({ @Component({
selector: 'ucap-sticker-selector', selector: 'ucap-sticker-selector',
@ -21,7 +24,7 @@ export class StickerSelectorComponent implements OnInit {
currentTabIndex: number; currentTabIndex: number;
constructor() {} constructor(private localStorageService: LocalStorageService) {}
ngOnInit() { ngOnInit() {
this.stickerInfoList = StickerUtil.getStickerInfoList(); this.stickerInfoList = StickerUtil.getStickerInfoList();
@ -48,6 +51,35 @@ export class StickerSelectorComponent implements OnInit {
} }
} }
getStickerInfos(stickerInfo: StickerInfo) {
if (stickerInfo.index === '00') {
const rtnArray: StickerFilesInfo[] = [];
const history = this.localStorageService.get<string[]>(
KEY_STICKER_HISTORY
);
if (!!history && history.length > 0) {
history.forEach(sticker => {
const arr: string[] = sticker.split('_');
if (arr.length === 2) {
const sInfo: StickerInfo[] = StickerMap.filter(
s => s.index === arr[0]
);
if (!!sInfo && sInfo.length > 0) {
rtnArray.push(
...sInfo[0].fileInfos.filter(
fileInfo => fileInfo.index === sticker
)
);
}
}
});
}
return rtnArray;
} else {
return stickerInfo.fileInfos;
}
}
getStickerContentsImage(sticker: StickerFilesInfo) { getStickerContentsImage(sticker: StickerFilesInfo) {
return this.stickerBasePath + sticker.path; return this.stickerBasePath + sticker.path;
} }