From a44dc50d410a284d9ebe28c56d6a643019d147e2 Mon Sep 17 00:00:00 2001 From: Audric Ackermann Date: Mon, 6 Jan 2025 15:28:04 +1100 Subject: [PATCH] chore: address PR comments --- package.json | 7 ++++--- ts/components/basic/StyledI18nSubText.tsx | 2 +- ts/components/conversation/TimerNotification.tsx | 2 +- .../message/message-item/GroupUpdateMessage.tsx | 2 +- .../conversation/message/reactions/ReactionPopup.tsx | 2 +- ts/components/dialog/SessionConfirm.tsx | 2 +- .../dialog/blockOrUnblock/BlockOrUnblockDialog.tsx | 2 +- ts/components/registration/components/BackButton.tsx | 2 +- ts/interactions/conversationInteractions.ts | 2 +- ts/localization/localeTools.ts | 9 ++++++--- ts/models/groupUpdate.ts | 2 +- ts/models/timerNotifications.ts | 2 +- ts/state/ducks/metaGroups.ts | 6 +++--- ts/util/i18n/functions/getMessage.ts | 2 +- ts/window.d.ts | 2 +- 15 files changed, 25 insertions(+), 21 deletions(-) diff --git a/package.json b/package.json index b974dd5b0..8125e2964 100644 --- a/package.json +++ b/package.json @@ -36,8 +36,8 @@ "start-prod": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron .", "start-prod:pretty": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron . | npx bunyan", "start-dev": "cross-env NODE_ENV=development NODE_APP_INSTANCE=devprod$MULTI electron .", - "build-everything": "python3 --version && yarn clean && yarn protobuf && yarn update-git-info && yarn sass && yarn build:locales-soft && tsc && yarn build:workers", - "build-everything:soft": "python3 --version && yarn clean && yarn protobuf && yarn update-git-info && yarn sass && yarn build:locales-soft && tsc && yarn build:workers", + "build-everything": "yarn print-deps && yarn clean && yarn protobuf && yarn update-git-info && yarn sass && yarn build:locales-soft && tsc && yarn build:workers", + "build-everything:soft": "yarn print-deps && yarn clean && yarn protobuf && yarn update-git-info && yarn sass && yarn build:locales-soft && tsc && yarn build:workers", "build-everything:watch": "yarn clean && yarn protobuf && yarn update-git-info && yarn sass && yarn build:locales-soft && yarn build:workers && yarn tsc -w", "start-dev:pretty": "cross-env NODE_ENV=production NODE_APP_INSTANCE=devprod$MULTI electron . | npx bunyan", "build:workers": "yarn worker:utils && yarn worker:libsession", @@ -60,7 +60,8 @@ "worker:utils": "webpack --config=./utils.worker.config.js", "worker:libsession": "rimraf 'ts/webworker/workers/node/libsession/*.node' && webpack --config=./libsession.worker.config.js", "dedup-yarn-lock": "npx --yes yarn-deduplicate yarn.lock", - "prepare": "husky install" + "prepare": "husky install", + "print-deps": "node -v && python3 --version" }, "dependencies": { "@emoji-mart/data": "^1.1.2", diff --git a/ts/components/basic/StyledI18nSubText.tsx b/ts/components/basic/StyledI18nSubText.tsx index 70c1bb3fa..6a8af7fca 100644 --- a/ts/components/basic/StyledI18nSubText.tsx +++ b/ts/components/basic/StyledI18nSubText.tsx @@ -1,7 +1,7 @@ import styled from 'styled-components'; import { forwardRef } from 'react'; import { Localizer } from './Localizer'; -import { LocalizerComponentPropsObject } from '../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../localization/localeTools'; const StyledI18nSubTextContainer = styled('div')` font-size: var(--font-size-md); diff --git a/ts/components/conversation/TimerNotification.tsx b/ts/components/conversation/TimerNotification.tsx index 23fa18c50..bd8fffb1d 100644 --- a/ts/components/conversation/TimerNotification.tsx +++ b/ts/components/conversation/TimerNotification.tsx @@ -26,7 +26,7 @@ import { Localizer } from '../basic/Localizer'; import { SessionButtonColor } from '../basic/SessionButton'; import { SessionIcon } from '../icon'; import { getTimerNotificationStr } from '../../models/timerNotifications'; -import { LocalizerComponentPropsObject } from '../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../localization/localeTools'; const FollowSettingButton = styled.button` color: var(--primary-color); diff --git a/ts/components/conversation/message/message-item/GroupUpdateMessage.tsx b/ts/components/conversation/message/message-item/GroupUpdateMessage.tsx index 7187d02d6..c7f138ad1 100644 --- a/ts/components/conversation/message/message-item/GroupUpdateMessage.tsx +++ b/ts/components/conversation/message/message-item/GroupUpdateMessage.tsx @@ -19,7 +19,7 @@ import { import { Localizer } from '../../../basic/Localizer'; import { ExpirableReadableMessage } from './ExpirableReadableMessage'; import { NotificationBubble } from './notification-bubble/NotificationBubble'; -import { LocalizerComponentPropsObject } from '../../../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../../../localization/localeTools'; // This component is used to display group updates in the conversation view. diff --git a/ts/components/conversation/message/reactions/ReactionPopup.tsx b/ts/components/conversation/message/reactions/ReactionPopup.tsx index 85561f8fa..23c46a2c4 100644 --- a/ts/components/conversation/message/reactions/ReactionPopup.tsx +++ b/ts/components/conversation/message/reactions/ReactionPopup.tsx @@ -5,7 +5,7 @@ import { PubKey } from '../../../../session/types/PubKey'; import { Localizer } from '../../../basic/Localizer'; import { nativeEmojiData } from '../../../../util/emoji'; -import { LocalizerComponentPropsObject } from '../../../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../../../localization/localeTools'; export type TipPosition = 'center' | 'left' | 'right'; diff --git a/ts/components/dialog/SessionConfirm.tsx b/ts/components/dialog/SessionConfirm.tsx index be6da4866..09c5efd8e 100644 --- a/ts/components/dialog/SessionConfirm.tsx +++ b/ts/components/dialog/SessionConfirm.tsx @@ -12,7 +12,7 @@ import { SpacerLG } from '../basic/Text'; import { SessionSpinner } from '../loading'; import { StyledI18nSubText } from '../basic/StyledI18nSubText'; -import { LocalizerComponentPropsObject } from '../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../localization/localeTools'; export interface SessionConfirmDialogProps { i18nMessage?: LocalizerComponentPropsObject; diff --git a/ts/components/dialog/blockOrUnblock/BlockOrUnblockDialog.tsx b/ts/components/dialog/blockOrUnblock/BlockOrUnblockDialog.tsx index 93c49ec08..bfa7909ae 100644 --- a/ts/components/dialog/blockOrUnblock/BlockOrUnblockDialog.tsx +++ b/ts/components/dialog/blockOrUnblock/BlockOrUnblockDialog.tsx @@ -13,7 +13,7 @@ import { Localizer } from '../../basic/Localizer'; import { SessionButton, SessionButtonColor, SessionButtonType } from '../../basic/SessionButton'; import { StyledModalDescriptionContainer } from '../shared/ModalDescriptionContainer'; import { BlockOrUnblockModalState } from './BlockOrUnblockModalState'; -import { LocalizerComponentPropsObject } from '../../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../../localization/localeTools'; type ModalState = NonNullable; diff --git a/ts/components/registration/components/BackButton.tsx b/ts/components/registration/components/BackButton.tsx index 4c8ec63b7..293ec1ac0 100644 --- a/ts/components/registration/components/BackButton.tsx +++ b/ts/components/registration/components/BackButton.tsx @@ -17,7 +17,7 @@ import { deleteDbLocally } from '../../../util/accountManager'; import { Flex } from '../../basic/Flex'; import { SessionButtonColor } from '../../basic/SessionButton'; import { SessionIconButton } from '../../icon'; -import { LocalizerComponentPropsObject } from '../../../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../../../localization/localeTools'; /** Min height should match the onboarding step with the largest height this prevents the loading spinner from jumping around while still keeping things centered */ const StyledBackButtonContainer = styled(Flex)` diff --git a/ts/interactions/conversationInteractions.ts b/ts/interactions/conversationInteractions.ts index 39fad4de8..997113db6 100644 --- a/ts/interactions/conversationInteractions.ts +++ b/ts/interactions/conversationInteractions.ts @@ -58,7 +58,7 @@ import { GroupPromote } from '../session/utils/job_runners/jobs/GroupPromoteJob' import { MessageSender } from '../session/sending'; import { StoreGroupRequestFactory } from '../session/apis/snode_api/factories/StoreGroupRequestFactory'; import { DURATION } from '../session/constants'; -import { LocalizerComponentPropsObject } from '../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../localization/localeTools'; export async function copyPublicKeyByConvoId(convoId: string) { if (OpenGroupUtils.isOpenGroupV2(convoId)) { diff --git a/ts/localization/localeTools.ts b/ts/localization/localeTools.ts index 23eca9079..c28c7bd65 100644 --- a/ts/localization/localeTools.ts +++ b/ts/localization/localeTools.ts @@ -57,9 +57,12 @@ export function isPluralToken(token: string): token is PluralLocalizerTokens { return token in pluralsDictionary; } -type TokenWithArgs = { - [K in keyof D]: D[K] extends { args: undefined } | { args: never } ? never : K; -}[keyof D]; +/** + * This type extracts from a dictionary, the keys that have a property 'args' set (i.e. not undefined or never). + */ +type TokenWithArgs = { + [Key in keyof Dict]: Dict[Key] extends { args: undefined } | { args: never } ? never : Key; +}[keyof Dict]; type MergedTokenWithArgs = TokenWithArgs | TokenWithArgs; diff --git a/ts/models/groupUpdate.ts b/ts/models/groupUpdate.ts index 7c1e9766c..1b09367ac 100644 --- a/ts/models/groupUpdate.ts +++ b/ts/models/groupUpdate.ts @@ -1,4 +1,4 @@ -import { LocalizerComponentPropsObject } from '../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../localization/localeTools'; import { ConvoHub } from '../session/conversations'; import { UserUtils } from '../session/utils'; diff --git a/ts/models/timerNotifications.ts b/ts/models/timerNotifications.ts index 43c7186be..6b11a1a7a 100644 --- a/ts/models/timerNotifications.ts +++ b/ts/models/timerNotifications.ts @@ -5,7 +5,7 @@ import { PubKey } from '../session/types'; import { UserUtils } from '../session/utils'; import { TimerOptions } from '../session/disappearing_messages/timerOptions'; import { isLegacyDisappearingModeEnabled } from '../session/disappearing_messages/legacy'; -import { LocalizerComponentPropsObject } from '../localization/localeTools'; +import type { LocalizerComponentPropsObject } from '../localization/localeTools'; export function getTimerNotificationStr({ expirationMode, diff --git a/ts/state/ducks/metaGroups.ts b/ts/state/ducks/metaGroups.ts index ad1bb38df..8a5a9def7 100644 --- a/ts/state/ducks/metaGroups.ts +++ b/ts/state/ducks/metaGroups.ts @@ -577,7 +577,7 @@ async function handleMemberAddedFromUI({ throw new Error('tried to make change to group but we do not have the admin secret key'); } - await checkWeAreAdminOrThrow(groupPk, 'handleMemberAddedFromUIOrNot'); + await checkWeAreAdminOrThrow(groupPk, 'handleMemberAddedFromUI'); const { withHistory, withoutHistory, convo, us } = validateMemberAddChange({ withHistory: addMembersWithHistory, @@ -675,12 +675,12 @@ async function handleMemberAddedFromUI({ await LibSessionUtil.saveDumpsToDb(groupPk); throw new Error( - 'handleMemberAddedFromUIOrNot: pushChangesToGroupSwarmIfNeeded did not return success' + 'handleMemberAddedFromUI: pushChangesToGroupSwarmIfNeeded did not return success' ); } } catch (e) { window.log.warn( - 'handleNameChangeFromUIOrNot: pushChangesToGroupSwarmIfNeeded failed with:', + 'handleMemberAddedFromUI: pushChangesToGroupSwarmIfNeeded failed with:', e.message ); } diff --git a/ts/util/i18n/functions/getMessage.ts b/ts/util/i18n/functions/getMessage.ts index d0bef4190..4ad09ba29 100644 --- a/ts/util/i18n/functions/getMessage.ts +++ b/ts/util/i18n/functions/getMessage.ts @@ -18,4 +18,4 @@ getMessageDefaultCopy.strippedWithObj = strippedWithObj; getMessageDefaultCopy.getRawMessage = getRawMessage; getMessageDefaultCopy.formatMessageWithArgs = formatMessageWithArgs; -export const getMessage: SetupI18nReturnType = getMessageDefault as SetupI18nReturnType; +export const getMessage: SetupI18nReturnType = getMessageDefaultCopy as SetupI18nReturnType; diff --git a/ts/window.d.ts b/ts/window.d.ts index 705c72dd7..afb228349 100644 --- a/ts/window.d.ts +++ b/ts/window.d.ts @@ -6,7 +6,7 @@ import { Persistor } from 'redux-persist/es/types'; import { PrimaryColorStateType, ThemeStateType } from './themes/constants/colors'; import type { GetMessageArgs, I18nMethods } from './types/localizer'; -import { MergedLocalizerTokens } from './localization/localeTools'; +import type { MergedLocalizerTokens } from './localization/localeTools'; export interface LibTextsecure { messaging: boolean;