2023-01-03 19:55:46 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2022-12-23 00:32:03 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import type { TimelineItemType } from '../../components/conversation/TimelineItem';
|
|
|
|
|
|
|
|
import type { StateType } from '../reducer';
|
|
|
|
import {
|
|
|
|
getContactNameColorSelector,
|
|
|
|
getConversationSelector,
|
2023-03-20 22:23:53 +00:00
|
|
|
getTargetedMessage,
|
2022-12-23 00:32:03 +00:00
|
|
|
getMessages,
|
2023-03-20 22:23:53 +00:00
|
|
|
getSelectedMessageIds,
|
2022-12-23 00:32:03 +00:00
|
|
|
} from './conversations';
|
|
|
|
import { getAccountSelector } from './accounts';
|
|
|
|
import {
|
|
|
|
getRegionCode,
|
|
|
|
getUserConversationId,
|
|
|
|
getUserNumber,
|
|
|
|
getUserACI,
|
|
|
|
getUserPNI,
|
|
|
|
} from './user';
|
|
|
|
import { getActiveCall, getCallSelector } from './calling';
|
|
|
|
import { getPropsForBubble } from './message';
|
2023-08-09 00:53:06 +00:00
|
|
|
import { getCallHistorySelector } from './callHistory';
|
2022-12-23 00:32:03 +00:00
|
|
|
|
|
|
|
export const getTimelineItem = (
|
|
|
|
state: StateType,
|
2023-01-19 19:56:02 +00:00
|
|
|
id?: string
|
2022-12-23 00:32:03 +00:00
|
|
|
): TimelineItemType | undefined => {
|
2023-01-19 19:56:02 +00:00
|
|
|
if (id === undefined) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2022-12-23 00:32:03 +00:00
|
|
|
const messageLookup = getMessages(state);
|
|
|
|
|
|
|
|
const message = messageLookup[id];
|
|
|
|
if (!message) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
|
2023-03-20 22:23:53 +00:00
|
|
|
const targetedMessage = getTargetedMessage(state);
|
2023-01-19 19:56:02 +00:00
|
|
|
const conversationSelector = getConversationSelector(state);
|
|
|
|
const regionCode = getRegionCode(state);
|
|
|
|
const ourNumber = getUserNumber(state);
|
|
|
|
const ourACI = getUserACI(state);
|
|
|
|
const ourPNI = getUserPNI(state);
|
|
|
|
const ourConversationId = getUserConversationId(state);
|
|
|
|
const callSelector = getCallSelector(state);
|
2023-08-09 00:53:06 +00:00
|
|
|
const callHistorySelector = getCallHistorySelector(state);
|
2023-01-19 19:56:02 +00:00
|
|
|
const activeCall = getActiveCall(state);
|
|
|
|
const accountSelector = getAccountSelector(state);
|
|
|
|
const contactNameColorSelector = getContactNameColorSelector(state);
|
2023-03-20 22:23:53 +00:00
|
|
|
const selectedMessageIds = getSelectedMessageIds(state);
|
2023-01-19 19:56:02 +00:00
|
|
|
|
|
|
|
return getPropsForBubble(message, {
|
|
|
|
conversationSelector,
|
|
|
|
ourConversationId,
|
|
|
|
ourNumber,
|
|
|
|
ourACI,
|
|
|
|
ourPNI,
|
|
|
|
regionCode,
|
2023-03-20 22:23:53 +00:00
|
|
|
targetedMessageId: targetedMessage?.id,
|
|
|
|
targetedMessageCounter: targetedMessage?.counter,
|
2023-01-19 19:56:02 +00:00
|
|
|
contactNameColorSelector,
|
|
|
|
callSelector,
|
2023-08-09 00:53:06 +00:00
|
|
|
callHistorySelector,
|
2023-01-19 19:56:02 +00:00
|
|
|
activeCall,
|
|
|
|
accountSelector,
|
2023-03-20 22:23:53 +00:00
|
|
|
selectedMessageIds,
|
2023-01-19 19:56:02 +00:00
|
|
|
});
|
2022-12-23 00:32:03 +00:00
|
|
|
};
|