Story replies indicator
This commit is contained in:
parent
b4b477e44c
commit
896b36c301
3 changed files with 27 additions and 18 deletions
|
@ -106,9 +106,9 @@ export function StoryListItem({
|
|||
}
|
||||
|
||||
let repliesElement: JSX.Element | undefined;
|
||||
if (hasRepliesFromSelf) {
|
||||
if (group === undefined && hasRepliesFromSelf) {
|
||||
repliesElement = <div className="StoryListItem__info--replies--self" />;
|
||||
} else if (hasReplies) {
|
||||
} else if (group && (hasReplies || hasRepliesFromSelf)) {
|
||||
repliesElement = <div className="StoryListItem__info--replies--others" />;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import { isNotNil } from '../util/isNotNil';
|
|||
import { strictAssert } from '../util/assert';
|
||||
import { dropNull } from '../util/dropNull';
|
||||
import { DurationInSeconds } from '../util/durations';
|
||||
import { isGroup } from '../util/whatTypeOfConversation';
|
||||
import { SIGNAL_ACI } from '../types/SignalConversation';
|
||||
|
||||
let storyData:
|
||||
|
@ -33,14 +32,6 @@ export async function loadStories(): Promise<void> {
|
|||
|
||||
storyData = await Promise.all(
|
||||
stories.map(async story => {
|
||||
const conversation = window.ConversationController.get(
|
||||
story.conversationId
|
||||
);
|
||||
|
||||
if (!isGroup(conversation?.attributes)) {
|
||||
return story;
|
||||
}
|
||||
|
||||
const [hasReplies, hasRepliesFromSelf] = await Promise.all([
|
||||
dataInterface.hasStoryReplies(story.id),
|
||||
dataInterface.hasStoryRepliesFromSelf(story.id),
|
||||
|
|
|
@ -516,8 +516,8 @@ function replyToStory(
|
|||
mentions: DraftBodyRangesType,
|
||||
timestamp: number,
|
||||
story: StoryViewType
|
||||
): ThunkAction<void, RootStateType, unknown, NoopActionType> {
|
||||
return async dispatch => {
|
||||
): ThunkAction<void, RootStateType, unknown, StoryChangedActionType> {
|
||||
return async (dispatch, getState) => {
|
||||
const conversation = window.ConversationController.get(conversationId);
|
||||
|
||||
if (!conversation) {
|
||||
|
@ -537,10 +537,23 @@ function replyToStory(
|
|||
}
|
||||
);
|
||||
|
||||
dispatch({
|
||||
type: 'NOOP',
|
||||
payload: null,
|
||||
});
|
||||
const { stories } = getState().stories;
|
||||
|
||||
const storyData = stories.find(s => s.messageId === story.messageId);
|
||||
if (!storyData) {
|
||||
log.error('replyToStory: story not found', story.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
// for group stories, this happens automatically through LOAD_STORY_REPLIES
|
||||
// but 1:1 we need to update manually
|
||||
dispatch(
|
||||
storyChanged({
|
||||
...storyData,
|
||||
hasReplies: true,
|
||||
hasRepliesFromSelf: true,
|
||||
})
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -1396,6 +1409,9 @@ export function reducer(
|
|||
prevStory.sendStateByConversationId,
|
||||
newStory.sendStateByConversationId
|
||||
);
|
||||
const hasHasRepliesChanged =
|
||||
prevStory.hasReplies !== newStory.hasReplies ||
|
||||
prevStory.hasRepliesFromSelf !== newStory.hasRepliesFromSelf;
|
||||
|
||||
const shouldReplace =
|
||||
isDownloadingAttachment ||
|
||||
|
@ -1405,7 +1421,9 @@ export function reducer(
|
|||
hasExpirationChanged ||
|
||||
hasSendStateChanged ||
|
||||
readStatusChanged ||
|
||||
reactionsChanged;
|
||||
reactionsChanged ||
|
||||
hasHasRepliesChanged;
|
||||
|
||||
if (!shouldReplace) {
|
||||
return state;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue