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;
|
let repliesElement: JSX.Element | undefined;
|
||||||
if (hasRepliesFromSelf) {
|
if (group === undefined && hasRepliesFromSelf) {
|
||||||
repliesElement = <div className="StoryListItem__info--replies--self" />;
|
repliesElement = <div className="StoryListItem__info--replies--self" />;
|
||||||
} else if (hasReplies) {
|
} else if (group && (hasReplies || hasRepliesFromSelf)) {
|
||||||
repliesElement = <div className="StoryListItem__info--replies--others" />;
|
repliesElement = <div className="StoryListItem__info--replies--others" />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,6 @@ import { isNotNil } from '../util/isNotNil';
|
||||||
import { strictAssert } from '../util/assert';
|
import { strictAssert } from '../util/assert';
|
||||||
import { dropNull } from '../util/dropNull';
|
import { dropNull } from '../util/dropNull';
|
||||||
import { DurationInSeconds } from '../util/durations';
|
import { DurationInSeconds } from '../util/durations';
|
||||||
import { isGroup } from '../util/whatTypeOfConversation';
|
|
||||||
import { SIGNAL_ACI } from '../types/SignalConversation';
|
import { SIGNAL_ACI } from '../types/SignalConversation';
|
||||||
|
|
||||||
let storyData:
|
let storyData:
|
||||||
|
@ -33,14 +32,6 @@ export async function loadStories(): Promise<void> {
|
||||||
|
|
||||||
storyData = await Promise.all(
|
storyData = await Promise.all(
|
||||||
stories.map(async story => {
|
stories.map(async story => {
|
||||||
const conversation = window.ConversationController.get(
|
|
||||||
story.conversationId
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!isGroup(conversation?.attributes)) {
|
|
||||||
return story;
|
|
||||||
}
|
|
||||||
|
|
||||||
const [hasReplies, hasRepliesFromSelf] = await Promise.all([
|
const [hasReplies, hasRepliesFromSelf] = await Promise.all([
|
||||||
dataInterface.hasStoryReplies(story.id),
|
dataInterface.hasStoryReplies(story.id),
|
||||||
dataInterface.hasStoryRepliesFromSelf(story.id),
|
dataInterface.hasStoryRepliesFromSelf(story.id),
|
||||||
|
|
|
@ -516,8 +516,8 @@ function replyToStory(
|
||||||
mentions: DraftBodyRangesType,
|
mentions: DraftBodyRangesType,
|
||||||
timestamp: number,
|
timestamp: number,
|
||||||
story: StoryViewType
|
story: StoryViewType
|
||||||
): ThunkAction<void, RootStateType, unknown, NoopActionType> {
|
): ThunkAction<void, RootStateType, unknown, StoryChangedActionType> {
|
||||||
return async dispatch => {
|
return async (dispatch, getState) => {
|
||||||
const conversation = window.ConversationController.get(conversationId);
|
const conversation = window.ConversationController.get(conversationId);
|
||||||
|
|
||||||
if (!conversation) {
|
if (!conversation) {
|
||||||
|
@ -537,10 +537,23 @@ function replyToStory(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
dispatch({
|
const { stories } = getState().stories;
|
||||||
type: 'NOOP',
|
|
||||||
payload: null,
|
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,
|
prevStory.sendStateByConversationId,
|
||||||
newStory.sendStateByConversationId
|
newStory.sendStateByConversationId
|
||||||
);
|
);
|
||||||
|
const hasHasRepliesChanged =
|
||||||
|
prevStory.hasReplies !== newStory.hasReplies ||
|
||||||
|
prevStory.hasRepliesFromSelf !== newStory.hasRepliesFromSelf;
|
||||||
|
|
||||||
const shouldReplace =
|
const shouldReplace =
|
||||||
isDownloadingAttachment ||
|
isDownloadingAttachment ||
|
||||||
|
@ -1405,7 +1421,9 @@ export function reducer(
|
||||||
hasExpirationChanged ||
|
hasExpirationChanged ||
|
||||||
hasSendStateChanged ||
|
hasSendStateChanged ||
|
||||||
readStatusChanged ||
|
readStatusChanged ||
|
||||||
reactionsChanged;
|
reactionsChanged ||
|
||||||
|
hasHasRepliesChanged;
|
||||||
|
|
||||||
if (!shouldReplace) {
|
if (!shouldReplace) {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue