From fb3cc12f56a96c1772f3c31c380aa5038a158192 Mon Sep 17 00:00:00 2001 From: VeraLyu Date: Thu, 27 Apr 2017 22:58:38 +0800 Subject: PLT-6249: Erase custom emoji in "recently used" after deleted (#6242) --- webapp/stores/emoji_store.jsx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'webapp/stores') diff --git a/webapp/stores/emoji_store.jsx b/webapp/stores/emoji_store.jsx index ff9ec64f8..8a4165dd4 100644 --- a/webapp/stores/emoji_store.jsx +++ b/webapp/stores/emoji_store.jsx @@ -139,6 +139,17 @@ class EmojiStore extends EventEmitter { return this.map.get(name); } + removeRecentEmoji(id) { + const recentEmojis = this.getRecentEmojis(); + for (let i = recentEmojis.length - 1; i >= 0; i--) { + if (recentEmojis[i].id === id) { + recentEmojis.splice(i, 1); + break; + } + } + localStorage.setItem(Constants.RECENT_EMOJI_KEY, JSON.stringify(recentEmojis)); + } + addRecentEmoji(rawAlias) { const recentEmojis = this.getRecentEmojis(); @@ -214,6 +225,7 @@ class EmojiStore extends EventEmitter { break; case ActionTypes.REMOVED_CUSTOM_EMOJI: this.removeCustomEmoji(action.id); + this.removeRecentEmoji(action.id); this.emitChange(); break; case ActionTypes.EMOJI_POSTED: -- cgit v1.2.3-1-g7c22