From 5252dd40e32ea3db660c66a1a8c298414c5442c7 Mon Sep 17 00:00:00 2001 From: Brice-W Date: Wed, 7 Jul 2021 13:43:33 +1000 Subject: [PATCH] fixes --- js/background.js | 4 ---- js/views/app_view.js | 11 ---------- ts/components/ConversationListItem.tsx | 3 +-- ts/components/LeftPane.tsx | 3 ++- ts/components/session/ActionsPanel.tsx | 22 +------------------ .../conversation/SessionCompositionBox.tsx | 2 +- ts/components/session/menu/Menu.tsx | 6 ++--- ts/state/ducks/SessionTheme.tsx | 3 --- ts/state/ducks/section.tsx | 11 +++++++++- ts/state/selectors/onions.ts | 2 +- ts/state/selectors/section.ts | 3 +-- ts/window.d.ts | 3 --- 12 files changed, 19 insertions(+), 54 deletions(-) diff --git a/js/background.js b/js/background.js index c58986015..0a632e39a 100644 --- a/js/background.js +++ b/js/background.js @@ -297,10 +297,6 @@ window.addEventListener('focus', () => Whisper.Notifications.clear()); window.addEventListener('unload', () => Whisper.Notifications.fastClear()); - window.showResetSessionIdDialog = () => { - appView.showResetSessionIdDialog(); - }; - // Set user's launch count. const prevLaunchCount = window.getSettingValue('launch-count'); const launchCount = !prevLaunchCount ? 1 : prevLaunchCount + 1; diff --git a/js/views/app_view.js b/js/views/app_view.js index ba1432b43..126e920e9 100644 --- a/js/views/app_view.js +++ b/js/views/app_view.js @@ -94,16 +94,5 @@ window.focus(); // FIXME return Promise.resolve(); }, - showResetSessionIdDialog() { - const theme = this.getThemeObject(); - const resetSessionIDDialog = new Whisper.SessionIDResetDialog({ theme }); - - this.el.prepend(resetSessionIDDialog.el); - }, - getThemeObject() { - const themeSettings = storage.get('theme-setting') || 'light'; - const theme = themeSettings === 'light' ? window.lightTheme : window.darkTheme; - return theme; - }, }); })(); diff --git a/ts/components/ConversationListItem.tsx b/ts/components/ConversationListItem.tsx index 545385274..ebdd01aee 100644 --- a/ts/components/ConversationListItem.tsx +++ b/ts/components/ConversationListItem.tsx @@ -28,8 +28,7 @@ import { } from '../state/ducks/conversations'; import { SessionIcon, SessionIconSize, SessionIconType } from './session/icon'; import { useDispatch, useSelector } from 'react-redux'; -import { SectionType } from './session/ActionsPanel'; -import { getTheme } from '../state/selectors/theme'; +import { SectionType } from '../state/ducks/section'; import { getFocusedSection } from '../state/selectors/section'; export interface ConversationListItemProps extends ConversationType { diff --git a/ts/components/LeftPane.tsx b/ts/components/LeftPane.tsx index da5a16129..812298819 100644 --- a/ts/components/LeftPane.tsx +++ b/ts/components/LeftPane.tsx @@ -1,6 +1,6 @@ import React, { useState } from 'react'; -import { ActionsPanel, SectionType } from './session/ActionsPanel'; +import { ActionsPanel } from './session/ActionsPanel'; import { LeftPaneMessageSection } from './session/LeftPaneMessageSection'; import { openConversationExternal } from '../state/ducks/conversations'; @@ -13,6 +13,7 @@ import { useDispatch, useSelector } from 'react-redux'; import { getLeftPaneLists } from '../state/selectors/conversations'; import { getQuery, getSearchResults, isSearching } from '../state/selectors/search'; import { clearSearch, search, updateSearchTerm } from '../state/ducks/search'; +import { SectionType } from '../state/ducks/section'; import { getTheme } from '../state/selectors/theme'; // from https://github.com/bvaughn/react-virtualized/blob/fb3484ed5dcc41bffae8eab029126c0fb8f7abc0/source/List/types.js#L5 diff --git a/ts/components/session/ActionsPanel.tsx b/ts/components/session/ActionsPanel.tsx index 6c32f113d..bae63749c 100644 --- a/ts/components/session/ActionsPanel.tsx +++ b/ts/components/session/ActionsPanel.tsx @@ -30,7 +30,7 @@ import { applyTheme } from '../../state/ducks/theme'; import { getFocusedSection } from '../../state/selectors/section'; import { useInterval } from '../../hooks/useInterval'; import { clearSearch } from '../../state/ducks/search'; -import { showLeftPaneSection } from '../../state/ducks/section'; +import { SectionType, showLeftPaneSection } from '../../state/ducks/section'; import { cleanUpOldDecryptedMedias } from '../../session/crypto/DecryptedAttachmentsManager'; import { getOpenGroupManager } from '../../opengroup/opengroupV2/OpenGroupManagerV2'; @@ -47,16 +47,6 @@ import { ActionPanelOnionStatusLight } from '../OnionStatusPathDialog'; // tslint:disable-next-line: no-import-side-effect no-submodule-imports -export enum SectionType { - Profile, - Message, - Contact, - Channel, - Settings, - Moon, - PathIndicator, -} - const Section = (props: { type: SectionType; avatarPath?: string }) => { const ourNumber = useSelector(getOurNumber); const unreadMessageCount = useSelector(getUnreadMessageCount); @@ -143,15 +133,6 @@ const Section = (props: { type: SectionType; avatarPath?: string }) => { ); }; -const showResetSessionIDDialogIfNeeded = async () => { - const userED25519KeyPairHex = await UserUtils.getUserED25519KeyPair(); - if (userED25519KeyPairHex) { - return; - } - - window.showResetSessionIdDialog(); -}; - const cleanUpMediasInterval = DURATION.MINUTES * 30; const setupTheme = () => { @@ -230,7 +211,6 @@ const doAppStartUp = () => { void setupTheme(); // keep that one to make sure our users upgrade to new sessionIDS - void showResetSessionIDDialogIfNeeded(); void removeAllV1OpenGroups(); // this generates the key to encrypt attachments locally diff --git a/ts/components/session/conversation/SessionCompositionBox.tsx b/ts/components/session/conversation/SessionCompositionBox.tsx index 22df902de..c28e8cd80 100644 --- a/ts/components/session/conversation/SessionCompositionBox.tsx +++ b/ts/components/session/conversation/SessionCompositionBox.tsx @@ -31,10 +31,10 @@ import { getConversationController } from '../../../session/conversations'; import { ConversationType } from '../../../state/ducks/conversations'; import { SessionMemberListItem } from '../SessionMemberListItem'; import autoBind from 'auto-bind'; -import { SectionType } from '../ActionsPanel'; import { SessionSettingCategory } from '../settings/SessionSettings'; import { getMentionsInput } from '../../../state/selectors/mentionsInput'; import { updateConfirmModal } from '../../../state/ducks/modalDialog'; +import { SectionType } from '../../../state/ducks/section'; import { SessionButtonColor } from '../SessionButton'; import { SessionConfirmDialogProps } from '../SessionConfirm'; diff --git a/ts/components/session/menu/Menu.tsx b/ts/components/session/menu/Menu.tsx index 04b90b254..9c4886aab 100644 --- a/ts/components/session/menu/Menu.tsx +++ b/ts/components/session/menu/Menu.tsx @@ -7,6 +7,7 @@ import { Item, Submenu } from 'react-contexify'; import { ConversationNotificationSettingType } from '../../../models/conversation'; import { useDispatch, useSelector } from 'react-redux'; import { changeNickNameModal, updateConfirmModal } from '../../../state/ducks/modalDialog'; +import { SectionType } from '../../../state/ducks/section'; import { getConversationController } from '../../../session/conversations'; import { blockConvoById, @@ -24,7 +25,6 @@ import { unblockConvoById, } from '../../../interactions/conversationInteractions'; import { SessionButtonColor } from '../SessionButton'; -import { SectionType } from '../ActionsPanel'; import { ToastUtils } from '../../../session/utils'; const maxNumberOfPinnedConversations = 5; @@ -132,9 +132,7 @@ export interface PinConversationMenuItemProps { conversationId: string; } -export const getPinConversationMenuItem = ( - conversationId: string -): JSX.Element | null => { +export const getPinConversationMenuItem = (conversationId: string): JSX.Element | null => { const isMessagesSection = useSelector(getFocusedSection) === SectionType.Message; if (isMessagesSection && window.lokiFeatureFlags.enablePinConversations) { const conversation = getConversationController().get(conversationId); diff --git a/ts/state/ducks/SessionTheme.tsx b/ts/state/ducks/SessionTheme.tsx index 3432efc28..6a4c43f93 100644 --- a/ts/state/ducks/SessionTheme.tsx +++ b/ts/state/ducks/SessionTheme.tsx @@ -163,6 +163,3 @@ export const inversedTheme = (theme: DefaultTheme): DefaultTheme => { export const SessionTheme = ({ children, theme }: { children: any; theme: DefaultTheme }) => ( {children} ); - -window.lightTheme = lightTheme; -window.darkTheme = darkTheme; diff --git a/ts/state/ducks/section.tsx b/ts/state/ducks/section.tsx index 3c75a20b2..6c6092cc3 100644 --- a/ts/state/ducks/section.tsx +++ b/ts/state/ducks/section.tsx @@ -1,9 +1,18 @@ -import { SectionType } from '../../components/session/ActionsPanel'; import { SessionSettingCategory } from '../../components/session/settings/SessionSettings'; export const FOCUS_SECTION = 'FOCUS_SECTION'; export const FOCUS_SETTINGS_SECTION = 'FOCUS_SETTINGS_SECTION'; +export enum SectionType { + Profile, + Message, + Contact, + Channel, + Settings, + Moon, + PathIndicator, +} + type FocusSectionActionType = { type: 'FOCUS_SECTION'; payload: SectionType; diff --git a/ts/state/selectors/onions.ts b/ts/state/selectors/onions.ts index 897e8b3ff..6bb0f9693 100644 --- a/ts/state/selectors/onions.ts +++ b/ts/state/selectors/onions.ts @@ -1,9 +1,9 @@ import { createSelector } from 'reselect'; import { StateType } from '../reducer'; -import { SectionType } from '../../components/session/ActionsPanel'; import { OnionState } from '../ducks/onion'; import { Snode } from '../../data/data'; +import { SectionType } from '../../state/ducks/section'; export const getOnionPaths = (state: StateType): OnionState => state.onionPaths; diff --git a/ts/state/selectors/section.ts b/ts/state/selectors/section.ts index 35f5df599..049ad4983 100644 --- a/ts/state/selectors/section.ts +++ b/ts/state/selectors/section.ts @@ -1,8 +1,7 @@ import { createSelector } from 'reselect'; import { StateType } from '../reducer'; -import { SectionStateType } from '../ducks/section'; -import { SectionType } from '../../components/session/ActionsPanel'; +import { SectionStateType, SectionType } from '../ducks/section'; import { SessionSettingCategory } from '../../components/session/settings/SessionSettings'; export const getSection = (state: StateType): SectionStateType => state.section; diff --git a/ts/window.d.ts b/ts/window.d.ts index 9aa831a01..bb39ad709 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -57,7 +57,6 @@ declare global { getSeedNodeList: () => Array | undefined; setPassword: any; setSettingValue: any; - showResetSessionIdDialog: any; storage: any; textsecure: LibTextsecure; toggleLinkPreview: any; @@ -80,8 +79,6 @@ declare global { expired: (boolean) => void; expiredStatus: () => boolean; }; - lightTheme: DefaultTheme; - darkTheme: DefaultTheme; LokiPushNotificationServer: any; globalOnlineStatus: boolean; confirmationDialog: any;