2022-02-23 18:48:40 +00:00
|
|
|
// Copyright 2022 Signal Messenger, LLC
|
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import { getEmptyState as accounts } from './ducks/accounts';
|
|
|
|
import { getEmptyState as app } from './ducks/app';
|
|
|
|
import { getEmptyState as audioPlayer } from './ducks/audioPlayer';
|
|
|
|
import { getEmptyState as audioRecorder } from './ducks/audioRecorder';
|
2023-08-09 00:53:06 +00:00
|
|
|
import { getEmptyState as callHistory } from './ducks/callHistory';
|
2022-02-23 18:48:40 +00:00
|
|
|
import { getEmptyState as calling } from './ducks/calling';
|
|
|
|
import { getEmptyState as composer } from './ducks/composer';
|
|
|
|
import { getEmptyState as conversations } from './ducks/conversations';
|
|
|
|
import { getEmptyState as crashReports } from './ducks/crashReports';
|
|
|
|
import { getEmptyState as expiration } from './ducks/expiration';
|
|
|
|
import { getEmptyState as globalModals } from './ducks/globalModals';
|
2023-03-28 20:31:24 +00:00
|
|
|
import { getEmptyState as inbox } from './ducks/inbox';
|
2022-12-10 02:02:22 +00:00
|
|
|
import { getEmptyState as lightbox } from './ducks/lightbox';
|
2022-02-23 18:48:40 +00:00
|
|
|
import { getEmptyState as linkPreviews } from './ducks/linkPreviews';
|
2022-12-20 17:50:23 +00:00
|
|
|
import { getEmptyState as mediaGallery } from './ducks/mediaGallery';
|
2023-08-09 00:53:06 +00:00
|
|
|
import { getEmptyState as nav } from './ducks/nav';
|
2022-02-23 18:48:40 +00:00
|
|
|
import { getEmptyState as network } from './ducks/network';
|
|
|
|
import { getEmptyState as preferredReactions } from './ducks/preferredReactions';
|
|
|
|
import { getEmptyState as safetyNumber } from './ducks/safetyNumber';
|
|
|
|
import { getEmptyState as search } from './ducks/search';
|
2022-03-04 21:14:52 +00:00
|
|
|
import { getEmptyState as getStoriesEmptyState } from './ducks/stories';
|
2022-07-01 00:52:03 +00:00
|
|
|
import { getEmptyState as getStoryDistributionListsEmptyState } from './ducks/storyDistributionLists';
|
2022-07-12 16:41:41 +00:00
|
|
|
import { getEmptyState as getToastEmptyState } from './ducks/toast';
|
2022-02-23 18:48:40 +00:00
|
|
|
import { getEmptyState as updates } from './ducks/updates';
|
|
|
|
import { getEmptyState as user } from './ducks/user';
|
2022-10-18 17:12:02 +00:00
|
|
|
import { getEmptyState as username } from './ducks/username';
|
2022-02-23 18:48:40 +00:00
|
|
|
|
|
|
|
import type { StateType } from './reducer';
|
|
|
|
import type { BadgesStateType } from './ducks/badges';
|
2023-01-13 00:24:59 +00:00
|
|
|
import type { MainWindowStatsType } from '../windows/context';
|
|
|
|
import type { MenuOptionsType } from '../types/menu';
|
2022-03-04 21:14:52 +00:00
|
|
|
import type { StoryDataType } from './ducks/stories';
|
2022-07-01 00:52:03 +00:00
|
|
|
import type { StoryDistributionListDataType } from './ducks/storyDistributionLists';
|
2023-04-20 21:23:19 +00:00
|
|
|
import OS from '../util/os/osMain';
|
2022-02-23 18:48:40 +00:00
|
|
|
import { getEmojiReducerState as emojis } from '../util/loadRecentEmojis';
|
2023-01-13 00:24:59 +00:00
|
|
|
import { getInitialState as stickers } from '../types/Stickers';
|
2023-03-14 15:55:31 +00:00
|
|
|
import { getInteractionMode } from '../services/InteractionMode';
|
2023-04-11 03:54:43 +00:00
|
|
|
import { makeLookup } from '../util/makeLookup';
|
2023-08-09 00:53:06 +00:00
|
|
|
import type { CallHistoryDetails } from '../types/CallDisposition';
|
2024-03-07 17:36:08 +00:00
|
|
|
import type { ThemeType } from '../types/Util';
|
2022-02-23 18:48:40 +00:00
|
|
|
|
|
|
|
export function getInitialState({
|
|
|
|
badges,
|
2023-08-09 00:53:06 +00:00
|
|
|
callsHistory,
|
2024-03-04 22:26:49 +00:00
|
|
|
callsHistoryUnreadCount,
|
2022-03-04 21:14:52 +00:00
|
|
|
stories,
|
2022-07-01 00:52:03 +00:00
|
|
|
storyDistributionLists,
|
2022-06-08 22:00:32 +00:00
|
|
|
mainWindowStats,
|
|
|
|
menuOptions,
|
2024-03-07 17:36:08 +00:00
|
|
|
theme,
|
2022-02-23 18:48:40 +00:00
|
|
|
}: {
|
|
|
|
badges: BadgesStateType;
|
2023-08-09 00:53:06 +00:00
|
|
|
callsHistory: ReadonlyArray<CallHistoryDetails>;
|
2024-03-04 22:26:49 +00:00
|
|
|
callsHistoryUnreadCount: number;
|
2022-03-04 21:14:52 +00:00
|
|
|
stories: Array<StoryDataType>;
|
2022-07-01 00:52:03 +00:00
|
|
|
storyDistributionLists: Array<StoryDistributionListDataType>;
|
2022-06-08 22:00:32 +00:00
|
|
|
mainWindowStats: MainWindowStatsType;
|
|
|
|
menuOptions: MenuOptionsType;
|
2024-03-07 17:36:08 +00:00
|
|
|
theme: ThemeType;
|
2022-02-23 18:48:40 +00:00
|
|
|
}): StateType {
|
|
|
|
const items = window.storage.getItemsState();
|
|
|
|
|
|
|
|
const convoCollection = window.getConversations();
|
|
|
|
const formattedConversations = convoCollection.map(conversation =>
|
|
|
|
conversation.format()
|
|
|
|
);
|
|
|
|
const ourNumber = window.textsecure.storage.user.getNumber();
|
2023-08-10 16:43:33 +00:00
|
|
|
const ourAci = window.textsecure.storage.user.getAci();
|
|
|
|
const ourPni = window.textsecure.storage.user.getPni();
|
2022-02-23 18:48:40 +00:00
|
|
|
const ourConversationId =
|
|
|
|
window.ConversationController.getOurConversationId();
|
|
|
|
const ourDeviceId = window.textsecure.storage.user.getDeviceId();
|
|
|
|
|
2023-01-13 00:24:59 +00:00
|
|
|
let osName: 'windows' | 'macos' | 'linux' | undefined;
|
|
|
|
|
|
|
|
if (OS.isWindows()) {
|
|
|
|
osName = 'windows';
|
|
|
|
} else if (OS.isMacOS()) {
|
|
|
|
osName = 'macos';
|
|
|
|
} else if (OS.isLinux()) {
|
|
|
|
osName = 'linux';
|
|
|
|
}
|
|
|
|
|
2022-02-23 18:48:40 +00:00
|
|
|
return {
|
|
|
|
accounts: accounts(),
|
|
|
|
app: app(),
|
|
|
|
audioPlayer: audioPlayer(),
|
|
|
|
audioRecorder: audioRecorder(),
|
|
|
|
badges,
|
2023-08-09 00:53:06 +00:00
|
|
|
callHistory: {
|
|
|
|
...callHistory(),
|
|
|
|
callHistoryByCallId: makeLookup(callsHistory, 'callId'),
|
2024-03-04 22:26:49 +00:00
|
|
|
unreadCount: callsHistoryUnreadCount,
|
2023-08-09 00:53:06 +00:00
|
|
|
},
|
2022-02-23 18:48:40 +00:00
|
|
|
calling: calling(),
|
|
|
|
composer: composer(),
|
|
|
|
conversations: {
|
|
|
|
...conversations(),
|
2023-04-11 03:54:43 +00:00
|
|
|
conversationLookup: makeLookup(formattedConversations, 'id'),
|
|
|
|
conversationsByE164: makeLookup(formattedConversations, 'e164'),
|
2023-08-16 20:54:39 +00:00
|
|
|
conversationsByServiceId: {
|
|
|
|
...makeLookup(formattedConversations, 'serviceId'),
|
2023-04-11 03:54:43 +00:00
|
|
|
...makeLookup(formattedConversations, 'pni'),
|
2022-09-27 20:31:55 +00:00
|
|
|
},
|
2023-04-11 03:54:43 +00:00
|
|
|
conversationsByGroupId: makeLookup(formattedConversations, 'groupId'),
|
|
|
|
conversationsByUsername: makeLookup(formattedConversations, 'username'),
|
2022-02-23 18:48:40 +00:00
|
|
|
},
|
|
|
|
crashReports: crashReports(),
|
|
|
|
emojis: emojis(),
|
|
|
|
expiration: expiration(),
|
|
|
|
globalModals: globalModals(),
|
2023-03-28 20:31:24 +00:00
|
|
|
inbox: inbox(),
|
2022-02-23 18:48:40 +00:00
|
|
|
items,
|
2022-12-10 02:02:22 +00:00
|
|
|
lightbox: lightbox(),
|
2022-02-23 18:48:40 +00:00
|
|
|
linkPreviews: linkPreviews(),
|
2022-12-20 17:50:23 +00:00
|
|
|
mediaGallery: mediaGallery(),
|
2023-08-09 00:53:06 +00:00
|
|
|
nav: nav(),
|
2022-02-23 18:48:40 +00:00
|
|
|
network: network(),
|
|
|
|
preferredReactions: preferredReactions(),
|
|
|
|
safetyNumber: safetyNumber(),
|
|
|
|
search: search(),
|
|
|
|
stickers: stickers(),
|
2022-03-04 21:14:52 +00:00
|
|
|
stories: {
|
|
|
|
...getStoriesEmptyState(),
|
|
|
|
stories,
|
|
|
|
},
|
2022-07-01 00:52:03 +00:00
|
|
|
storyDistributionLists: {
|
|
|
|
...getStoryDistributionListsEmptyState(),
|
|
|
|
distributionLists: storyDistributionLists || [],
|
|
|
|
},
|
2022-07-12 16:41:41 +00:00
|
|
|
toast: getToastEmptyState(),
|
2022-02-23 18:48:40 +00:00
|
|
|
updates: updates(),
|
|
|
|
user: {
|
|
|
|
...user(),
|
2023-01-13 00:24:59 +00:00
|
|
|
attachmentsPath: window.BasePaths.attachments,
|
|
|
|
i18n: window.i18n,
|
2023-03-14 15:55:31 +00:00
|
|
|
interactionMode: getInteractionMode(),
|
2023-01-13 00:24:59 +00:00
|
|
|
isMainWindowFullScreen: mainWindowStats.isFullScreen,
|
|
|
|
isMainWindowMaximized: mainWindowStats.isMaximized,
|
2023-04-20 21:23:19 +00:00
|
|
|
localeMessages: window.i18n.getLocaleMessages(),
|
2023-01-13 00:24:59 +00:00
|
|
|
menuOptions,
|
|
|
|
osName,
|
2023-08-10 16:43:33 +00:00
|
|
|
ourAci,
|
2022-02-23 18:48:40 +00:00
|
|
|
ourConversationId,
|
|
|
|
ourDeviceId,
|
|
|
|
ourNumber,
|
2023-08-10 16:43:33 +00:00
|
|
|
ourPni,
|
2022-02-23 18:48:40 +00:00
|
|
|
platform: window.platform,
|
2023-01-13 00:24:59 +00:00
|
|
|
regionCode: window.storage.get('regionCode'),
|
|
|
|
stickersPath: window.BasePaths.stickers,
|
|
|
|
tempPath: window.BasePaths.temp,
|
2022-02-23 18:48:40 +00:00
|
|
|
theme,
|
|
|
|
version: window.getVersion(),
|
|
|
|
},
|
2022-10-18 17:12:02 +00:00
|
|
|
username: username(),
|
2022-02-23 18:48:40 +00:00
|
|
|
};
|
|
|
|
}
|