From 0f9bc57ccbfba480ae28624b10c6c138d0c1f650 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Thu, 9 Jan 2020 06:35:33 -0800 Subject: [PATCH] Only show pack installed tooltip for non-blessed, local installs --- ts/state/ducks/stickers.ts | 13 ++++++++++--- ts/state/smart/CompositionArea.tsx | 6 ++++-- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/ts/state/ducks/stickers.ts b/ts/state/ducks/stickers.ts index ebc817648..2303d662b 100644 --- a/ts/state/ducks/stickers.ts +++ b/ts/state/ducks/stickers.ts @@ -103,6 +103,7 @@ type StickerAddedAction = { type InstallStickerPackPayloadType = { packId: string; + fromSync: boolean; status: 'installed'; installedAt: number; recentStickers: Array; @@ -121,6 +122,7 @@ type ClearInstalledStickerPackAction = { type UninstallStickerPackPayloadType = { packId: string; + fromSync: boolean; status: 'downloaded'; installedAt: null; recentStickers: Array; @@ -258,8 +260,9 @@ async function doInstallStickerPack( return { packId, - installedAt: timestamp, + fromSync, status, + installedAt: timestamp, recentStickers: recentStickers.map(item => ({ packId: item.packId, stickerId: item.id, @@ -298,6 +301,7 @@ async function doUninstallStickerPack( return { packId, + fromSync, status, installedAt: null, recentStickers: recentStickers.map(item => ({ @@ -426,7 +430,7 @@ export function reducer( action.type === 'stickers/UNINSTALL_STICKER_PACK_FULFILLED' ) { const { payload } = action; - const { installedAt, packId, status, recentStickers } = payload; + const { fromSync, installedAt, packId, status, recentStickers } = payload; const { packs } = state; const existingPack = packs[packId]; @@ -440,9 +444,12 @@ export function reducer( }; } + const isBlessed = state.blessedPacks[packId]; + const installedPack = !fromSync && !isBlessed ? packId : null; + return { ...state, - installedPack: packId, + installedPack, packs: { ...packs, [packId]: { diff --git a/ts/state/smart/CompositionArea.tsx b/ts/state/smart/CompositionArea.tsx index 212fb8fdc..287e386a3 100644 --- a/ts/state/smart/CompositionArea.tsx +++ b/ts/state/smart/CompositionArea.tsx @@ -13,6 +13,7 @@ import { getInstalledStickerPacks, getKnownStickerPacks, getReceivedStickerPacks, + getRecentlyInstalledStickerPack, getRecentStickers, } from '../selectors/stickers'; @@ -40,6 +41,8 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => { const blessedPacks = getBlessedStickerPacks(state); const knownPacks = getKnownStickerPacks(state); + const installedPack = getRecentlyInstalledStickerPack(state); + const recentStickers = getRecentStickers(state); const showIntroduction = get( state.items, @@ -61,8 +64,7 @@ const mapStateToProps = (state: StateType, props: ExternalProps) => { skinTone: get(state, ['items', 'skinTone'], 0), // Stickers receivedPacks, - // 'Installed Pack' tooltip disabled for now - installedPack: null, + installedPack, blessedPacks, knownPacks, installedPacks,