From 1b16743917796e86fd4cc231f5bc309a603221fe Mon Sep 17 00:00:00 2001 From: Josh Perez <60019601+josh-signal@users.noreply.github.com> Date: Thu, 17 Nov 2022 12:35:27 -0500 Subject: [PATCH] Onboarding story improvements --- images/profile-avatar.svg | 10 ++++++++++ ts/ConversationController.ts | 7 +++++++ ts/state/selectors/stories.ts | 22 ++++++++++++++-------- ts/types/SignalConversation.ts | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) create mode 100644 images/profile-avatar.svg diff --git a/images/profile-avatar.svg b/images/profile-avatar.svg new file mode 100644 index 000000000000..68da034b5f19 --- /dev/null +++ b/images/profile-avatar.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/ts/ConversationController.ts b/ts/ConversationController.ts index eb4934989428..121683495a31 100644 --- a/ts/ConversationController.ts +++ b/ts/ConversationController.ts @@ -417,6 +417,13 @@ export class ConversationController { profileSharing: true, }); + if (conversation.get('profileAvatar')?.path !== SIGNAL_AVATAR_PATH) { + conversation.set({ + profileAvatar: { hash: SIGNAL_AVATAR_PATH, path: SIGNAL_AVATAR_PATH }, + }); + updateConversation(conversation.attributes); + } + this._signalConversationId = conversation.id; return conversation; diff --git a/ts/state/selectors/stories.ts b/ts/state/selectors/stories.ts index 7e49a5823c43..8de5424e14a4 100644 --- a/ts/state/selectors/stories.ts +++ b/ts/state/selectors/stories.ts @@ -359,11 +359,13 @@ export const getStories = createSelector( return; } + const isSignalStory = story.sourceUuid === SIGNAL_ACI; + // if for some reason this story is already expired (bug) // log it and skip it. Unless it's the onboarding story, that story // doesn't have an expiration until it is viewed. if ( - !story.sourceUuid === SIGNAL_ACI && + !isSignalStory && (calculateExpirationTimestamp(story) ?? 0) < Date.now() ) { const messageIdForLogging = getMessageIdForLogging({ @@ -447,20 +449,24 @@ export const getStories = createSelector( storiesMap = storiesById; } - const existingConversationStory = storiesMap.get( - conversationStory.conversationId - ); + const existingConversationStory = + storiesMap.get(conversationStory.conversationId) || conversationStory; - storiesMap.set(conversationStory.conversationId, { + const conversationStoryObject = { ...existingConversationStory, - ...conversationStory, hasReplies: existingConversationStory?.hasReplies || conversationStory.hasReplies, hasRepliesFromSelf: existingConversationStory?.hasRepliesFromSelf || conversationStory.hasRepliesFromSelf, - storyView: conversationStory.storyView, - }); + }; + + // For the signal story we want the thumbnail to be from the first story + if (!isSignalStory) { + conversationStoryObject.storyView = conversationStory.storyView; + } + + storiesMap.set(conversationStory.conversationId, conversationStoryObject); }); return { diff --git a/ts/types/SignalConversation.ts b/ts/types/SignalConversation.ts index 0d62aa0d71bc..5d87ba5ce7b1 100644 --- a/ts/types/SignalConversation.ts +++ b/ts/types/SignalConversation.ts @@ -4,4 +4,4 @@ import { UUID } from './UUID'; export const SIGNAL_ACI = UUID.cast('11111111-1111-4111-8111-111111111111'); -export const SIGNAL_AVATAR_PATH = 'images/icon_256.png'; +export const SIGNAL_AVATAR_PATH = 'images/profile-avatar.svg';