mirror of
https://github.com/signalapp/Signal-Desktop.git
synced 2026-04-17 23:34:14 +01:00
Enable tsconfig noUncheckedIndexedAccess
This commit is contained in:
@@ -110,7 +110,8 @@ async function getNextVoiceNote({
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const { message, attachment } = results[0];
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const { message, attachment } = results[0]!;
|
||||
return extractVoiceNoteForPlayback(
|
||||
{
|
||||
...message,
|
||||
|
||||
@@ -3398,7 +3398,7 @@ export function reducer(
|
||||
rootKey:
|
||||
callLinks[conversationId]?.rootKey ??
|
||||
action.payload.callLinkRootKey,
|
||||
adminKey: callLinks[conversationId]?.adminKey,
|
||||
adminKey: callLinks[conversationId]?.adminKey ?? null,
|
||||
storageNeedsSync: false,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1206,8 +1206,7 @@ function processAttachments({
|
||||
file: File;
|
||||
pendingAttachment: AttachmentDraftType;
|
||||
}> = [];
|
||||
for (let i = 0; i < files.length; i += 1) {
|
||||
const file = files[i];
|
||||
for (const file of files) {
|
||||
const processingResult = preProcessAttachment(file, nextDraftAttachments);
|
||||
if (processingResult != null) {
|
||||
toastToShow = processingResult;
|
||||
@@ -1374,6 +1373,8 @@ function removeAttachment(
|
||||
}
|
||||
|
||||
const targetAttachment = attachments[targetAttachmentIndex];
|
||||
strictAssert(targetAttachment, 'Missing targetAttachment');
|
||||
|
||||
const nextAttachments = attachments
|
||||
.slice(0, targetAttachmentIndex)
|
||||
.concat(attachments.slice(targetAttachmentIndex + 1));
|
||||
@@ -1734,13 +1735,11 @@ export function reducer(
|
||||
if (action.type === CONVERSATION_UNLOADED) {
|
||||
const nextConversations: Record<string, ComposerStateByConversationType> =
|
||||
{};
|
||||
Object.keys(state.conversations).forEach(conversationId => {
|
||||
if (conversationId === action.payload.conversationId) {
|
||||
return;
|
||||
}
|
||||
|
||||
nextConversations[conversationId] = state.conversations[conversationId];
|
||||
});
|
||||
for (const [conversationId, conversation] of Object.entries(
|
||||
state.conversations
|
||||
)) {
|
||||
nextConversations[conversationId] = conversation;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -1624,7 +1624,7 @@ async function getAvatarsAndUpdateConversation(
|
||||
const { conversationLookup } = conversations;
|
||||
const conversationAttrs = conversationLookup[conversationId];
|
||||
const avatars =
|
||||
conversationAttrs.avatars || getAvatarData(conversation.attributes);
|
||||
conversationAttrs?.avatars || getAvatarData(conversation.attributes);
|
||||
|
||||
const nextAvatarId = getNextAvatarId(avatars);
|
||||
const nextAvatars = getNextAvatarsData(avatars, nextAvatarId);
|
||||
@@ -3224,6 +3224,8 @@ function toggleSelectMessage(
|
||||
[toggledMessage, conversations.lastSelectedMessage],
|
||||
message => message
|
||||
);
|
||||
strictAssert(after, 'Missing after');
|
||||
strictAssert(before, 'Missing before');
|
||||
|
||||
const betweenIds = await DataReader.getMessagesBetween(conversationId, {
|
||||
after: {
|
||||
@@ -3738,6 +3740,7 @@ function revokePendingMembershipsFromGroupV2(
|
||||
}
|
||||
|
||||
const [memberId] = memberIds;
|
||||
strictAssert(memberId, 'Missing memberId');
|
||||
|
||||
const pendingMember = window.ConversationController.get(memberId);
|
||||
if (!pendingMember) {
|
||||
@@ -5700,9 +5703,9 @@ function maybeDropMessageIdsFromMessagesLookup(
|
||||
}
|
||||
|
||||
const updatedMessagesLookup: Record<string, MessageWithUIFieldsType> = {};
|
||||
for (const messageId of Object.keys(messagesLookup)) {
|
||||
for (const [messageId, message] of Object.entries(messagesLookup)) {
|
||||
if (!messageIdsToRemove.has(messageId)) {
|
||||
updatedMessagesLookup[messageId] = messagesLookup[messageId];
|
||||
updatedMessagesLookup[messageId] = message;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6334,6 +6337,7 @@ export function reducer(
|
||||
}
|
||||
|
||||
const conversationAttrs = state.conversationLookup[conversationId];
|
||||
strictAssert(conversationAttrs, 'Missing conversationAttrs');
|
||||
const isGroupStoryReply = isGroup(conversationAttrs) && data.storyId;
|
||||
if (isGroupStoryReply) {
|
||||
return dropPreloadData(state);
|
||||
@@ -6563,13 +6567,15 @@ export function reducer(
|
||||
const lastId = oldIds[oldIds.length - 1];
|
||||
|
||||
if (oldest && oldest.id === firstId && firstId === id) {
|
||||
const second = messagesLookup[oldIds[1]];
|
||||
const secondId = oldIds[1];
|
||||
const second = secondId && messagesLookup[secondId];
|
||||
oldest = second
|
||||
? pick(second, ['id', 'received_at', 'sent_at'])
|
||||
: undefined;
|
||||
}
|
||||
if (newest && newest.id === lastId && lastId === id) {
|
||||
const penultimate = messagesLookup[oldIds[oldIds.length - 2]];
|
||||
const secondLastId = oldIds[oldIds.length - 2];
|
||||
const penultimate = secondLastId && messagesLookup[secondLastId];
|
||||
newest = penultimate
|
||||
? pick(penultimate, ['id', 'received_at', 'sent_at'])
|
||||
: undefined;
|
||||
@@ -6708,7 +6714,11 @@ export function reducer(
|
||||
existingConversation.metrics;
|
||||
|
||||
const lookup = fromPairs(
|
||||
existingConversation.messageIds.map(id => [id, messagesLookup[id]])
|
||||
existingConversation.messageIds.map(id => {
|
||||
const message = messagesLookup[id];
|
||||
strictAssert(message, 'Missing message');
|
||||
return [id, message];
|
||||
})
|
||||
);
|
||||
messages.forEach(message => {
|
||||
lookup[message.id] = message;
|
||||
@@ -6724,10 +6734,10 @@ export function reducer(
|
||||
const first = sorted[0];
|
||||
const last = sorted[sorted.length - 1];
|
||||
|
||||
if (!newest) {
|
||||
if (!newest && first != null) {
|
||||
newest = pick(first, ['id', 'received_at', 'sent_at']);
|
||||
}
|
||||
if (!oldest) {
|
||||
if (!oldest && last != null) {
|
||||
oldest = pick(last, ['id', 'received_at', 'sent_at']);
|
||||
}
|
||||
|
||||
@@ -6801,7 +6811,7 @@ export function reducer(
|
||||
...existingConversation,
|
||||
messageIds,
|
||||
messageLoadingState: undefined,
|
||||
scrollToMessageId: isJustSent ? last.id : undefined,
|
||||
scrollToMessageId: isJustSent ? last?.id : undefined,
|
||||
metrics: {
|
||||
...existingConversation.metrics,
|
||||
newest,
|
||||
@@ -7372,8 +7382,7 @@ export function reducer(
|
||||
...state,
|
||||
};
|
||||
|
||||
Object.keys(conversationLookup).forEach(id => {
|
||||
const existing = conversationLookup[id];
|
||||
for (const [id, existing] of Object.entries(conversationLookup)) {
|
||||
const added = {
|
||||
...existing,
|
||||
conversationColor,
|
||||
@@ -7391,7 +7400,7 @@ export function reducer(
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return nextState;
|
||||
}
|
||||
@@ -7431,11 +7440,9 @@ export function reducer(
|
||||
...state,
|
||||
};
|
||||
|
||||
Object.keys(conversationLookup).forEach(id => {
|
||||
const existing = conversationLookup[id];
|
||||
|
||||
for (const [id, existing] of Object.entries(conversationLookup)) {
|
||||
if (existing.customColorId !== colorId) {
|
||||
return;
|
||||
continue;
|
||||
}
|
||||
|
||||
const changed = {
|
||||
@@ -7455,7 +7462,7 @@ export function reducer(
|
||||
},
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
return nextState;
|
||||
}
|
||||
|
||||
@@ -404,9 +404,9 @@ function showLightbox(opts: {
|
||||
media,
|
||||
selectedIndex: index === -1 ? 0 : index,
|
||||
hasPrevMessage:
|
||||
older.length > 0 && filterValidAttachments(older[0]).length > 0,
|
||||
older[0] != null && filterValidAttachments(older[0]).length > 0,
|
||||
hasNextMessage:
|
||||
newer.length > 0 && filterValidAttachments(newer[0]).length > 0,
|
||||
newer[0] != null && filterValidAttachments(newer[0]).length > 0,
|
||||
playbackDisabled: false,
|
||||
},
|
||||
});
|
||||
@@ -429,7 +429,7 @@ function showLightboxForAdjacentMessage(
|
||||
return async (dispatch, getState) => {
|
||||
const { lightbox } = getState();
|
||||
|
||||
if (!lightbox.isShowingLightbox || lightbox.media.length === 0) {
|
||||
if (!lightbox.isShowingLightbox || lightbox.media[0] == null) {
|
||||
log.warn('showLightboxForAdjacentMessage: empty lightbox');
|
||||
return;
|
||||
}
|
||||
@@ -502,8 +502,10 @@ function showLightboxForAdjacentMessage(
|
||||
showLightbox({
|
||||
attachment:
|
||||
direction === AdjacentMessageDirection.Previous
|
||||
? attachments[attachments.length - 1]
|
||||
: attachments[0],
|
||||
? // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
attachments[attachments.length - 1]!
|
||||
: // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
attachments[0]!,
|
||||
messageId: adjacent.id,
|
||||
})
|
||||
);
|
||||
|
||||
@@ -660,7 +660,8 @@ export function reducer(
|
||||
? [
|
||||
{
|
||||
type: 'link',
|
||||
preview: message.preview[0],
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
preview: message.preview[0]!,
|
||||
message: _cleanMessage(message),
|
||||
},
|
||||
]
|
||||
@@ -675,7 +676,8 @@ export function reducer(
|
||||
newDocuments = newDocuments.concat(
|
||||
_cleanContact({
|
||||
type: 'contact',
|
||||
contact: message.contact[0],
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
contact: message.contact[0]!,
|
||||
message: _cleanMessage(message),
|
||||
})
|
||||
);
|
||||
|
||||
@@ -17,6 +17,7 @@ import * as Errors from '../../types/errors.std.js';
|
||||
import type { StateType as RootStateType } from '../reducer.preload.js';
|
||||
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions.std.js';
|
||||
import { useBoundActions } from '../../hooks/useBoundActions.std.js';
|
||||
import { strictAssert } from '../../util/assert.std.js';
|
||||
|
||||
const { omit } = lodash;
|
||||
|
||||
@@ -205,6 +206,7 @@ export function reducer(
|
||||
const { contact } = action.payload;
|
||||
const { id } = contact;
|
||||
const record = state.contacts[id];
|
||||
strictAssert(record, 'Missing record');
|
||||
return {
|
||||
contacts: {
|
||||
...state.contacts,
|
||||
@@ -221,6 +223,7 @@ export function reducer(
|
||||
const { contact, ...restProps } = action.payload;
|
||||
const { id } = contact;
|
||||
const record = state.contacts[id];
|
||||
strictAssert(record, 'Missing record');
|
||||
return {
|
||||
contacts: {
|
||||
...state.contacts,
|
||||
@@ -237,6 +240,7 @@ export function reducer(
|
||||
const { contact, safetyNumber } = action.payload;
|
||||
const { id } = contact;
|
||||
const record = state.contacts[id];
|
||||
strictAssert(record, 'Missing record');
|
||||
return {
|
||||
contacts: {
|
||||
...state.contacts,
|
||||
|
||||
@@ -624,10 +624,7 @@ async function queryConversationsAndContacts(
|
||||
// Split into two groups - active conversations and items just from address book
|
||||
let conversationIds: Array<string> = [];
|
||||
let contactIds: Array<string> = [];
|
||||
const max = searchResults.length;
|
||||
for (let i = 0; i < max; i += 1) {
|
||||
const conversation = searchResults[i];
|
||||
|
||||
for (const conversation of searchResults) {
|
||||
if (conversation.type === 'direct' && !conversation.lastMessage) {
|
||||
contactIds.push(conversation.id);
|
||||
} else {
|
||||
|
||||
@@ -27,6 +27,7 @@ import type { EraseStorageServiceStateAction } from './user.preload.js';
|
||||
import type { NoopActionType } from './noop.std.js';
|
||||
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions.std.js';
|
||||
import { useBoundActions } from '../../hooks/useBoundActions.std.js';
|
||||
import { strictAssert } from '../../util/assert.std.js';
|
||||
|
||||
const { omit, reject } = lodash;
|
||||
|
||||
@@ -419,6 +420,7 @@ export function reducer(
|
||||
if (action.type === 'stickers/STICKER_ADDED') {
|
||||
const { payload } = action;
|
||||
const packToUpdate = state.packs[payload.packId];
|
||||
strictAssert(packToUpdate, 'Missing packToUpdate');
|
||||
|
||||
return {
|
||||
...state,
|
||||
@@ -438,6 +440,7 @@ export function reducer(
|
||||
if (action.type === 'stickers/STICKER_PACK_UPDATED') {
|
||||
const { payload } = action;
|
||||
const packToUpdate = state.packs[payload.packId];
|
||||
strictAssert(packToUpdate, 'Missing packToUpdate');
|
||||
|
||||
return {
|
||||
...state,
|
||||
@@ -480,7 +483,7 @@ export function reducer(
|
||||
packs: {
|
||||
...packs,
|
||||
[packId]: {
|
||||
...packs[packId],
|
||||
...existingPack,
|
||||
status,
|
||||
installedAt,
|
||||
},
|
||||
@@ -515,6 +518,7 @@ export function reducer(
|
||||
item => item.packId === packId && item.stickerId === stickerId
|
||||
);
|
||||
const pack = packs[packId];
|
||||
strictAssert(pack, 'Missing pack');
|
||||
const sticker = pack.stickers[stickerId];
|
||||
|
||||
return {
|
||||
|
||||
@@ -916,6 +916,7 @@ const viewUserStories: ViewUserStoriesActionCreatorType = ({
|
||||
});
|
||||
|
||||
const story = storiesByConversationId[currentIndex];
|
||||
strictAssert(story, 'Missing story');
|
||||
const state = getState();
|
||||
|
||||
const hiddenConversationIds = new Set(getHideStoryConversationIds(state));
|
||||
@@ -1081,6 +1082,7 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
const currentDistributionListIndex = myStories.findIndex(item => {
|
||||
for (let i = item.stories.length - 1; i >= 0; i -= 1) {
|
||||
const myStory = item.stories[i];
|
||||
strictAssert(myStory, 'Missing myStory');
|
||||
if (myStory.messageId === storyId) {
|
||||
// [1] reversed
|
||||
currentStoryIndex = item.stories.length - 1 - i;
|
||||
@@ -1107,37 +1109,51 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
let nextSentStoryIndex = -1;
|
||||
let nextNumStories = numStories;
|
||||
|
||||
const currentSentStoryContainer = myStories[currentDistributionListIndex];
|
||||
strictAssert(
|
||||
currentSentStoryContainer,
|
||||
'Missing currentSentStoryContainer'
|
||||
);
|
||||
|
||||
// [2] reversed
|
||||
const currentStories = myStories[currentDistributionListIndex].stories
|
||||
const currentStories = currentSentStoryContainer.stories
|
||||
.slice()
|
||||
.reverse();
|
||||
|
||||
if (viewDirection === StoryViewDirectionType.Next) {
|
||||
if (currentStoryIndex < currentStories.length - 1) {
|
||||
nextSentStoryIndex = currentStoryIndex + 1;
|
||||
nextSentStoryId = currentStories[nextSentStoryIndex].messageId;
|
||||
nextSentStoryId = currentStories[nextSentStoryIndex]?.messageId;
|
||||
} else if (currentDistributionListIndex < myStories.length - 1) {
|
||||
const nextSentStoryContainer =
|
||||
myStories[currentDistributionListIndex + 1];
|
||||
strictAssert(
|
||||
nextSentStoryContainer,
|
||||
'Missing nextSentStoryContainer'
|
||||
);
|
||||
|
||||
nextNumStories = nextSentStoryContainer.stories.length;
|
||||
nextSentStoryIndex = 0;
|
||||
nextSentStoryId =
|
||||
nextSentStoryContainer.stories[nextNumStories - 1].messageId;
|
||||
nextSentStoryContainer.stories[nextNumStories - 1]?.messageId;
|
||||
}
|
||||
}
|
||||
|
||||
if (viewDirection === StoryViewDirectionType.Previous) {
|
||||
if (currentStoryIndex > 0) {
|
||||
nextSentStoryIndex = currentStoryIndex - 1;
|
||||
nextSentStoryId = currentStories[nextSentStoryIndex].messageId;
|
||||
nextSentStoryId = currentStories[nextSentStoryIndex]?.messageId;
|
||||
} else if (currentDistributionListIndex > 0) {
|
||||
const nextSentStoryContainer =
|
||||
myStories[currentDistributionListIndex - 1];
|
||||
strictAssert(
|
||||
nextSentStoryContainer,
|
||||
'Missing nextSentStoryContainer'
|
||||
);
|
||||
|
||||
nextNumStories = nextSentStoryContainer.stories.length;
|
||||
nextSentStoryIndex = nextNumStories - 1;
|
||||
nextSentStoryId = nextSentStoryContainer.stories[0].messageId;
|
||||
nextSentStoryId = nextSentStoryContainer.stories[0]?.messageId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1169,6 +1185,7 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
) {
|
||||
const nextIndex = currentIndex + 1;
|
||||
const nextStory = storiesByConversationId[nextIndex];
|
||||
strictAssert(nextStory, 'Missing nextStory');
|
||||
|
||||
dispatch({
|
||||
type: VIEW_STORY,
|
||||
@@ -1187,6 +1204,7 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
if (viewDirection === StoryViewDirectionType.Previous && currentIndex > 0) {
|
||||
const nextIndex = currentIndex - 1;
|
||||
const nextStory = storiesByConversationId[nextIndex];
|
||||
strictAssert(nextStory, 'Missing nextStory');
|
||||
|
||||
dispatch({
|
||||
type: VIEW_STORY,
|
||||
@@ -1245,15 +1263,17 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
onlyFromSelf: false,
|
||||
}
|
||||
);
|
||||
const nextStory =
|
||||
nextSelectedStoryData.storiesByConversationId[
|
||||
nextSelectedStoryData.currentIndex
|
||||
];
|
||||
strictAssert(nextStory, 'Missing nextStory');
|
||||
|
||||
dispatch({
|
||||
type: VIEW_STORY,
|
||||
payload: {
|
||||
currentIndex: nextSelectedStoryData.currentIndex,
|
||||
messageId:
|
||||
nextSelectedStoryData.storiesByConversationId[
|
||||
nextSelectedStoryData.currentIndex
|
||||
].messageId,
|
||||
messageId: nextStory.messageId,
|
||||
numStories: nextSelectedStoryData.numStories,
|
||||
storyViewMode,
|
||||
unviewedStoryConversationIdsSorted,
|
||||
@@ -1298,6 +1318,7 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
// Touch area for tapping right should be 80% of width of the screen
|
||||
const nextConversationStoryIndex = conversationStoryIndex + 1;
|
||||
const conversationStory = conversationStories[nextConversationStoryIndex];
|
||||
strictAssert(conversationStory, 'Missing conversationStory');
|
||||
|
||||
const nextSelectedStoryData = getSelectedStoryDataForConversationId(
|
||||
dispatch,
|
||||
@@ -1308,11 +1329,14 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
}
|
||||
);
|
||||
|
||||
const nextStory = nextSelectedStoryData.storiesByConversationId[0];
|
||||
strictAssert(nextStory, 'Missing nextStory');
|
||||
|
||||
dispatch({
|
||||
type: VIEW_STORY,
|
||||
payload: {
|
||||
currentIndex: 0,
|
||||
messageId: nextSelectedStoryData.storiesByConversationId[0].messageId,
|
||||
messageId: nextStory.messageId,
|
||||
numStories: nextSelectedStoryData.numStories,
|
||||
storyViewMode,
|
||||
unviewedStoryConversationIdsSorted,
|
||||
@@ -1336,6 +1360,7 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
// Touch area for tapping left should be 20% of width of the screen
|
||||
const nextConversationStoryIndex = conversationStoryIndex - 1;
|
||||
const conversationStory = conversationStories[nextConversationStoryIndex];
|
||||
strictAssert(conversationStory, 'Missing conversationStory');
|
||||
|
||||
const nextSelectedStoryData = getSelectedStoryDataForConversationId(
|
||||
dispatch,
|
||||
@@ -1346,11 +1371,14 @@ const viewStory: ViewStoryActionCreatorType = (
|
||||
}
|
||||
);
|
||||
|
||||
const nextStory = nextSelectedStoryData.storiesByConversationId[0];
|
||||
strictAssert(nextStory, 'Missing nextStory');
|
||||
|
||||
dispatch({
|
||||
type: VIEW_STORY,
|
||||
payload: {
|
||||
currentIndex: 0,
|
||||
messageId: nextSelectedStoryData.storiesByConversationId[0].messageId,
|
||||
messageId: nextStory.messageId,
|
||||
numStories: nextSelectedStoryData.numStories,
|
||||
storyViewMode,
|
||||
unviewedStoryConversationIdsSorted,
|
||||
@@ -1558,6 +1586,7 @@ export function reducer(
|
||||
);
|
||||
if (prevStoryIndex >= 0) {
|
||||
const prevStory = state.stories[prevStoryIndex];
|
||||
strictAssert(prevStory, 'Missing prevStory');
|
||||
|
||||
// Stories rarely need to change, here are the following exceptions...
|
||||
|
||||
@@ -1708,17 +1737,20 @@ export function reducer(
|
||||
story => story.messageId === replyState.messageId
|
||||
);
|
||||
|
||||
const stories =
|
||||
storyIndex >= 0
|
||||
? replaceIndex(state.stories, storyIndex, {
|
||||
...state.stories[storyIndex],
|
||||
hasReplies: true,
|
||||
hasRepliesFromSelf:
|
||||
state.stories[storyIndex].hasRepliesFromSelf ||
|
||||
state.stories[storyIndex].conversationId ===
|
||||
action.payload.conversationId,
|
||||
})
|
||||
: state.stories;
|
||||
let stories: ReadonlyArray<StoryDataType>;
|
||||
if (storyIndex >= 0) {
|
||||
const currentStory = state.stories[storyIndex];
|
||||
strictAssert(currentStory, 'Missing currentStory');
|
||||
stories = replaceIndex(state.stories, storyIndex, {
|
||||
...currentStory,
|
||||
hasReplies: true,
|
||||
hasRepliesFromSelf:
|
||||
currentStory.hasRepliesFromSelf ||
|
||||
currentStory.conversationId === action.payload.conversationId,
|
||||
});
|
||||
} else {
|
||||
stories = state.stories;
|
||||
}
|
||||
|
||||
return {
|
||||
...state,
|
||||
@@ -1775,6 +1807,7 @@ export function reducer(
|
||||
}
|
||||
|
||||
const existingStory = state.stories[storyIndex];
|
||||
strictAssert(existingStory, 'Missing existingStory');
|
||||
|
||||
return {
|
||||
...state,
|
||||
|
||||
@@ -19,6 +19,7 @@ import { storageServiceUploadJob } from '../../services/storage.preload.js';
|
||||
import type { BoundActionCreatorsMapObject } from '../../hooks/useBoundActions.std.js';
|
||||
import { useBoundActions } from '../../hooks/useBoundActions.std.js';
|
||||
import { itemStorage } from '../../textsecure/Storage.preload.js';
|
||||
import { strictAssert } from '../../util/assert.std.js';
|
||||
|
||||
const { omit } = lodash;
|
||||
|
||||
@@ -530,9 +531,11 @@ function replaceDistributionListData(
|
||||
return;
|
||||
}
|
||||
|
||||
const list = distributionLists[listIndex];
|
||||
strictAssert(list, 'Missing list');
|
||||
return replaceIndex(distributionLists, listIndex, {
|
||||
...distributionLists[listIndex],
|
||||
...getNextDistributionListData(distributionLists[listIndex]),
|
||||
...list,
|
||||
...getNextDistributionListData(list),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -551,6 +554,11 @@ export function reducer(
|
||||
);
|
||||
if (listIndex >= 0) {
|
||||
const existingDistributionList = state.distributionLists[listIndex];
|
||||
strictAssert(
|
||||
existingDistributionList,
|
||||
'Missing existingDistributionList'
|
||||
);
|
||||
|
||||
const memberServiceIds = new Set<ServiceIdString>(
|
||||
existingDistributionList.memberServiceIds
|
||||
);
|
||||
|
||||
@@ -46,9 +46,7 @@ export const getCallHistoryLatestCall = createSelector(
|
||||
callHistory => {
|
||||
let latestCall = null;
|
||||
|
||||
for (const callId of Object.keys(callHistory.callHistoryByCallId)) {
|
||||
const call = callHistory.callHistoryByCallId[callId];
|
||||
|
||||
for (const call of Object.values(callHistory.callHistoryByCallId)) {
|
||||
// Skip unused call links
|
||||
if (
|
||||
call.type === CallType.Adhoc &&
|
||||
|
||||
@@ -456,11 +456,7 @@ export const _getLeftPaneLists = ({
|
||||
const archivedConversations: Array<ConversationType> = [];
|
||||
const pinnedConversations: Array<ConversationType> = [];
|
||||
|
||||
const values = Object.values(conversationLookup);
|
||||
const max = values.length;
|
||||
for (let i = 0; i < max; i += 1) {
|
||||
let conversation = values[i];
|
||||
|
||||
for (let conversation of Object.values(conversationLookup)) {
|
||||
if (
|
||||
isChatFoldersEnabled(window.SignalContext.getVersion()) &&
|
||||
!_shouldIncludeInChatFolder(
|
||||
@@ -1180,7 +1176,8 @@ export const getCachedConversationMemberColorsSelector = createSelector(
|
||||
|
||||
contactNameColors.set(
|
||||
conversation.id,
|
||||
ContactNameColors[i % ContactNameColors.length]
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
ContactNameColors[i % ContactNameColors.length]!
|
||||
);
|
||||
});
|
||||
|
||||
@@ -1211,9 +1208,9 @@ export const getContactNameColorSelector = createSelector(
|
||||
);
|
||||
|
||||
export const getContactNameColor = (
|
||||
contactNameColors: Map<string, string>,
|
||||
contactNameColors: Map<string, ContactNameColorType>,
|
||||
contactId: string | undefined
|
||||
): string => {
|
||||
): ContactNameColorType => {
|
||||
if (!contactId) {
|
||||
log.warn('No color generated for missing contactId');
|
||||
return ContactNameColors[0];
|
||||
@@ -1460,10 +1457,17 @@ export const getConversationsStoppingSend = createSelector(
|
||||
|
||||
export const getHideStoryConversationIds = createSelector(
|
||||
getConversationLookup,
|
||||
(conversationLookup): Array<string> =>
|
||||
Object.keys(conversationLookup).filter(
|
||||
conversationId => conversationLookup[conversationId].hideStory
|
||||
)
|
||||
(conversationLookup): Array<string> => {
|
||||
const result: Array<string> = [];
|
||||
for (const [conversationId, conversation] of Object.entries(
|
||||
conversationLookup
|
||||
)) {
|
||||
if (conversation.hideStory) {
|
||||
result.push(conversationId);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
|
||||
export const getStoriesState = (state: StateType): StoriesStateType =>
|
||||
@@ -1546,20 +1550,10 @@ export const getLastEditableMessageId = createSelector(
|
||||
return;
|
||||
}
|
||||
|
||||
for (let i = conversationMessages.messageIds.length - 1; i >= 0; i -= 1) {
|
||||
const messageId = conversationMessages.messageIds[i];
|
||||
return conversationMessages.messageIds.findLast(messageId => {
|
||||
const message = messagesLookup[messageId];
|
||||
|
||||
if (!message) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (isOutgoing(message)) {
|
||||
return canEditMessage(message) ? message.id : undefined;
|
||||
}
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return message != null && isOutgoing(message) && canEditMessage(message);
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -72,7 +72,10 @@ import {
|
||||
defaultBlurHash,
|
||||
} from '../../util/Attachment.std.js';
|
||||
import type { MessageAttachmentType } from '../../types/AttachmentDownload.std.js';
|
||||
import { type DefaultConversationColorType } from '../../types/Colors.std.js';
|
||||
import type {
|
||||
ContactNameColorType,
|
||||
DefaultConversationColorType,
|
||||
} from '../../types/Colors.std.js';
|
||||
import { ReadStatus } from '../../messages/MessageReadStatus.std.js';
|
||||
|
||||
import type { CallingNotificationType } from '../../util/callingNotification.std.js';
|
||||
@@ -212,7 +215,7 @@ export type GetPropsForBubbleOptions = Readonly<{
|
||||
callHistorySelector: CallHistorySelectorType;
|
||||
activeCall?: CallStateType;
|
||||
accountSelector: AccountSelectorType;
|
||||
contactNameColors: Map<string, string>;
|
||||
contactNameColors: Map<string, ContactNameColorType>;
|
||||
defaultConversationColor: DefaultConversationColorType;
|
||||
}>;
|
||||
|
||||
@@ -2115,7 +2118,7 @@ function getDeletedForEveryoneByAdmin(
|
||||
message: MessageWithUIFieldsType,
|
||||
options: {
|
||||
conversationSelector: GetConversationByIdType;
|
||||
contactNameColors: Map<string, string>;
|
||||
contactNameColors: Map<string, ContactNameColorType>;
|
||||
ourAci: AciString | undefined;
|
||||
}
|
||||
): PropsData['deletedForEveryoneByAdmin'] {
|
||||
@@ -2157,7 +2160,8 @@ export function getPropsForEmbeddedContact(
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const firstContact = contacts[0];
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const firstContact = contacts[0]!;
|
||||
const numbers = firstContact?.number;
|
||||
const firstNumber = numbers && numbers[0] ? numbers[0].value : undefined;
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export const getBlessedStickerPacks = createSelector(
|
||||
): Array<StickerPackType> => {
|
||||
return filterAndTransformPacks(
|
||||
packs,
|
||||
pack => blessedPacks[pack.id] && pack.status !== 'installed',
|
||||
pack => blessedPacks[pack.id] != null && pack.status !== 'installed',
|
||||
pack => pack.createdAt,
|
||||
blessedPacks
|
||||
);
|
||||
|
||||
@@ -113,15 +113,18 @@ function sortMyStories(storyA: MyStoryType, storyB: MyStoryType): number {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!storyA.stories.length) {
|
||||
const a = storyA.stories[0];
|
||||
const b = storyB.stories[0];
|
||||
|
||||
if (a == null) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!storyB.stories.length) {
|
||||
if (b == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return storyA.stories[0].timestamp > storyB.stories[0].timestamp ? -1 : 1;
|
||||
return b.timestamp - a.timestamp;
|
||||
}
|
||||
|
||||
function getAvatarData(
|
||||
|
||||
@@ -41,11 +41,12 @@ import {
|
||||
import type { ConversationType } from '../ducks/conversations.preload.js';
|
||||
import { missingCaseError } from '../../util/missingCaseError.std.js';
|
||||
import { getGroupMemberships } from '../../util/getGroupMemberships.dom.js';
|
||||
import type { ContactNameColorType } from '../../types/Colors.std.js';
|
||||
|
||||
const getTimelineItem = (
|
||||
state: StateType,
|
||||
messageId: string | undefined,
|
||||
contactNameColors: Map<string, string>
|
||||
contactNameColors: Map<string, ContactNameColorType>
|
||||
): TimelineItemType | undefined => {
|
||||
if (messageId === undefined) {
|
||||
return undefined;
|
||||
|
||||
@@ -194,8 +194,8 @@ const mapStateToActiveCallProp = (
|
||||
},
|
||||
} = call;
|
||||
|
||||
for (let i = 0; i < memberships.length; i += 1) {
|
||||
const { aci } = memberships[i];
|
||||
for (const membership of memberships) {
|
||||
const { aci } = membership;
|
||||
|
||||
const member = conversationSelector(aci);
|
||||
if (!member) {
|
||||
@@ -206,9 +206,7 @@ const mapStateToActiveCallProp = (
|
||||
groupMembers.push(member);
|
||||
}
|
||||
|
||||
for (let i = 0; i < call.remoteParticipants.length; i += 1) {
|
||||
const remoteParticipant = call.remoteParticipants[i];
|
||||
|
||||
for (const remoteParticipant of call.remoteParticipants) {
|
||||
const remoteConversation = conversationSelectorByAci(
|
||||
remoteParticipant.aci
|
||||
);
|
||||
@@ -248,9 +246,7 @@ const mapStateToActiveCallProp = (
|
||||
}
|
||||
});
|
||||
|
||||
for (let i = 0; i < peekInfo.acis.length; i += 1) {
|
||||
const peekedParticipantAci = peekInfo.acis[i];
|
||||
|
||||
for (const peekedParticipantAci of peekInfo.acis) {
|
||||
const peekedConversation =
|
||||
conversationSelectorByAci(peekedParticipantAci);
|
||||
if (!peekedConversation) {
|
||||
@@ -261,9 +257,7 @@ const mapStateToActiveCallProp = (
|
||||
peekedParticipants.push(peekedConversation);
|
||||
}
|
||||
|
||||
for (let i = 0; i < peekInfo.pendingAcis.length; i += 1) {
|
||||
const aci = peekInfo.pendingAcis[i];
|
||||
|
||||
for (const aci of peekInfo.pendingAcis) {
|
||||
// In call links, pending users may be unknown until they share profile keys.
|
||||
// conversationSelectorByAci should create conversations for new contacts.
|
||||
const pendingConversation = conversationSelectorByAci(aci);
|
||||
|
||||
@@ -104,7 +104,8 @@ export const SmartToastManager = memo(function SmartToastManager({
|
||||
};
|
||||
} else if (megaphones.length > 0) {
|
||||
megaphone = {
|
||||
...megaphones[0],
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
...megaphones[0]!,
|
||||
type: MegaphoneType.Remote,
|
||||
onInteractWithMegaphone: interactWithMegaphone,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user