From 2bc161d54a79538242374cb4d7d961b7334901da Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 14:47:09 -0500 Subject: [PATCH 01/37] WIP --- shared/constants/archive/util.tsx | 16 ---------------- shared/constants/init/shared.tsx | 15 +++++++++++++-- shared/settings/archive/index.tsx | 2 +- shared/settings/archive/modal.tsx | 2 +- .../archive/index.tsx => stores/archive.tsx} | 6 +++--- 5 files changed, 18 insertions(+), 23 deletions(-) delete mode 100644 shared/constants/archive/util.tsx rename shared/{constants/archive/index.tsx => stores/archive.tsx} (98%) diff --git a/shared/constants/archive/util.tsx b/shared/constants/archive/util.tsx deleted file mode 100644 index 3be104f15ecb..000000000000 --- a/shared/constants/archive/util.tsx +++ /dev/null @@ -1,16 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import type * as UseArchiveStateType from '../archive' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifySimpleFSSimpleFSArchiveStatusChanged: - case EngineGen.chat1NotifyChatChatArchiveComplete: - case EngineGen.chat1NotifyChatChatArchiveProgress: - { - const {useArchiveState} = require('../archive') as typeof UseArchiveStateType - useArchiveState.getState().dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 8ed40061299a..d3aef1fa49cb 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -3,7 +3,7 @@ import logger from '@/logger' import {serverConfigFileName} from '../platform' import * as T from '../types' import {ignorePromise} from '../utils' -import * as ArchiveUtil from '../archive/util' +import type * as UseArchiveStateType from '@/stores/archive' import * as AutoResetUtil from '../autoreset/util' import * as AvatarUtil from '@/common-adapters/avatar/util' import * as BotsUtil from '../bots/util' @@ -241,8 +241,19 @@ export const initSharedSubscriptions = () => { }) } +// This is to defer loading stores we don't need immediately. export const _onEngineIncoming = (action: EngineGen.Actions) => { - ArchiveUtil.onEngineIncoming(action) + switch (action.type) { + case EngineGen.keybase1NotifySimpleFSSimpleFSArchiveStatusChanged: + case EngineGen.chat1NotifyChatChatArchiveComplete: + case EngineGen.chat1NotifyChatChatArchiveProgress: + { + const {useArchiveState} = require('@/stores/archive') as typeof UseArchiveStateType + useArchiveState.getState().dispatch.onEngineIncomingImpl(action) + } + break + default: + } AutoResetUtil.onEngineIncoming(action) AvatarUtil.onEngineIncoming(action) BotsUtil.onEngineIncoming(action) diff --git a/shared/settings/archive/index.tsx b/shared/settings/archive/index.tsx index 3ec5cf413eee..0ba0edd29d32 100644 --- a/shared/settings/archive/index.tsx +++ b/shared/settings/archive/index.tsx @@ -3,7 +3,7 @@ import * as C from '@/constants' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {formatTimeForConversationList, formatTimeForChat} from '@/util/timestamp' -import {useArchiveState} from '@/constants/archive' +import {useArchiveState} from '@/stores/archive' import * as FS from '@/constants/fs' import {useFSState} from '@/constants/fs' diff --git a/shared/settings/archive/modal.tsx b/shared/settings/archive/modal.tsx index d74739fcb969..4b12731e4d79 100644 --- a/shared/settings/archive/modal.tsx +++ b/shared/settings/archive/modal.tsx @@ -4,7 +4,7 @@ import * as C from '@/constants' import type * as T from '@/constants/types' import {pickSave} from '@/util/pick-files' import * as FsCommon from '@/fs/common' -import {useArchiveState} from '@/constants/archive' +import {useArchiveState} from '@/stores/archive' import {settingsArchiveTab} from '@/constants/settings' import {useCurrentUserState} from '@/constants/current-user' import {getConvoState} from '@/constants/chat2/convostate' diff --git a/shared/constants/archive/index.tsx b/shared/stores/archive.tsx similarity index 98% rename from shared/constants/archive/index.tsx rename to shared/stores/archive.tsx index dd132f0e3133..450e6b3ec185 100644 --- a/shared/constants/archive/index.tsx +++ b/shared/stores/archive.tsx @@ -1,11 +1,11 @@ -import * as T from '../types' +import * as T from '../constants/types' import * as Z from '@/util/zustand' -import {ignorePromise} from '../utils' +import {ignorePromise} from '../constants/utils' import * as EngineGen from '@/actions/engine-gen-gen' import {pathToRPCPath} from '@/constants/fs/util' import {formatTimeForPopup} from '@/util/timestamp' import {uint8ArrayToHex} from 'uint8array-extras' -import {isMobile} from '../platform' +import {isMobile} from '../constants/platform' type ChatJob = { id: string From 88164fe928165af6f034c8a92ec927d0256221ca Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 14:54:37 -0500 Subject: [PATCH 02/37] WIP --- shared/chat/conversation/bot/install.tsx | 2 +- shared/chat/conversation/bot/search.tsx | 2 +- shared/chat/conversation/bot/team-picker.tsx | 2 +- shared/chat/conversation/info-panel/bot.tsx | 2 +- shared/constants/autoreset/util.tsx | 13 -------- shared/constants/bots/util.tsx | 30 ----------------- shared/constants/devices/util.tsx | 21 ------------ shared/constants/init/shared.tsx | 32 ++++++++++++++++--- shared/devices/add-device.tsx | 2 +- shared/devices/device-icon.tsx | 2 +- shared/devices/device-page.tsx | 2 +- shared/devices/device-revoke.tsx | 2 +- shared/devices/index.tsx | 2 +- shared/devices/nav-header.tsx | 2 +- shared/devices/row.tsx | 2 +- .../recover-password/prompt-reset-shared.tsx | 2 +- shared/login/reset/confirm.tsx | 2 +- shared/login/reset/modal.tsx | 2 +- shared/login/reset/password-enter.tsx | 2 +- shared/login/reset/password-known.tsx | 2 +- shared/login/reset/waiting.tsx | 2 +- shared/profile/user/actions/index.tsx | 2 +- shared/provision/code-page/container.tsx | 2 +- shared/provision/error.tsx | 2 +- .../select-other-device-connected.tsx | 2 +- shared/provision/set-public-name.tsx | 2 +- shared/provision/troubleshooting.tsx | 2 +- shared/provision/username-or-email.tsx | 2 +- .../index.tsx => stores/autoreset.tsx} | 13 +++----- .../bots/index.tsx => stores/bots.tsx} | 24 ++++++++++---- .../devices/index.tsx => stores/devices.tsx} | 11 ++----- shared/teams/channel/index.tsx | 2 +- shared/teams/team/index.tsx | 2 +- shared/teams/team/rows/bot-row/bot.tsx | 2 +- 34 files changed, 79 insertions(+), 119 deletions(-) delete mode 100644 shared/constants/autoreset/util.tsx delete mode 100644 shared/constants/bots/util.tsx delete mode 100644 shared/constants/devices/util.tsx rename shared/{constants/autoreset/index.tsx => stores/autoreset.tsx} (91%) rename shared/{constants/bots/index.tsx => stores/bots.tsx} (90%) rename shared/{constants/devices/index.tsx => stores/devices.tsx} (90%) diff --git a/shared/chat/conversation/bot/install.tsx b/shared/chat/conversation/bot/install.tsx index c1e24c343beb..9e96801ec38e 100644 --- a/shared/chat/conversation/bot/install.tsx +++ b/shared/chat/conversation/bot/install.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import ChannelPicker from './channel-picker' import openURL from '@/util/open-url' import * as T from '@/constants/types' -import {useBotsState} from '@/constants/bots' +import {useBotsState} from '@/stores/bots' import {useAllChannelMetas} from '@/teams/common/channel-hooks' const RestrictedItem = '---RESTRICTED---' diff --git a/shared/chat/conversation/bot/search.tsx b/shared/chat/conversation/bot/search.tsx index 3a3dd2ab36f3..eb7e97b220b7 100644 --- a/shared/chat/conversation/bot/search.tsx +++ b/shared/chat/conversation/bot/search.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import debounce from 'lodash/debounce' import type * as T from '@/constants/types' import {Bot} from '../info-panel/bot' -import {getFeaturedSorted, useBotsState} from '@/constants/bots' +import {getFeaturedSorted, useBotsState} from '@/stores/bots' type Props = {teamID?: T.Teams.TeamID} diff --git a/shared/chat/conversation/bot/team-picker.tsx b/shared/chat/conversation/bot/team-picker.tsx index 23c869eeff54..b62b38be91c9 100644 --- a/shared/chat/conversation/bot/team-picker.tsx +++ b/shared/chat/conversation/bot/team-picker.tsx @@ -5,7 +5,7 @@ import * as T from '@/constants/types' import {Avatars, TeamAvatar} from '@/chat/avatars' import debounce from 'lodash/debounce' import logger from '@/logger' -import {useBotsState} from '@/constants/bots' +import {useBotsState} from '@/stores/bots' type Props = {botUsername: string} diff --git a/shared/chat/conversation/info-panel/bot.tsx b/shared/chat/conversation/info-panel/bot.tsx index 9acfef03a51a..5786c496280f 100644 --- a/shared/chat/conversation/info-panel/bot.tsx +++ b/shared/chat/conversation/info-panel/bot.tsx @@ -4,7 +4,7 @@ import * as Teams from '@/constants/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' -import {getFeaturedSorted, useBotsState} from '@/constants/bots' +import {getFeaturedSorted, useBotsState} from '@/stores/bots' import {useUsersState} from '@/constants/users' type AddToChannelProps = { diff --git a/shared/constants/autoreset/util.tsx b/shared/constants/autoreset/util.tsx deleted file mode 100644 index ccaa494f61a0..000000000000 --- a/shared/constants/autoreset/util.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyBadgesBadgeState: - { - storeRegistry.getState('autoreset').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/bots/util.tsx b/shared/constants/bots/util.tsx deleted file mode 100644 index 1af60048ec8d..000000000000 --- a/shared/constants/bots/util.tsx +++ /dev/null @@ -1,30 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import type * as T from '../types' -import {storeRegistry} from '../store-registry' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: - { - storeRegistry.getState('bots').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} - - -export const getFeaturedSorted = ( - featuredBotsMap: ReadonlyMap -): Array => { - const featured = [...featuredBotsMap.values()] - featured.sort((a: T.RPCGen.FeaturedBot, b: T.RPCGen.FeaturedBot) => { - if (a.rank < b.rank) { - return 1 - } else if (a.rank > b.rank) { - return -1 - } - return 0 - }) - return featured -} diff --git a/shared/constants/devices/util.tsx b/shared/constants/devices/util.tsx deleted file mode 100644 index 23b3694282b6..000000000000 --- a/shared/constants/devices/util.tsx +++ /dev/null @@ -1,21 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - -let loaded = false - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyBadgesBadgeState: - { - const {badgeState} = action.payload.params - const {newDevices, revokedDevices} = badgeState - const hasValue = (newDevices?.length ?? 0) + (revokedDevices?.length ?? 0) > 0 - if (loaded || hasValue) { - loaded = true - storeRegistry.getState('devices').dispatch.onEngineIncomingImpl(action) - } - } - break - default: - } -} diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index d3aef1fa49cb..505793a84861 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -4,9 +4,9 @@ import {serverConfigFileName} from '../platform' import * as T from '../types' import {ignorePromise} from '../utils' import type * as UseArchiveStateType from '@/stores/archive' -import * as AutoResetUtil from '../autoreset/util' +import type * as UseAutoResetStateType from '@/stores/autoreset' import * as AvatarUtil from '@/common-adapters/avatar/util' -import * as BotsUtil from '../bots/util' +import type * as UseBotsStateType from '@/stores/bots' import {useChatState} from '../chat2' import {getSelectedConversation} from '../chat2/common' import * as ChatUtil from '../chat2/util' @@ -35,6 +35,7 @@ import * as UsersUtil from '../users/util' import {useWhatsNewState} from '../whats-new' let _emitStartupOnLoadDaemonConnectedOnce = false +let _devicesLoaded = false export const onEngineConnected = () => { ChatUtil.onEngineConnected() @@ -252,15 +253,36 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { useArchiveState.getState().dispatch.onEngineIncomingImpl(action) } break + case EngineGen.keybase1NotifyBadgesBadgeState: + { + const {useAutoResetState} = require('@/stores/autoreset') as typeof UseAutoResetStateType + useAutoResetState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: + { + const {useBotsState} = require('@/stores/bots') as typeof UseBotsStateType + useBotsState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.keybase1NotifyBadgesBadgeState: + { + const {badgeState} = action.payload.params + const {newDevices, revokedDevices} = badgeState + const hasValue = (newDevices?.length ?? 0) + (revokedDevices?.length ?? 0) > 0 + if (_devicesLoaded || hasValue) { + _devicesLoaded = true + const {useDevicesState} = require('@/stores/devices') as typeof UseDevicesStateType + useDevicesState.getState().dispatch.onEngineIncomingImpl(action) + } + } + break default: } - AutoResetUtil.onEngineIncoming(action) AvatarUtil.onEngineIncoming(action) - BotsUtil.onEngineIncoming(action) ChatUtil.onEngineIncoming(action) useConfigState.getState().dispatch.onEngineIncoming(action) DeepLinksUtil.onEngineIncoming(action) - DevicesUtil.onEngineIncoming(action) FollowerUtil.onEngineIncoming(action) FSUtil.onEngineIncoming(action) GitUtil.onEngineIncoming(action) diff --git a/shared/devices/add-device.tsx b/shared/devices/add-device.tsx index 3b5726f11013..22d773f2001b 100644 --- a/shared/devices/add-device.tsx +++ b/shared/devices/add-device.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as React from 'react' import * as Kb from '@/common-adapters' import {useProvisionState} from '@/constants/provision' diff --git a/shared/devices/device-icon.tsx b/shared/devices/device-icon.tsx index 0121619b3fd5..a5b5135d2151 100644 --- a/shared/devices/device-icon.tsx +++ b/shared/devices/device-icon.tsx @@ -1,5 +1,5 @@ import type * as Provision from '@/constants/provision' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import type {IconStyle} from '@/common-adapters/icon' diff --git a/shared/devices/device-page.tsx b/shared/devices/device-page.tsx index dff22308c890..f270c62a1b27 100644 --- a/shared/devices/device-page.tsx +++ b/shared/devices/device-page.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' diff --git a/shared/devices/device-revoke.tsx b/shared/devices/device-revoke.tsx index 0d4ead70adde..26f9a09bb95d 100644 --- a/shared/devices/device-revoke.tsx +++ b/shared/devices/device-revoke.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import {useConfigState} from '@/constants/config' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/devices/index.tsx b/shared/devices/index.tsx index ebef2b008e50..4df196248347 100644 --- a/shared/devices/index.tsx +++ b/shared/devices/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' import DeviceRow, {NewContext} from './row' diff --git a/shared/devices/nav-header.tsx b/shared/devices/nav-header.tsx index 2176976bb9c3..364563a9b963 100644 --- a/shared/devices/nav-header.tsx +++ b/shared/devices/nav-header.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import type * as DevicesType from '@/constants/devices' +import type * as DevicesType from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/devices/row.tsx b/shared/devices/row.tsx index 5a384bbb9d81..3817ce3ef759 100644 --- a/shared/devices/row.tsx +++ b/shared/devices/row.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' import DeviceIcon from './device-icon' diff --git a/shared/login/recover-password/prompt-reset-shared.tsx b/shared/login/recover-password/prompt-reset-shared.tsx index da223aa06338..7107a4dc8cf2 100644 --- a/shared/login/recover-password/prompt-reset-shared.tsx +++ b/shared/login/recover-password/prompt-reset-shared.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' diff --git a/shared/login/reset/confirm.tsx b/shared/login/reset/confirm.tsx index 5ce7f9b7d53e..50279d56446c 100644 --- a/shared/login/reset/confirm.tsx +++ b/shared/login/reset/confirm.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/login/reset/modal.tsx b/shared/login/reset/modal.tsx index 3aa3e2b5ef66..9e3e48bd8db4 100644 --- a/shared/login/reset/modal.tsx +++ b/shared/login/reset/modal.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import * as Kb from '@/common-adapters' import {formatDurationForAutoreset} from '@/util/timestamp' diff --git a/shared/login/reset/password-enter.tsx b/shared/login/reset/password-enter.tsx index c749c5f801e6..010a4cdaf290 100644 --- a/shared/login/reset/password-enter.tsx +++ b/shared/login/reset/password-enter.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen} from '@/signup/common' diff --git a/shared/login/reset/password-known.tsx b/shared/login/reset/password-known.tsx index c606206718b4..f955e6b7d183 100644 --- a/shared/login/reset/password-known.tsx +++ b/shared/login/reset/password-known.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen} from '@/signup/common' diff --git a/shared/login/reset/waiting.tsx b/shared/login/reset/waiting.tsx index 9dea7f219397..adf2b26d7ace 100644 --- a/shared/login/reset/waiting.tsx +++ b/shared/login/reset/waiting.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import {SignupScreen} from '@/signup/common' import {addTicker, removeTicker} from '@/util/second-timer' import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import {useSafeNavigation} from '@/util/safe-navigation' import {formatDurationForAutoreset as formatDuration} from '@/util/timestamp' diff --git a/shared/profile/user/actions/index.tsx b/shared/profile/user/actions/index.tsx index 5695e6e9051c..bdc2ef2a0fda 100644 --- a/shared/profile/user/actions/index.tsx +++ b/shared/profile/user/actions/index.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import FollowButton from './follow-button' import ChatButton from '@/chat/chat-button' -import {useBotsState} from '@/constants/bots' +import {useBotsState} from '@/stores/bots' import {useTrackerState} from '@/constants/tracker2' import * as FS from '@/constants/fs' import {useFollowerState} from '@/constants/followers' diff --git a/shared/provision/code-page/container.tsx b/shared/provision/code-page/container.tsx index bc731a76d534..6b0e80c52254 100644 --- a/shared/provision/code-page/container.tsx +++ b/shared/provision/code-page/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as React from 'react' import * as Kb from '@/common-adapters' import QRImage from './qr-image' diff --git a/shared/provision/error.tsx b/shared/provision/error.tsx index 93125fdfb30b..f25a682e54be 100644 --- a/shared/provision/error.tsx +++ b/shared/provision/error.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as Kb from '@/common-adapters' import type * as React from 'react' import LoginContainer from '../login/forms/container' diff --git a/shared/provision/select-other-device-connected.tsx b/shared/provision/select-other-device-connected.tsx index 6f1baa6a45cc..4ff101b40ee9 100644 --- a/shared/provision/select-other-device-connected.tsx +++ b/shared/provision/select-other-device-connected.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import {useSafeSubmit} from '@/util/safe-submit' import SelectOtherDevice from './select-other-device' diff --git a/shared/provision/set-public-name.tsx b/shared/provision/set-public-name.tsx index d25bc7c81f22..d99fde018b10 100644 --- a/shared/provision/set-public-name.tsx +++ b/shared/provision/set-public-name.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import {useSafeSubmit} from '@/util/safe-submit' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/provision/troubleshooting.tsx b/shared/provision/troubleshooting.tsx index 0f00a0cc0e8b..b1b65fcd566b 100644 --- a/shared/provision/troubleshooting.tsx +++ b/shared/provision/troubleshooting.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Devices from '@/constants/devices' +import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {useProvisionState} from '@/constants/provision' diff --git a/shared/provision/username-or-email.tsx b/shared/provision/username-or-email.tsx index abf8e1800685..f9e69919dbd7 100644 --- a/shared/provision/username-or-email.tsx +++ b/shared/provision/username-or-email.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as AutoReset from '@/constants/autoreset' +import * as AutoReset from '@/stores/autoreset' import {useSignupState} from '@/constants/signup' import {useSafeSubmit} from '@/util/safe-submit' import * as T from '@/constants/types' diff --git a/shared/constants/autoreset/index.tsx b/shared/stores/autoreset.tsx similarity index 91% rename from shared/constants/autoreset/index.tsx rename to shared/stores/autoreset.tsx index f1d7ed2efaa5..ba72bf82ba3c 100644 --- a/shared/constants/autoreset/index.tsx +++ b/shared/stores/autoreset.tsx @@ -1,12 +1,12 @@ import * as Z from '@/util/zustand' -import {ignorePromise} from '../utils' -import * as S from '../strings' +import {ignorePromise} from '@/constants/utils' +import * as S from '@/constants/strings' import * as T from '@/constants/types' import * as EngineGen from '@/actions/engine-gen-gen' import logger from '@/logger' import {RPCError} from '@/util/errors' -import {navigateAppend, navUpToScreen} from '../router2/util' -import {storeRegistry} from '../store-registry' +import {navigateAppend, navUpToScreen} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' type Store = T.Immutable<{ active: boolean @@ -61,15 +61,10 @@ export const useAutoResetState = Z.createZustand((set, get) => { logger.error('Error in CancelAutoreset', error) switch (error.code) { case T.RPCGen.StatusCode.scnosession: - // We got logged out because we were revoked (which might have been - // becase the reset was completed and this device wasn't notified). return undefined case T.RPCGen.StatusCode.scnotfound: - // "User not in autoreset queue." - // do nothing, fall out of the catch block to cancel reset modal. break default: - // Any other error - display a red bar in the modal. { const desc = error.desc set(s => { diff --git a/shared/constants/bots/index.tsx b/shared/stores/bots.tsx similarity index 90% rename from shared/constants/bots/index.tsx rename to shared/stores/bots.tsx index beb76b45a4d4..6a65ba660878 100644 --- a/shared/constants/bots/index.tsx +++ b/shared/stores/bots.tsx @@ -1,8 +1,8 @@ -import * as T from '../types' +import * as T from '@/constants/types' import * as EngineGen from '@/actions/engine-gen-gen' import * as Z from '@/util/zustand' -import {ignorePromise, RPCError, isNetworkErr} from '../utils' -import * as S from '../strings' +import {ignorePromise, RPCError, isNetworkErr} from '@/constants/utils' +import * as S from '@/constants/strings' import logger from '@/logger' type BotSearchResults = { @@ -14,7 +14,7 @@ type Store = T.Immutable<{ featuredBotsPage: number featuredBotsLoaded: boolean featuredBotsMap: Map - botSearchResults: Map // Keyed so that we never show results that don't match the user's input (e.g. outdated results) + botSearchResults: Map }> const initialStore: Store = { @@ -136,7 +136,6 @@ export const useBotsState = Z.createZustand((set, get) => { query, }) if (!bots || bots.length === 0) { - // don't do anything with a bad response from rpc return } get().dispatch.updateFeaturedBots(bots) @@ -183,4 +182,17 @@ export const useBotsState = Z.createZustand((set, get) => { } }) -export {getFeaturedSorted} from './util' +export const getFeaturedSorted = ( + featuredBotsMap: ReadonlyMap +): Array => { + const featured = [...featuredBotsMap.values()] + featured.sort((a: T.RPCGen.FeaturedBot, b: T.RPCGen.FeaturedBot) => { + if (a.rank < b.rank) { + return 1 + } else if (a.rank > b.rank) { + return -1 + } + return 0 + }) + return featured +} diff --git a/shared/constants/devices/index.tsx b/shared/stores/devices.tsx similarity index 90% rename from shared/constants/devices/index.tsx rename to shared/stores/devices.tsx index 61608a6b712f..7012413b7337 100644 --- a/shared/constants/devices/index.tsx +++ b/shared/stores/devices.tsx @@ -1,8 +1,8 @@ import * as React from 'react' import * as Z from '@/util/zustand' -import * as S from '../strings' -import {ignorePromise, updateImmerMap} from '../utils' -import * as T from '../types' +import * as S from '@/constants/strings' +import {ignorePromise, updateImmerMap} from '@/constants/utils' +import * as T from '@/constants/types' import * as EngineGen from '@/actions/engine-gen-gen' import debounce from 'lodash/debounce' @@ -110,10 +110,6 @@ export const useRevokedDeviceCounts = () => { return [...ds.values()].reduce((c, v) => (v.revokedAt ? c + 1 : c), 0) } -// Icons are numbered 1-10, so this focuses on mapping -// Device -> [1, 10] -// We split devices by type and order them by creation time. Then, we use (index mod 10) -// as the background # export const numBackgrounds = 10 export const useDeviceIconNumber = (deviceID: T.Devices.DeviceID) => { @@ -124,7 +120,6 @@ export const useDeviceIconNumber = (deviceID: T.Devices.DeviceID) => { export const useNextDeviceIconNumber = () => { const dm = useDevicesState(s => s.deviceMap) const next = React.useMemo(() => { - // Find the max device number and add one (+ one more since these are 1-indexed) const result = {backup: 1, desktop: 1, mobile: 1} dm.forEach(device => { if (device.deviceNumberOfType >= result[device.type]) { diff --git a/shared/teams/channel/index.tsx b/shared/teams/channel/index.tsx index 0bad5f015636..a23d5d1b52ae 100644 --- a/shared/teams/channel/index.tsx +++ b/shared/teams/channel/index.tsx @@ -15,7 +15,7 @@ import ChannelMemberRow from './rows' import BotRow from '../team/rows/bot-row/bot' import SettingsList from '../../chat/conversation/info-panel/settings' import EmptyRow from '../team/rows/empty-row' -import {useBotsState} from '@/constants/bots' +import {useBotsState} from '@/stores/bots' import {useUsersState} from '@/constants/users' export type OwnProps = { diff --git a/shared/teams/team/index.tsx b/shared/teams/team/index.tsx index 0d83779ee857..d4b330a2af9d 100644 --- a/shared/teams/team/index.tsx +++ b/shared/teams/team/index.tsx @@ -18,7 +18,7 @@ import { type Section, type Item, } from './rows' -import {useBotsState} from '@/constants/bots' +import {useBotsState} from '@/stores/bots' type Props = { teamID: T.Teams.TeamID diff --git a/shared/teams/team/rows/bot-row/bot.tsx b/shared/teams/team/rows/bot-row/bot.tsx index a6fb1ef29367..59e55fd216b8 100644 --- a/shared/teams/team/rows/bot-row/bot.tsx +++ b/shared/teams/team/rows/bot-row/bot.tsx @@ -4,7 +4,7 @@ import * as Teams from '@/constants/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import BotMenu from './bot-menu' -import {useBotsState} from '@/constants/bots' +import {useBotsState} from '@/stores/bots' import {useTrackerState} from '@/constants/tracker2' import {useProfileState} from '@/constants/profile' From 11804c90f90180308d8deb4fd5332e235634b094 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:01:19 -0500 Subject: [PATCH 03/37] WIP --- shared/constants/init/shared.tsx | 21 +++++------ shared/constants/store-registry.tsx | 57 +++++++++++++++-------------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 505793a84861..c6adf5cde328 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -1,10 +1,11 @@ -import type * as EngineGen from '@/actions/engine-gen-gen' +import * as EngineGen from '@/actions/engine-gen-gen' import logger from '@/logger' import {serverConfigFileName} from '../platform' import * as T from '../types' import {ignorePromise} from '../utils' import type * as UseArchiveStateType from '@/stores/archive' import type * as UseAutoResetStateType from '@/stores/autoreset' +import type * as UseDevicesStateType from '@/stores/devices' import * as AvatarUtil from '@/common-adapters/avatar/util' import type * as UseBotsStateType from '@/stores/bots' import {useChatState} from '../chat2' @@ -15,7 +16,6 @@ import {useCurrentUserState} from '../current-user' import {useDaemonState} from '../daemon' import {useDarkModeState} from '../darkmode' import * as DeepLinksUtil from '../deeplinks/util' -import * as DevicesUtil from '../devices/util' import * as FollowerUtil from '../followers/util' import * as FSUtil from '../fs/util' import * as GitUtil from '../git/util' @@ -257,16 +257,7 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { { const {useAutoResetState} = require('@/stores/autoreset') as typeof UseAutoResetStateType useAutoResetState.getState().dispatch.onEngineIncomingImpl(action) - } - break - case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: - { - const {useBotsState} = require('@/stores/bots') as typeof UseBotsStateType - useBotsState.getState().dispatch.onEngineIncomingImpl(action) - } - break - case EngineGen.keybase1NotifyBadgesBadgeState: - { + const {badgeState} = action.payload.params const {newDevices, revokedDevices} = badgeState const hasValue = (newDevices?.length ?? 0) + (revokedDevices?.length ?? 0) > 0 @@ -277,6 +268,12 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } } break + case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: + { + const {useBotsState} = require('@/stores/bots') as typeof UseBotsStateType + useBotsState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 1d04affa5e76..d7fac135fec0 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -1,33 +1,36 @@ // used to allow non-circular cross-calls between stores // ONLY for zustand stores import type * as T from './types' -import type * as TBType from './team-building' -import type * as ConvoStateType from './chat2/convostate' -import type {ConvoState} from './chat2/convostate' -import type {State as AutoResetState, useAutoResetState} from './autoreset' -import type {State as BotsState, useBotsState} from './bots' -import type {State as ChatState, useChatState} from './chat2' -import type {State as DaemonState, useDaemonState} from './daemon' -import type {State as DevicesState, useDevicesState} from './devices' -import type {State as FSState, useFSState} from './fs' -import type {State as GitState, useGitState} from './git' -import type {State as NotificationsState, useNotifState} from './notifications' -import type {State as PeopleState, usePeopleState} from './people' -import type {State as ProfileState, useProfileState} from './profile' -import type {State as ProvisionState, useProvisionState} from './provision' -import type {State as PushState, usePushState} from './push' -import type {State as RecoverPasswordState, useState as useRecoverPasswordState} from './recover-password' -import type {State as SettingsState, useSettingsState} from './settings' -import type {State as SettingsChatState, useSettingsChatState} from './settings-chat' -import type {State as SettingsContactsState, useSettingsContactsState} from './settings-contacts' -import type {State as SettingsEmailState, useSettingsEmailState} from './settings-email' -import type {State as SettingsPasswordState, usePWState} from './settings-password' -import type {State as SettingsPhoneState, useSettingsPhoneState} from './settings-phone' -import type {State as SignupState, useSignupState} from './signup' -import type {State as TeamsState, useTeamsState} from './teams' -import type {State as Tracker2State, useTrackerState} from './tracker2' -import type {State as UnlockFoldersState, useUnlockFoldersState} from './unlock-folders' -import type {State as UsersState, useUsersState} from './users' +import type * as TBType from '@/constants/team-building' +import type * as ConvoStateType from '@/constants/chat2/convostate' +import type {ConvoState} from '@/constants/chat2/convostate' +import type {State as AutoResetState, useAutoResetState} from '@/stores/autoreset' +import type {State as BotsState, useBotsState} from '@/stores/bots' +import type {State as ChatState, useChatState} from '@/constants/chat2' +import type {State as DaemonState, useDaemonState} from '@/constants/daemon' +import type {State as DevicesState, useDevicesState} from '@/stores/devices' +import type {State as FSState, useFSState} from '@/constants/fs' +import type {State as GitState, useGitState} from '@/constants/git' +import type {State as NotificationsState, useNotifState} from '@/constants/notifications' +import type {State as PeopleState, usePeopleState} from '@/constants/people' +import type {State as ProfileState, useProfileState} from '@/constants/profile' +import type {State as ProvisionState, useProvisionState} from '@/constants/provision' +import type {State as PushState, usePushState} from '@/constants/push' +import type { + State as RecoverPasswordState, + useState as useRecoverPasswordState, +} from '@/constants/recover-password' +import type {State as SettingsState, useSettingsState} from '@/constants/settings' +import type {State as SettingsChatState, useSettingsChatState} from '@/constants/settings-chat' +import type {State as SettingsContactsState, useSettingsContactsState} from '@/constants/settings-contacts' +import type {State as SettingsEmailState, useSettingsEmailState} from '@/constants/settings-email' +import type {State as SettingsPasswordState, usePWState} from '@/constants/settings-password' +import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/constants/settings-phone' +import type {State as SignupState, useSignupState} from '@/constants/signup' +import type {State as TeamsState, useTeamsState} from '@/constants/teams' +import type {State as Tracker2State, useTrackerState} from '@/constants/tracker2' +import type {State as UnlockFoldersState, useUnlockFoldersState} from '@/constants/unlock-folders' +import type {State as UsersState, useUsersState} from '@/constants/users' type StoreName = | 'autoreset' From 5385d0eec5b5cee2c8c0ec74d1e44796aefaefff Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:07:01 -0500 Subject: [PATCH 04/37] WIP --- shared/constants/store-registry.tsx | 6 +++--- shared/devices/nav-header.tsx | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index d7fac135fec0..e7dcf4be408f 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -117,11 +117,11 @@ class StoreRegistry { /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */ switch (storeName) { case 'autoreset': { - const {useAutoResetState} = require('./autoreset') + const {useAutoResetState} = require('../stores/autoreset') return useAutoResetState } case 'bots': { - const {useBotsState} = require('./bots') + const {useBotsState} = require('../stores/bots') return useBotsState } case 'chat': { @@ -133,7 +133,7 @@ class StoreRegistry { return useDaemonState } case 'devices': { - const {useDevicesState} = require('./devices') + const {useDevicesState} = require('../stores/devices') return useDevicesState } case 'fs': { diff --git a/shared/devices/nav-header.tsx b/shared/devices/nav-header.tsx index 364563a9b963..66506b11fbe8 100644 --- a/shared/devices/nav-header.tsx +++ b/shared/devices/nav-header.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' export const HeaderTitle = () => { - const Devices = require('@/constants/devices') as typeof DevicesType + const Devices = require('@/stores/devices') as typeof DevicesType const numActive = Devices.useActiveDeviceCounts() const numRevoked = Devices.useRevokedDeviceCounts() return ( From 4d99c7ec19c88ae68815e75a5dc094bcebe829af Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 15:12:22 -0500 Subject: [PATCH 05/37] WIP --- shared/chat/conversation/bottom-banner.tsx | 2 +- shared/common-adapters/avatar/hooks.tsx | 2 +- shared/common-adapters/mention-container.tsx | 2 +- shared/common-adapters/profile-card.tsx | 2 +- shared/common-adapters/usernames.tsx | 2 +- shared/constants/followers/util.tsx | 29 ------------------- shared/constants/init/shared.tsx | 25 ++++++++++++++-- shared/menubar/remote-container.desktop.tsx | 2 +- shared/menubar/remote-proxy.desktop.tsx | 2 +- shared/profile/user/actions/index.tsx | 2 +- shared/profile/user/hooks.tsx | 2 +- shared/settings/contacts-joined.tsx | 2 +- .../index.tsx => stores/followers.tsx} | 1 - shared/team-building/list-body.tsx | 2 +- shared/tracker2/bio.tsx | 2 +- shared/tracker2/remote-container.desktop.tsx | 2 +- shared/tracker2/remote-proxy.desktop.tsx | 2 +- 17 files changed, 37 insertions(+), 46 deletions(-) delete mode 100644 shared/constants/followers/util.tsx rename shared/{constants/followers/index.tsx => stores/followers.tsx} (92%) diff --git a/shared/chat/conversation/bottom-banner.tsx b/shared/chat/conversation/bottom-banner.tsx index 3b845cd09e92..68cff5406824 100644 --- a/shared/chat/conversation/bottom-banner.tsx +++ b/shared/chat/conversation/bottom-banner.tsx @@ -6,7 +6,7 @@ import _openSMS from '@/util/sms' import {assertionToDisplay} from '@/common-adapters/usernames' import type {Props as TextProps} from '@/common-adapters/text' import {useUsersState} from '@/constants/users' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' const installMessage = `I sent you encrypted messages on Keybase. You can install it here: https://keybase.io/phone-app` diff --git a/shared/common-adapters/avatar/hooks.tsx b/shared/common-adapters/avatar/hooks.tsx index 0307b138030d..f7fd24ebbb6e 100644 --- a/shared/common-adapters/avatar/hooks.tsx +++ b/shared/common-adapters/avatar/hooks.tsx @@ -8,7 +8,7 @@ import './avatar.css' import type {Props} from '.' import {useColorScheme} from 'react-native' import {useUsersState} from '@/constants/users' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {navToProfile} from '@/constants/router2' export const avatarSizes = [128, 96, 64, 48, 32, 24, 16] as const diff --git a/shared/common-adapters/mention-container.tsx b/shared/common-adapters/mention-container.tsx index 7cd4ab40f54f..107b2535da44 100644 --- a/shared/common-adapters/mention-container.tsx +++ b/shared/common-adapters/mention-container.tsx @@ -3,7 +3,7 @@ import * as Chat from '@/constants/chat2' import Mention, {type OwnProps} from './mention' import {useTrackerState} from '@/constants/tracker2' import {useProfileState} from '@/constants/profile' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' const Container = (ownProps: OwnProps) => { diff --git a/shared/common-adapters/profile-card.tsx b/shared/common-adapters/profile-card.tsx index 933bfa706f49..bb37a3692f60 100644 --- a/shared/common-adapters/profile-card.tsx +++ b/shared/common-adapters/profile-card.tsx @@ -13,7 +13,7 @@ import FloatingMenu from './floating-menu' import Icon from './icon' import Meta from './meta' import {useProfileState} from '@/constants/profile' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' import ProgressIndicator from './progress-indicator' import Text from './text' diff --git a/shared/common-adapters/usernames.tsx b/shared/common-adapters/usernames.tsx index e86fcb564666..acde8bed645a 100644 --- a/shared/common-adapters/usernames.tsx +++ b/shared/common-adapters/usernames.tsx @@ -15,7 +15,7 @@ import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' import {useTrackerState} from '@/constants/tracker2' import {useUsersState} from '@/constants/users' import {useProfileState} from '@/constants/profile' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' export type User = { diff --git a/shared/constants/followers/util.tsx b/shared/constants/followers/util.tsx deleted file mode 100644 index 34ea577cab45..000000000000 --- a/shared/constants/followers/util.tsx +++ /dev/null @@ -1,29 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import isEqual from 'lodash/isEqual' -import {useCurrentUserState} from '../current-user' -import {useFollowerState} from '../followers' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyTrackingTrackingChanged: { - const {isTracking, username} = action.payload.params - useFollowerState.getState().dispatch.updateFollowing(username, isTracking) - break - } - case EngineGen.keybase1NotifyTrackingTrackingInfo: { - const {uid, followers: _newFollowers, followees: _newFollowing} = action.payload.params - if (useCurrentUserState.getState().uid !== uid) { - return - } - const newFollowers = new Set(_newFollowers) - const newFollowing = new Set(_newFollowing) - const {following: oldFollowing, followers: oldFollowers, dispatch} = useFollowerState.getState() - const following = isEqual(newFollowing, oldFollowing) ? oldFollowing : newFollowing - const followers = isEqual(newFollowers, oldFollowers) ? oldFollowers : newFollowers - dispatch.replace(followers, following) - break - } - default: - } -} - diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index c6adf5cde328..50d5c5bbacfb 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -16,7 +16,8 @@ import {useCurrentUserState} from '../current-user' import {useDaemonState} from '../daemon' import {useDarkModeState} from '../darkmode' import * as DeepLinksUtil from '../deeplinks/util' -import * as FollowerUtil from '../followers/util' +import {useFollowerState} from '@/stores/followers' +import isEqual from 'lodash/isEqual' import * as FSUtil from '../fs/util' import * as GitUtil from '../git/util' import * as NotifUtil from '../notifications/util' @@ -280,7 +281,27 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { ChatUtil.onEngineIncoming(action) useConfigState.getState().dispatch.onEngineIncoming(action) DeepLinksUtil.onEngineIncoming(action) - FollowerUtil.onEngineIncoming(action) + switch (action.type) { + case EngineGen.keybase1NotifyTrackingTrackingChanged: { + const {isTracking, username} = action.payload.params + useFollowerState.getState().dispatch.updateFollowing(username, isTracking) + break + } + case EngineGen.keybase1NotifyTrackingTrackingInfo: { + const {uid, followers: _newFollowers, followees: _newFollowing} = action.payload.params + if (useCurrentUserState.getState().uid !== uid) { + break + } + const newFollowers = new Set(_newFollowers) + const newFollowing = new Set(_newFollowing) + const {following: oldFollowing, followers: oldFollowers, dispatch} = useFollowerState.getState() + const following = isEqual(newFollowing, oldFollowing) ? oldFollowing : newFollowing + const followers = isEqual(newFollowers, oldFollowers) ? oldFollowers : newFollowers + dispatch.replace(followers, following) + break + } + default: + } FSUtil.onEngineIncoming(action) GitUtil.onEngineIncoming(action) NotifUtil.onEngineIncoming(action) diff --git a/shared/menubar/remote-container.desktop.tsx b/shared/menubar/remote-container.desktop.tsx index fa658dbb9793..bd346723f6ce 100644 --- a/shared/menubar/remote-container.desktop.tsx +++ b/shared/menubar/remote-container.desktop.tsx @@ -5,7 +5,7 @@ import {useConfigState} from '@/constants/config' import type {DeserializeProps} from './remote-serializer.desktop' import {useAvatarState} from '@/common-adapters/avatar/store' import {useUsersState} from '@/constants/users' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' import {useDaemonState} from '@/constants/daemon' import {useDarkModeState} from '@/constants/darkmode' diff --git a/shared/menubar/remote-proxy.desktop.tsx b/shared/menubar/remote-proxy.desktop.tsx index c32e0a8c65e7..9c57387bb36f 100644 --- a/shared/menubar/remote-proxy.desktop.tsx +++ b/shared/menubar/remote-proxy.desktop.tsx @@ -14,7 +14,7 @@ import type * as NotifConstants from '@/constants/notifications' import {useColorScheme} from 'react-native' import * as FS from '@/constants/fs' import {useFSState} from '@/constants/fs' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useUsersState} from '@/constants/users' import {useNotifState} from '@/constants/notifications' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/profile/user/actions/index.tsx b/shared/profile/user/actions/index.tsx index bdc2ef2a0fda..386e8981f8bb 100644 --- a/shared/profile/user/actions/index.tsx +++ b/shared/profile/user/actions/index.tsx @@ -7,7 +7,7 @@ import ChatButton from '@/chat/chat-button' import {useBotsState} from '@/stores/bots' import {useTrackerState} from '@/constants/tracker2' import * as FS from '@/constants/fs' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' type OwnProps = {username: string} diff --git a/shared/profile/user/hooks.tsx b/shared/profile/user/hooks.tsx index 0a2a49b3017e..83e22a319579 100644 --- a/shared/profile/user/hooks.tsx +++ b/shared/profile/user/hooks.tsx @@ -4,7 +4,7 @@ import {type BackgroundColorType} from '.' import {useColorScheme} from 'react-native' import {useTrackerState} from '@/constants/tracker2' import {useProfileState} from '@/constants/profile' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' const headerBackgroundColorType = ( diff --git a/shared/settings/contacts-joined.tsx b/shared/settings/contacts-joined.tsx index 0650fa5d2e47..232852a67173 100644 --- a/shared/settings/contacts-joined.tsx +++ b/shared/settings/contacts-joined.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import UnconnectedFollowButton from '@/profile/user/actions/follow-button' import {useSettingsContactsState} from '@/constants/settings-contacts' import {useTrackerState} from '@/constants/tracker2' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' const renderItem = (_: number, item: T.RPCGen.ProcessedContact) => diff --git a/shared/constants/followers/index.tsx b/shared/stores/followers.tsx similarity index 92% rename from shared/constants/followers/index.tsx rename to shared/stores/followers.tsx index f276f03786e9..f7f550f23102 100644 --- a/shared/constants/followers/index.tsx +++ b/shared/stores/followers.tsx @@ -1,7 +1,6 @@ import * as T from '@/constants/types' import * as Z from '@/util/zustand' -// This store has no dependencies on other stores and is safe to import directly from other stores. type Store = T.Immutable<{ followers: Set following: Set diff --git a/shared/team-building/list-body.tsx b/shared/team-building/list-body.tsx index d9cb0fcbeb9a..9c5c98e1005c 100644 --- a/shared/team-building/list-body.tsx +++ b/shared/team-building/list-body.tsx @@ -15,7 +15,7 @@ import {RecsAndRecos, numSectionLabel} from './recs-and-recos' import {formatAnyPhoneNumbers} from '@/util/phone-numbers' import {useRoute} from '@react-navigation/native' import {useSettingsContactsState} from '@/constants/settings-contacts' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' // import {useAnimatedScrollHandler} from '@/common-adapters/reanimated' import {useColorScheme} from 'react-native' diff --git a/shared/tracker2/bio.tsx b/shared/tracker2/bio.tsx index 9113b0f41b25..a8f7213169d1 100644 --- a/shared/tracker2/bio.tsx +++ b/shared/tracker2/bio.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import {useTrackerState} from '@/constants/tracker2' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' type OwnProps = { inTracker: boolean diff --git a/shared/tracker2/remote-container.desktop.tsx b/shared/tracker2/remote-container.desktop.tsx index 16c3549ec2ca..0bf397e22914 100644 --- a/shared/tracker2/remote-container.desktop.tsx +++ b/shared/tracker2/remote-container.desktop.tsx @@ -11,7 +11,7 @@ import KB2 from '@/util/electron.desktop' import {useAvatarState} from '@/common-adapters/avatar/store' import {useTrackerState} from '@/constants/tracker2' import {useUsersState} from '@/constants/users' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' import {useDarkModeState} from '@/constants/darkmode' diff --git a/shared/tracker2/remote-proxy.desktop.tsx b/shared/tracker2/remote-proxy.desktop.tsx index f8ca55fb0c87..cebdb746423b 100644 --- a/shared/tracker2/remote-proxy.desktop.tsx +++ b/shared/tracker2/remote-proxy.desktop.tsx @@ -11,7 +11,7 @@ import {mapFilterByKey} from '@/util/map' import {useColorScheme} from 'react-native' import {useTrackerState} from '@/constants/tracker2' import {useUsersState} from '@/constants/users' -import {useFollowerState} from '@/constants/followers' +import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' const MAX_TRACKERS = 5 From 009c9cca45192d320b047b4bb1fd9cc9e9332819 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:14:17 -0500 Subject: [PATCH 06/37] WIP --- shared/constants/people/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared/constants/people/index.tsx b/shared/constants/people/index.tsx index 7599680c75f4..5ac7397bc6c7 100644 --- a/shared/constants/people/index.tsx +++ b/shared/constants/people/index.tsx @@ -10,7 +10,7 @@ import {isMobile} from '../platform' import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' import debounce from 'lodash/debounce' import {useConfigState} from '../config' -import {useFollowerState} from '../followers' +import {useFollowerState} from '@/stores/followers' import {RPCError, isNetworkErr} from '../utils' // set this to true to have all todo items + a contact joined notification show up all the time From afc0bf01e76172992ddf4c31acd8b0d57899100c Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 15:17:58 -0500 Subject: [PATCH 07/37] WIP --- .../attachment-fullscreen/hooks.tsx | 2 +- .../conversation/info-panel/attachments.tsx | 2 +- .../messages/attachment/audio.tsx | 2 +- .../conversation/messages/attachment/file.tsx | 2 +- .../messages/attachment/shared.tsx | 2 +- .../messages/message-popup/attachment.tsx | 2 +- .../messages/special-top-message.tsx | 2 +- .../messages/system-git-push/container.tsx | 2 +- shared/chat/pdf/index.desktop.tsx | 2 +- shared/chat/send-to-chat/index.tsx | 4 +- shared/constants/fs/common.native.tsx | 2 +- .../fs/platform-specific.android.tsx | 2 +- shared/constants/fs/util.tsx | 15 - shared/constants/init/shared.tsx | 11 +- shared/constants/store-registry.tsx | 2 +- shared/crypto/input.tsx | 2 +- shared/crypto/output.tsx | 4 +- shared/fs/banner/conflict-banner.tsx | 4 +- shared/fs/banner/public-reminder.tsx | 4 +- shared/fs/banner/reset-banner.tsx | 4 +- .../container.tsx | 4 +- .../kext-permission-popup.tsx | 2 +- shared/fs/browser/destination-picker.tsx | 4 +- shared/fs/browser/index.tsx | 4 +- shared/fs/browser/offline.tsx | 4 +- shared/fs/browser/root.tsx | 4 +- shared/fs/browser/rows/editing.tsx | 4 +- shared/fs/browser/rows/rows-container.tsx | 4 +- shared/fs/browser/rows/still.tsx | 4 +- shared/fs/browser/rows/tlf-type.tsx | 2 +- shared/fs/browser/rows/tlf.tsx | 4 +- shared/fs/common/errs-container.tsx | 2 +- shared/fs/common/folder-view-filter-icon.tsx | 4 +- shared/fs/common/folder-view-filter.tsx | 4 +- shared/fs/common/hooks.tsx | 4 +- shared/fs/common/item-icon.tsx | 4 +- shared/fs/common/kbfs-path.tsx | 2 +- shared/fs/common/last-modified-line.tsx | 4 +- .../fs/common/open-in-system-file-manager.tsx | 2 +- shared/fs/common/path-info.tsx | 4 +- .../common/path-item-action/choose-view.tsx | 2 +- .../path-item-action/confirm-delete.tsx | 4 +- shared/fs/common/path-item-action/confirm.tsx | 4 +- shared/fs/common/path-item-action/index.tsx | 4 +- shared/fs/common/path-item-action/layout.tsx | 2 +- .../path-item-action/menu-container.tsx | 4 +- shared/fs/common/path-item-info.tsx | 4 +- .../fs/common/path-status-icon-container.tsx | 4 +- .../common/refresh-driver-status-on-mount.tsx | 2 +- shared/fs/common/sfmi-popup.tsx | 2 +- shared/fs/common/tlf-info-line-container.tsx | 4 +- shared/fs/common/upload-button.tsx | 4 +- shared/fs/common/use-open.tsx | 4 +- shared/fs/filepreview/bare-preview.tsx | 2 +- shared/fs/filepreview/default-view.tsx | 4 +- shared/fs/filepreview/view.tsx | 4 +- shared/fs/footer/download.tsx | 4 +- shared/fs/footer/downloads.tsx | 2 +- shared/fs/footer/proof-broken.tsx | 2 +- shared/fs/footer/upload-container.tsx | 4 +- shared/fs/index.tsx | 4 +- shared/fs/nav-header/actions.tsx | 4 +- shared/fs/nav-header/main-banner.tsx | 4 +- shared/fs/nav-header/mobile-header.tsx | 4 +- shared/fs/nav-header/title.tsx | 2 +- shared/fs/routes.tsx | 2 +- shared/fs/top-bar/loading.tsx | 4 +- shared/fs/top-bar/sort.tsx | 4 +- shared/fs/top-bar/sync-toggle.tsx | 4 +- shared/git/row.tsx | 2 +- shared/incoming-share/index.tsx | 4 +- shared/menubar/remote-proxy.desktop.tsx | 4 +- shared/profile/user/actions/index.tsx | 2 +- shared/router-v2/header/syncing-folders.tsx | 4 +- shared/router-v2/router.shared.tsx | 2 +- shared/router-v2/tab-bar.desktop.tsx | 2 +- shared/settings/advanced.tsx | 2 +- shared/settings/archive/index.tsx | 4 +- shared/settings/files/hooks.tsx | 2 +- shared/settings/files/index.desktop.tsx | 4 +- shared/settings/files/index.native.tsx | 4 +- shared/settings/files/refresh-settings.tsx | 2 +- shared/stores/fs.tsx | 1812 +++++++++++++++++ .../search-result/people-result.tsx | 2 +- shared/teams/container.tsx | 2 +- 85 files changed, 1949 insertions(+), 145 deletions(-) create mode 100644 shared/stores/fs.tsx diff --git a/shared/chat/conversation/attachment-fullscreen/hooks.tsx b/shared/chat/conversation/attachment-fullscreen/hooks.tsx index 584d3cdeacc9..02fdc5218010 100644 --- a/shared/chat/conversation/attachment-fullscreen/hooks.tsx +++ b/shared/chat/conversation/attachment-fullscreen/hooks.tsx @@ -3,7 +3,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import type * as T from '@/constants/types' import {maxWidth, maxHeight} from '../messages/attachment/shared' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const blankMessage = Chat.makeMessageAttachment({}) export const useData = (initialOrdinal: T.Chat.Ordinal) => { diff --git a/shared/chat/conversation/info-panel/attachments.tsx b/shared/chat/conversation/info-panel/attachments.tsx index 451fa0a9bf98..c407c5430d4e 100644 --- a/shared/chat/conversation/info-panel/attachments.tsx +++ b/shared/chat/conversation/info-panel/attachments.tsx @@ -8,7 +8,7 @@ import chunk from 'lodash/chunk' import {formatAudioRecordDuration, formatTimeForMessages} from '@/util/timestamp' import {infoPanelWidth} from './common' import {useMessagePopup} from '../messages/message-popup' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type Props = { commonSections: ReadonlyArray
diff --git a/shared/chat/conversation/messages/attachment/audio.tsx b/shared/chat/conversation/messages/attachment/audio.tsx index eb299725bc45..caa3ddc2354d 100644 --- a/shared/chat/conversation/messages/attachment/audio.tsx +++ b/shared/chat/conversation/messages/attachment/audio.tsx @@ -3,7 +3,7 @@ import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {useOrdinal} from '../ids-context' import AudioPlayer from '@/chat/audio/audio-player' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const missingMessage = Chat.makeMessageAttachment() diff --git a/shared/chat/conversation/messages/attachment/file.tsx b/shared/chat/conversation/messages/attachment/file.tsx index 948f66f32a0d..1cbb694c3939 100644 --- a/shared/chat/conversation/messages/attachment/file.tsx +++ b/shared/chat/conversation/messages/attachment/file.tsx @@ -9,7 +9,7 @@ import captialize from 'lodash/capitalize' import * as Kb from '@/common-adapters' import type {StyleOverride} from '@/common-adapters/markdown' import {getEditStyle, ShowToastAfterSaving} from './shared' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type OwnProps = {showPopup: () => void} diff --git a/shared/chat/conversation/messages/attachment/shared.tsx b/shared/chat/conversation/messages/attachment/shared.tsx index 379a85ae8374..b1893784f743 100644 --- a/shared/chat/conversation/messages/attachment/shared.tsx +++ b/shared/chat/conversation/messages/attachment/shared.tsx @@ -6,7 +6,7 @@ import * as T from '@/constants/types' import {useOrdinal} from '../ids-context' import {sharedStyles} from '../shared-styles' import {Keyboard} from 'react-native' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type Props = { transferState: T.Chat.MessageAttachmentTransferState diff --git a/shared/chat/conversation/messages/message-popup/attachment.tsx b/shared/chat/conversation/messages/message-popup/attachment.tsx index 0cf6fdb9efb9..9fc1b4e8acc6 100644 --- a/shared/chat/conversation/messages/message-popup/attachment.tsx +++ b/shared/chat/conversation/messages/message-popup/attachment.tsx @@ -5,7 +5,7 @@ import type * as T from '@/constants/types' import {type Position, fileUIName, type StylesCrossPlatform} from '@/styles' import {useItems, useHeader} from './hooks' import * as Kb from '@/common-adapters' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type OwnProps = { attachTo?: React.RefObject diff --git a/shared/chat/conversation/messages/special-top-message.tsx b/shared/chat/conversation/messages/special-top-message.tsx index 40205b7dc910..77ad455838ea 100644 --- a/shared/chat/conversation/messages/special-top-message.tsx +++ b/shared/chat/conversation/messages/special-top-message.tsx @@ -10,7 +10,7 @@ import NewChatCard from './cards/new-chat' import ProfileResetNotice from './system-profile-reset-notice' import RetentionNotice from './retention-notice' import {usingFlashList} from '../list-area/flashlist-config' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' const ErrorMessage = () => { diff --git a/shared/chat/conversation/messages/system-git-push/container.tsx b/shared/chat/conversation/messages/system-git-push/container.tsx index 3d8d2c346a98..bc2fa9853091 100644 --- a/shared/chat/conversation/messages/system-git-push/container.tsx +++ b/shared/chat/conversation/messages/system-git-push/container.tsx @@ -4,7 +4,7 @@ import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {useGitState} from '@/constants/git' import UserNotice from '../user-notice' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' type OwnProps = {message: T.Chat.MessageSystemGitPush} diff --git a/shared/chat/pdf/index.desktop.tsx b/shared/chat/pdf/index.desktop.tsx index d0c53c8853c4..4e5c2f2b2b1b 100644 --- a/shared/chat/pdf/index.desktop.tsx +++ b/shared/chat/pdf/index.desktop.tsx @@ -3,7 +3,7 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import type {Props} from '.' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const ChatPDF = (props: Props) => { const {ordinal} = props diff --git a/shared/chat/send-to-chat/index.tsx b/shared/chat/send-to-chat/index.tsx index 2bba86a3e4df..237b70bfd797 100644 --- a/shared/chat/send-to-chat/index.tsx +++ b/shared/chat/send-to-chat/index.tsx @@ -6,8 +6,8 @@ import * as Kb from '@/common-adapters' import * as Kbfs from '@/fs/common' import ConversationList from './conversation-list/conversation-list' import ChooseConversation from './conversation-list/choose-conversation' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' type Props = { diff --git a/shared/constants/fs/common.native.tsx b/shared/constants/fs/common.native.tsx index c75025efc827..6358c7a6cbc4 100644 --- a/shared/constants/fs/common.native.tsx +++ b/shared/constants/fs/common.native.tsx @@ -3,7 +3,7 @@ import {ignorePromise} from '../utils' import {wrapErrors} from '@/util/debug' import * as T from '../types' import * as Styles from '@/styles' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {launchImageLibraryAsync} from '@/util/expo-image-picker.native' import {saveAttachmentToCameraRoll, showShareActionSheet} from '../platform-specific' import {useFSState} from '.' diff --git a/shared/constants/fs/platform-specific.android.tsx b/shared/constants/fs/platform-specific.android.tsx index 8e7f3ff2a04b..37db57525572 100644 --- a/shared/constants/fs/platform-specific.android.tsx +++ b/shared/constants/fs/platform-specific.android.tsx @@ -1,6 +1,6 @@ import * as T from '../types' import {ignorePromise, wrapErrors} from '../utils' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import logger from '@/logger' import nativeInit from './common.native' import {useFSState} from '.' diff --git a/shared/constants/fs/util.tsx b/shared/constants/fs/util.tsx index e680702022f8..197a45cf13cd 100644 --- a/shared/constants/fs/util.tsx +++ b/shared/constants/fs/util.tsx @@ -5,21 +5,6 @@ import * as T from '../types' import {isLinux, isMobile} from '../platform' import {settingsFsTab} from '../settings/util' import {navigateAppend} from '../router2/util' -import {storeRegistry} from '../store-registry' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyFSFSOverallSyncStatusChanged: - case EngineGen.keybase1NotifyFSFSSubscriptionNotifyPath: - case EngineGen.keybase1NotifyFSFSSubscriptionNotify: - { - storeRegistry.getState('fs').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} - export const makeActionForOpenPathInFilesTab = ( // TODO: remove the second arg when we are done with migrating to nav2 path: T.FS.Path diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 50d5c5bbacfb..fd525d251d48 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -18,7 +18,7 @@ import {useDarkModeState} from '../darkmode' import * as DeepLinksUtil from '../deeplinks/util' import {useFollowerState} from '@/stores/followers' import isEqual from 'lodash/isEqual' -import * as FSUtil from '../fs/util' +import type * as UseFSStateType from '@/stores/fs' import * as GitUtil from '../git/util' import * as NotifUtil from '../notifications/util' import * as PeopleUtil from '../people/util' @@ -275,6 +275,14 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { useBotsState.getState().dispatch.onEngineIncomingImpl(action) } break + case EngineGen.keybase1NotifyFSFSOverallSyncStatusChanged: + case EngineGen.keybase1NotifyFSFSSubscriptionNotifyPath: + case EngineGen.keybase1NotifyFSFSSubscriptionNotify: + { + const {useFSState} = require('@/stores/fs') as typeof UseFSStateType + useFSState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) @@ -302,7 +310,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - FSUtil.onEngineIncoming(action) GitUtil.onEngineIncoming(action) NotifUtil.onEngineIncoming(action) PeopleUtil.onEngineIncoming(action) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index e7dcf4be408f..46f4b1fa11b9 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -9,7 +9,7 @@ import type {State as BotsState, useBotsState} from '@/stores/bots' import type {State as ChatState, useChatState} from '@/constants/chat2' import type {State as DaemonState, useDaemonState} from '@/constants/daemon' import type {State as DevicesState, useDevicesState} from '@/stores/devices' -import type {State as FSState, useFSState} from '@/constants/fs' +import type {State as FSState, useFSState} from '@/stores/fs' import type {State as GitState, useGitState} from '@/constants/git' import type {State as NotificationsState, useNotifState} from '@/constants/notifications' import type {State as PeopleState, usePeopleState} from '@/constants/people' diff --git a/shared/crypto/input.tsx b/shared/crypto/input.tsx index 575de4122740..63039da7272d 100644 --- a/shared/crypto/input.tsx +++ b/shared/crypto/input.tsx @@ -3,7 +3,7 @@ import * as Crypto from '@/constants/crypto' import * as React from 'react' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import type {IconType} from '@/common-adapters/icon.constants-gen' import capitalize from 'lodash/capitalize' import {pickFiles} from '@/util/pick-files' diff --git a/shared/crypto/output.tsx b/shared/crypto/output.tsx index d349ae39efe5..a1884597be7c 100644 --- a/shared/crypto/output.tsx +++ b/shared/crypto/output.tsx @@ -8,8 +8,8 @@ import capitalize from 'lodash/capitalize' import type * as T from '@/constants/types' import {pickFiles} from '@/util/pick-files' import type HiddenString from '@/util/hidden-string' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useConfigState} from '@/constants/config' type OutputProps = {operation: T.Crypto.Operations} diff --git a/shared/fs/banner/conflict-banner.tsx b/shared/fs/banner/conflict-banner.tsx index 09898a2b91e6..c39440d9d96c 100644 --- a/shared/fs/banner/conflict-banner.tsx +++ b/shared/fs/banner/conflict-banner.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import openUrl from '@/util/open-url' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = { path: T.FS.Path diff --git a/shared/fs/banner/public-reminder.tsx b/shared/fs/banner/public-reminder.tsx index 16783c602a96..717e78175cf4 100644 --- a/shared/fs/banner/public-reminder.tsx +++ b/shared/fs/banner/public-reminder.tsx @@ -1,8 +1,8 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { path: T.FS.Path diff --git a/shared/fs/banner/reset-banner.tsx b/shared/fs/banner/reset-banner.tsx index 91e09bfd1b13..bc9fc4837b45 100644 --- a/shared/fs/banner/reset-banner.tsx +++ b/shared/fs/banner/reset-banner.tsx @@ -5,8 +5,8 @@ import {folderNameWithoutUsers} from '@/util/kbfs' import * as Kb from '@/common-adapters' import * as RowTypes from '@/fs/browser/rows/types' import {useTrackerState} from '@/constants/tracker2' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useProfileState} from '@/constants/profile' type OwnProps = {path: T.FS.Path} diff --git a/shared/fs/banner/system-file-manager-integration-banner/container.tsx b/shared/fs/banner/system-file-manager-integration-banner/container.tsx index 02877de920b0..0114e131cbad 100644 --- a/shared/fs/banner/system-file-manager-integration-banner/container.tsx +++ b/shared/fs/banner/system-file-manager-integration-banner/container.tsx @@ -3,8 +3,8 @@ import * as C from '@/constants' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as Kbfs from '@/fs/common' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = {alwaysShow?: boolean} diff --git a/shared/fs/banner/system-file-manager-integration-banner/kext-permission-popup.tsx b/shared/fs/banner/system-file-manager-integration-banner/kext-permission-popup.tsx index 759aa1d2fe21..7898cf2ca82c 100644 --- a/shared/fs/banner/system-file-manager-integration-banner/kext-permission-popup.tsx +++ b/shared/fs/banner/system-file-manager-integration-banner/kext-permission-popup.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import * as C from '@/constants' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const InstallSecurityPrefs = () => { const driverStatus = useFSState(s => s.sfmi.driverStatus) diff --git a/shared/fs/browser/destination-picker.tsx b/shared/fs/browser/destination-picker.tsx index 9a407bb950b8..b00bdd56608b 100644 --- a/shared/fs/browser/destination-picker.tsx +++ b/shared/fs/browser/destination-picker.tsx @@ -8,8 +8,8 @@ import NavHeaderTitle from '@/fs/nav-header/title' import Root from './root' import Rows from './rows/rows-container' import {OriginalOrCompressedButton} from '@/incoming-share' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = {index: number} diff --git a/shared/fs/browser/index.tsx b/shared/fs/browser/index.tsx index c4e8df63334d..b8dff985b6d0 100644 --- a/shared/fs/browser/index.tsx +++ b/shared/fs/browser/index.tsx @@ -10,8 +10,8 @@ import PublicReminder from '../banner/public-reminder' import Root from './root' import Rows from './rows/rows-container' import {asRows as resetBannerAsRows} from '../banner/reset-banner' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = {path: T.FS.Path} diff --git a/shared/fs/browser/offline.tsx b/shared/fs/browser/offline.tsx index 51f045b4fdba..3a3273e64ffe 100644 --- a/shared/fs/browser/offline.tsx +++ b/shared/fs/browser/offline.tsx @@ -1,8 +1,8 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import TopBar from '../top-bar' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { path: T.FS.Path diff --git a/shared/fs/browser/root.tsx b/shared/fs/browser/root.tsx index af39fbc45ea1..caf3b4743a8c 100644 --- a/shared/fs/browser/root.tsx +++ b/shared/fs/browser/root.tsx @@ -5,8 +5,8 @@ import TlfType from './rows/tlf-type' import Tlf from './rows/tlf' import SfmiBanner from '../banner/system-file-manager-integration-banner/container' import {WrapRow} from './rows/rows' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' type Props = { diff --git a/shared/fs/browser/rows/editing.tsx b/shared/fs/browser/rows/editing.tsx index e6e19567d756..99ac037113a7 100644 --- a/shared/fs/browser/rows/editing.tsx +++ b/shared/fs/browser/rows/editing.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {rowStyles} from './common' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { editID: T.FS.EditID diff --git a/shared/fs/browser/rows/rows-container.tsx b/shared/fs/browser/rows/rows-container.tsx index 9c3852859b96..079d1134f007 100644 --- a/shared/fs/browser/rows/rows-container.tsx +++ b/shared/fs/browser/rows/rows-container.tsx @@ -4,8 +4,8 @@ import * as RowTypes from './types' import {sortRowItems, type SortableRowItem} from './sort' import Rows, {type Props} from './rows' import {asRows as topBarAsRow} from '../../top-bar' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' type OwnProps = { diff --git a/shared/fs/browser/rows/still.tsx b/shared/fs/browser/rows/still.tsx index c5b1655ff3b4..f0a2ad9abbef 100644 --- a/shared/fs/browser/rows/still.tsx +++ b/shared/fs/browser/rows/still.tsx @@ -4,8 +4,8 @@ import {useOpen} from '@/fs/common/use-open' import {rowStyles, StillCommon} from './common' import * as Kb from '@/common-adapters' import {LastModifiedLine, Filename} from '@/fs/common' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = { destinationPickerIndex?: number diff --git a/shared/fs/browser/rows/tlf-type.tsx b/shared/fs/browser/rows/tlf-type.tsx index 908334f54352..e60d181d6f39 100644 --- a/shared/fs/browser/rows/tlf-type.tsx +++ b/shared/fs/browser/rows/tlf-type.tsx @@ -1,6 +1,6 @@ import * as T from '@/constants/types' import {useOpen} from '@/fs/common/use-open' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {rowStyles, StillCommon} from './common' import * as Kb from '@/common-adapters' diff --git a/shared/fs/browser/rows/tlf.tsx b/shared/fs/browser/rows/tlf.tsx index 001ba2b64cdd..90621b34fb64 100644 --- a/shared/fs/browser/rows/tlf.tsx +++ b/shared/fs/browser/rows/tlf.tsx @@ -3,8 +3,8 @@ import {useOpen} from '@/fs/common/use-open' import {rowStyles, StillCommon} from './common' import * as Kb from '@/common-adapters' import {useFsPathMetadata, TlfInfoLine, Filename} from '@/fs/common' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' export type OwnProps = { diff --git a/shared/fs/common/errs-container.tsx b/shared/fs/common/errs-container.tsx index 7e86e484dd46..ae768869412a 100644 --- a/shared/fs/common/errs-container.tsx +++ b/shared/fs/common/errs-container.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as C from '@/constants' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const ErrsContainer = () => { const {_errors, _dismiss} = useFSState( diff --git a/shared/fs/common/folder-view-filter-icon.tsx b/shared/fs/common/folder-view-filter-icon.tsx index a843e380bf81..135aff8989f2 100644 --- a/shared/fs/common/folder-view-filter-icon.tsx +++ b/shared/fs/common/folder-view-filter-icon.tsx @@ -1,8 +1,8 @@ import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import type * as Styles from '@/styles' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { onClick: () => void diff --git a/shared/fs/common/folder-view-filter.tsx b/shared/fs/common/folder-view-filter.tsx index 7cf7dc787a71..45e1c6d835da 100644 --- a/shared/fs/common/folder-view-filter.tsx +++ b/shared/fs/common/folder-view-filter.tsx @@ -3,8 +3,8 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' import debounce from 'lodash/debounce' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { onCancel?: () => void diff --git a/shared/fs/common/hooks.tsx b/shared/fs/common/hooks.tsx index be2ac0bcaa39..95edbb6d8778 100644 --- a/shared/fs/common/hooks.tsx +++ b/shared/fs/common/hooks.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import logger from '@/logger' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' const isPathItem = (path: T.FS.Path) => T.FS.getPathLevel(path) > 2 || FS.hasSpecialFileElement(path) diff --git a/shared/fs/common/item-icon.tsx b/shared/fs/common/item-icon.tsx index 303b8e533dc2..8b0d42789caf 100644 --- a/shared/fs/common/item-icon.tsx +++ b/shared/fs/common/item-icon.tsx @@ -1,8 +1,8 @@ import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import type {IconType} from '@/common-adapters/icon' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' export type Size = 96 | 48 | 32 | 16 type SizeString = '96' | '48' | '32' | '16' diff --git a/shared/fs/common/kbfs-path.tsx b/shared/fs/common/kbfs-path.tsx index bc000fb40d44..847405ef0104 100644 --- a/shared/fs/common/kbfs-path.tsx +++ b/shared/fs/common/kbfs-path.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import PathInfo from './path-info' import PathItemInfo from './path-item-info' diff --git a/shared/fs/common/last-modified-line.tsx b/shared/fs/common/last-modified-line.tsx index 7a8d7893f508..a11c6be3625f 100644 --- a/shared/fs/common/last-modified-line.tsx +++ b/shared/fs/common/last-modified-line.tsx @@ -1,8 +1,8 @@ import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {formatTimeForFS} from '@/util/timestamp' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' export type OwnProps = { path: T.FS.Path diff --git a/shared/fs/common/open-in-system-file-manager.tsx b/shared/fs/common/open-in-system-file-manager.tsx index 42758a5a7420..c45d43352971 100644 --- a/shared/fs/common/open-in-system-file-manager.tsx +++ b/shared/fs/common/open-in-system-file-manager.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as C from '@/constants' import SystemFileManagerIntegrationPopup from './sfmi-popup' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type Props = {path: T.FS.Path} diff --git a/shared/fs/common/path-info.tsx b/shared/fs/common/path-info.tsx index 16e0f1ef9d51..25182ab0625a 100644 --- a/shared/fs/common/path-info.tsx +++ b/shared/fs/common/path-info.tsx @@ -1,8 +1,8 @@ import * as T from '@/constants/types' import {useFsPathInfo} from './hooks' import * as Kb from '@/common-adapters' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type PathInfoProps = { containerStyle?: Kb.Styles.StylesCrossPlatform diff --git a/shared/fs/common/path-item-action/choose-view.tsx b/shared/fs/common/path-item-action/choose-view.tsx index 7029ddf85d26..23421a3c10cd 100644 --- a/shared/fs/common/path-item-action/choose-view.tsx +++ b/shared/fs/common/path-item-action/choose-view.tsx @@ -2,7 +2,7 @@ import * as T from '@/constants/types' import type {FloatingMenuProps} from './types' import Menu from './menu-container' import Confirm from './confirm' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type OwnProps = { floatingMenuProps: FloatingMenuProps diff --git a/shared/fs/common/path-item-action/confirm-delete.tsx b/shared/fs/common/path-item-action/confirm-delete.tsx index fbc3d3afe1aa..d47af5f53184 100644 --- a/shared/fs/common/path-item-action/confirm-delete.tsx +++ b/shared/fs/common/path-item-action/confirm-delete.tsx @@ -2,8 +2,8 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as C from '@/constants' import * as React from 'react' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' export type Props = { onBack: () => void diff --git a/shared/fs/common/path-item-action/confirm.tsx b/shared/fs/common/path-item-action/confirm.tsx index 73e19306d67c..c3fb1a363ea6 100644 --- a/shared/fs/common/path-item-action/confirm.tsx +++ b/shared/fs/common/path-item-action/confirm.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import * as T from '@/constants/types' import type {FloatingMenuProps} from './types' import * as Kb from '@/common-adapters' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = { floatingMenuProps: FloatingMenuProps diff --git a/shared/fs/common/path-item-action/index.tsx b/shared/fs/common/path-item-action/index.tsx index 46087ca280e2..00c24879ddbb 100644 --- a/shared/fs/common/path-item-action/index.tsx +++ b/shared/fs/common/path-item-action/index.tsx @@ -4,8 +4,8 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import ChooseView from './choose-view' import type {SizeType} from '@/common-adapters/icon' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' export type ClickableProps = { onClick: () => void diff --git a/shared/fs/common/path-item-action/layout.tsx b/shared/fs/common/path-item-action/layout.tsx index ec63a3a52b64..89a91060c446 100644 --- a/shared/fs/common/path-item-action/layout.tsx +++ b/shared/fs/common/path-item-action/layout.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as T from '@/constants/types' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' export type Layout = { archive: boolean diff --git a/shared/fs/common/path-item-action/menu-container.tsx b/shared/fs/common/path-item-action/menu-container.tsx index 996f366ea73c..e3874afe76d1 100644 --- a/shared/fs/common/path-item-action/menu-container.tsx +++ b/shared/fs/common/path-item-action/menu-container.tsx @@ -8,8 +8,8 @@ import * as Util from '@/util/kbfs' import Header from './header' import type {FloatingMenuProps} from './types' import {getRootLayout, getShareLayout} from './layout' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' type OwnProps = { diff --git a/shared/fs/common/path-item-info.tsx b/shared/fs/common/path-item-info.tsx index 75d4bc69fb06..bd9d22d388f1 100644 --- a/shared/fs/common/path-item-info.tsx +++ b/shared/fs/common/path-item-info.tsx @@ -6,8 +6,8 @@ import ItemIcon from './item-icon' import CommaSeparatedName from './comma-separated-name' import {pluralize} from '@/util/string' import {useFsChildren, useFsPathMetadata, useFsOnlineStatus, useFsSoftError} from './hooks' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { containerStyle?: Kb.Styles.StylesCrossPlatform diff --git a/shared/fs/common/path-status-icon-container.tsx b/shared/fs/common/path-status-icon-container.tsx index 9a1440a507e2..0e6cb624b358 100644 --- a/shared/fs/common/path-status-icon-container.tsx +++ b/shared/fs/common/path-status-icon-container.tsx @@ -1,8 +1,8 @@ import * as T from '@/constants/types' import * as C from '@/constants' import PathStatusIcon from './path-status-icon' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnPropsPathItem = { path: T.FS.Path diff --git a/shared/fs/common/refresh-driver-status-on-mount.tsx b/shared/fs/common/refresh-driver-status-on-mount.tsx index 9ce3cc4d12d5..c4739b49fa67 100644 --- a/shared/fs/common/refresh-driver-status-on-mount.tsx +++ b/shared/fs/common/refresh-driver-status-on-mount.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const RefreshDriverStatusOnMount = () => { const refreshDriverStatusDesktop = useFSState(s => s.dispatch.dynamic.refreshDriverStatusDesktop) diff --git a/shared/fs/common/sfmi-popup.tsx b/shared/fs/common/sfmi-popup.tsx index 9fbf8764643b..33aa3bbe952b 100644 --- a/shared/fs/common/sfmi-popup.tsx +++ b/shared/fs/common/sfmi-popup.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {useFuseClosedSourceConsent} from './hooks' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type Props = { mode: 'Icon' | 'Button' diff --git a/shared/fs/common/tlf-info-line-container.tsx b/shared/fs/common/tlf-info-line-container.tsx index 8b84d8962edd..aa8f257a9e9b 100644 --- a/shared/fs/common/tlf-info-line-container.tsx +++ b/shared/fs/common/tlf-info-line-container.tsx @@ -1,7 +1,7 @@ import * as T from '@/constants/types' import TlfInfoLine from './tlf-info-line' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' export type OwnProps = { diff --git a/shared/fs/common/upload-button.tsx b/shared/fs/common/upload-button.tsx index 593688df6905..c335b8e84126 100644 --- a/shared/fs/common/upload-button.tsx +++ b/shared/fs/common/upload-button.tsx @@ -3,8 +3,8 @@ import * as T from '@/constants/types' import * as C from '@/constants' import * as Kb from '@/common-adapters' import type * as Styles from '@/styles' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type OwnProps = { path: T.FS.Path diff --git a/shared/fs/common/use-open.tsx b/shared/fs/common/use-open.tsx index 0e15b1719686..74a9ea2be194 100644 --- a/shared/fs/common/use-open.tsx +++ b/shared/fs/common/use-open.tsx @@ -1,8 +1,8 @@ import * as C from '@/constants' import * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type Props = { path: T.FS.Path diff --git a/shared/fs/filepreview/bare-preview.tsx b/shared/fs/filepreview/bare-preview.tsx index bcbe04f750c7..f9d95b402178 100644 --- a/shared/fs/filepreview/bare-preview.tsx +++ b/shared/fs/filepreview/bare-preview.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import Footer from '../footer/footer' import View from './view' import * as Kbfs from '../common' diff --git a/shared/fs/filepreview/default-view.tsx b/shared/fs/filepreview/default-view.tsx index 41d252be7d54..70b01d0109ac 100644 --- a/shared/fs/filepreview/default-view.tsx +++ b/shared/fs/filepreview/default-view.tsx @@ -3,8 +3,8 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import {PathItemAction, LastModifiedLine, ItemIcon, type ClickableProps} from '../common' import {hasShare} from '../common/path-item-action/layout' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type OwnProps = {path: T.FS.Path} diff --git a/shared/fs/filepreview/view.tsx b/shared/fs/filepreview/view.tsx index 2765510266e7..db96179f7e08 100644 --- a/shared/fs/filepreview/view.tsx +++ b/shared/fs/filepreview/view.tsx @@ -7,8 +7,8 @@ import TextView from './text-view' import AVView from './av-view' import PdfView from './pdf-view' import * as Kb from '@/common-adapters' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type Props = { path: T.FS.Path diff --git a/shared/fs/footer/download.tsx b/shared/fs/footer/download.tsx index 3d2177cbd799..062e69bc0a46 100644 --- a/shared/fs/footer/download.tsx +++ b/shared/fs/footer/download.tsx @@ -4,8 +4,8 @@ import * as C from '@/constants' import * as T from '@/constants/types' import DownloadWrapper from './download-wrapper' import {formatDurationFromNowTo} from '@/util/timestamp' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' export type Props = { downloadID: string diff --git a/shared/fs/footer/downloads.tsx b/shared/fs/footer/downloads.tsx index 7983b96c0020..bee401a9f534 100644 --- a/shared/fs/footer/downloads.tsx +++ b/shared/fs/footer/downloads.tsx @@ -2,7 +2,7 @@ import * as Kb from '@/common-adapters' import * as C from '@/constants' import * as Kbfs from '../common' import Download from './download' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const Mobile = () => { Kbfs.useFsDownloadStatus() diff --git a/shared/fs/footer/proof-broken.tsx b/shared/fs/footer/proof-broken.tsx index 186b5106bb28..5bba1fed4a51 100644 --- a/shared/fs/footer/proof-broken.tsx +++ b/shared/fs/footer/proof-broken.tsx @@ -1,6 +1,6 @@ import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {useUsersState} from '@/constants/users' type Props = {path: T.FS.Path} diff --git a/shared/fs/footer/upload-container.tsx b/shared/fs/footer/upload-container.tsx index 73bfd3b2d3ef..31193f51a235 100644 --- a/shared/fs/footer/upload-container.tsx +++ b/shared/fs/footer/upload-container.tsx @@ -2,8 +2,8 @@ import * as T from '@/constants/types' import Upload from './upload' import {useUploadCountdown} from './use-upload-countdown' import * as C from '@/constants' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' // NOTE flip this to show a button to debug the upload banner animations. const enableDebugUploadBanner = false as boolean diff --git a/shared/fs/index.tsx b/shared/fs/index.tsx index 304ce8342ced..78fa22597830 100644 --- a/shared/fs/index.tsx +++ b/shared/fs/index.tsx @@ -5,8 +5,8 @@ import Browser from './browser' import {NormalPreview} from './filepreview' import * as Kbfs from './common' import * as SimpleScreens from './simple-screens' -import {useFSState} from '@/constants/fs' -import * as FS from '@/constants/fs' +import {useFSState} from '@/stores/fs' +import * as FS from '@/stores/fs' type ChooseComponentProps = { emitBarePreview: () => void diff --git a/shared/fs/nav-header/actions.tsx b/shared/fs/nav-header/actions.tsx index 497c67488b7f..014b0c7e1331 100644 --- a/shared/fs/nav-header/actions.tsx +++ b/shared/fs/nav-header/actions.tsx @@ -3,8 +3,8 @@ import * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' import * as Kbfs from '../common' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type Props = { onTriggerFilterMobile: () => void diff --git a/shared/fs/nav-header/main-banner.tsx b/shared/fs/nav-header/main-banner.tsx index 73150635e474..af0b4e87a394 100644 --- a/shared/fs/nav-header/main-banner.tsx +++ b/shared/fs/nav-header/main-banner.tsx @@ -1,8 +1,8 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' type Props = { diff --git a/shared/fs/nav-header/mobile-header.tsx b/shared/fs/nav-header/mobile-header.tsx index 1364d912bc1c..3868d0e25ba9 100644 --- a/shared/fs/nav-header/mobile-header.tsx +++ b/shared/fs/nav-header/mobile-header.tsx @@ -5,8 +5,8 @@ import * as Kbfs from '../common' import type * as T from '@/constants/types' import Actions from './actions' import MainBanner from './main-banner' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' /* * diff --git a/shared/fs/nav-header/title.tsx b/shared/fs/nav-header/title.tsx index a1419632345f..1bcb3e156a77 100644 --- a/shared/fs/nav-header/title.tsx +++ b/shared/fs/nav-header/title.tsx @@ -3,7 +3,7 @@ import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as Kbfs from '../common' import {useSafeNavigation} from '@/util/safe-navigation' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' type Props = { path: T.FS.Path diff --git a/shared/fs/routes.tsx b/shared/fs/routes.tsx index f96c5d4f17c3..f9d6796ef092 100644 --- a/shared/fs/routes.tsx +++ b/shared/fs/routes.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as T from '@/constants/types' import * as C from '@/constants' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {Actions, MainBanner, MobileHeader, Title} from './nav-header' const FsRoot = React.lazy(async () => import('.')) diff --git a/shared/fs/top-bar/loading.tsx b/shared/fs/top-bar/loading.tsx index 1aee292386c8..214ecb0a9539 100644 --- a/shared/fs/top-bar/loading.tsx +++ b/shared/fs/top-bar/loading.tsx @@ -1,8 +1,8 @@ import * as T from '@/constants/types' import * as C from '@/constants' import * as Kb from '@/common-adapters' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' // The behavior is to only show spinner when user first time lands on a screen // and when don't have the data that drives it yet. Since RPCs happen diff --git a/shared/fs/top-bar/sort.tsx b/shared/fs/top-bar/sort.tsx index f2057895d10f..30db41b3f6be 100644 --- a/shared/fs/top-bar/sort.tsx +++ b/shared/fs/top-bar/sort.tsx @@ -2,8 +2,8 @@ import * as C from '@/constants' import * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type OwnProps = { path: T.FS.Path diff --git a/shared/fs/top-bar/sync-toggle.tsx b/shared/fs/top-bar/sync-toggle.tsx index 437300313c8d..cdc1e573a46d 100644 --- a/shared/fs/top-bar/sync-toggle.tsx +++ b/shared/fs/top-bar/sync-toggle.tsx @@ -2,8 +2,8 @@ import * as C from '@/constants' import * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type OwnProps = { tlfPath: T.FS.Path diff --git a/shared/git/row.tsx b/shared/git/row.tsx index 4402b545eb79..ca132a409a88 100644 --- a/shared/git/row.tsx +++ b/shared/git/row.tsx @@ -6,7 +6,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import openURL from '@/util/open-url' import {useTrackerState} from '@/constants/tracker2' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' export const NewContext = React.createContext>(new Set()) diff --git a/shared/incoming-share/index.tsx b/shared/incoming-share/index.tsx index 610c72636a1c..dcfb5e355583 100644 --- a/shared/incoming-share/index.tsx +++ b/shared/incoming-share/index.tsx @@ -5,8 +5,8 @@ import * as T from '@/constants/types' import * as FsCommon from '@/fs/common' import {MobileSendToChat} from '../chat/send-to-chat' import {settingsFeedbackTab} from '@/constants/settings' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' import {useConfigState} from '@/constants/config' export const OriginalOrCompressedButton = ({incomingShareItems}: IncomingShareProps) => { diff --git a/shared/menubar/remote-proxy.desktop.tsx b/shared/menubar/remote-proxy.desktop.tsx index 9c57387bb36f..9fe8cebe926e 100644 --- a/shared/menubar/remote-proxy.desktop.tsx +++ b/shared/menubar/remote-proxy.desktop.tsx @@ -12,8 +12,8 @@ import {serialize, type ProxyProps, type RemoteTlfUpdates} from './remote-serial import {useAvatarState} from '@/common-adapters/avatar/store' import type * as NotifConstants from '@/constants/notifications' import {useColorScheme} from 'react-native' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' import {useFollowerState} from '@/stores/followers' import {useUsersState} from '@/constants/users' import {useNotifState} from '@/constants/notifications' diff --git a/shared/profile/user/actions/index.tsx b/shared/profile/user/actions/index.tsx index 386e8981f8bb..58d78b0bbd1a 100644 --- a/shared/profile/user/actions/index.tsx +++ b/shared/profile/user/actions/index.tsx @@ -6,7 +6,7 @@ import FollowButton from './follow-button' import ChatButton from '@/chat/chat-button' import {useBotsState} from '@/stores/bots' import {useTrackerState} from '@/constants/tracker2' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/router-v2/header/syncing-folders.tsx b/shared/router-v2/header/syncing-folders.tsx index 578aa416f544..722a91e2bb98 100644 --- a/shared/router-v2/header/syncing-folders.tsx +++ b/shared/router-v2/header/syncing-folders.tsx @@ -1,9 +1,9 @@ import * as C from '@/constants' -import * as Constants from '@/constants/fs' +import * as Constants from '@/stores/fs' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import PieSlice from '@/fs/common/pie-slice' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' type OwnProps = { negative?: boolean diff --git a/shared/router-v2/router.shared.tsx b/shared/router-v2/router.shared.tsx index 7a88668f6157..a163de1ca0e3 100644 --- a/shared/router-v2/router.shared.tsx +++ b/shared/router-v2/router.shared.tsx @@ -4,7 +4,7 @@ import * as React from 'react' import {Splash} from '../login/loading' import type {Theme} from '@react-navigation/native' import {colors, darkColors, themed} from '@/styles/colors' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' import {useDarkModeState} from '@/constants/darkmode' export const SimpleLoading = React.memo(function SimpleLoading() { diff --git a/shared/router-v2/tab-bar.desktop.tsx b/shared/router-v2/tab-bar.desktop.tsx index 843f25c36ead..a3569650f3d3 100644 --- a/shared/router-v2/tab-bar.desktop.tsx +++ b/shared/router-v2/tab-bar.desktop.tsx @@ -15,7 +15,7 @@ import KB2 from '@/util/electron.desktop' import './tab-bar.css' import {settingsLogOutTab} from '@/constants/settings/util' import {useTrackerState} from '@/constants/tracker2' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' import {useProfileState} from '@/constants/profile' import {useNotifState} from '@/constants/notifications' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/settings/advanced.tsx b/shared/settings/advanced.tsx index 06bec08d7338..f72060b34b02 100644 --- a/shared/settings/advanced.tsx +++ b/shared/settings/advanced.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import {ProxySettings} from './proxy' import {useSettingsState, traceInProgressKey, processorProfileInProgressKey} from '@/constants/settings' import {usePWState} from '@/constants/settings-password' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' import {useConfigState} from '@/constants/config' let initialUseNativeFrame: boolean | undefined diff --git a/shared/settings/archive/index.tsx b/shared/settings/archive/index.tsx index 0ba0edd29d32..b69fa85c4fbf 100644 --- a/shared/settings/archive/index.tsx +++ b/shared/settings/archive/index.tsx @@ -4,8 +4,8 @@ import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {formatTimeForConversationList, formatTimeForChat} from '@/util/timestamp' import {useArchiveState} from '@/stores/archive' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' const ChatJob = React.memo(function ChatJob(p: {index: number; id: string}) { const {id, index} = p diff --git a/shared/settings/files/hooks.tsx b/shared/settings/files/hooks.tsx index 7cd0b2d730c2..e8e29a846900 100644 --- a/shared/settings/files/hooks.tsx +++ b/shared/settings/files/hooks.tsx @@ -1,6 +1,6 @@ import {defaultNotificationThreshold} from '.' import * as C from '@/constants' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const useFiles = () => { const {areSettingsLoading, setSpaceAvailableNotificationThreshold, spaceAvailableNotificationThreshold} = diff --git a/shared/settings/files/index.desktop.tsx b/shared/settings/files/index.desktop.tsx index c8abd4d17097..02c9475c612e 100644 --- a/shared/settings/files/index.desktop.tsx +++ b/shared/settings/files/index.desktop.tsx @@ -6,8 +6,8 @@ import * as Kbfs from '@/fs/common' import RefreshDriverStatusOnMount from '@/fs/common/refresh-driver-status-on-mount' import RefreshSettings from './refresh-settings' import useFiles from './hooks' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type Props = ReturnType export const allowedNotificationThresholds = [100 * 1024 ** 2, 1024 ** 3, 3 * 1024 ** 3, 10 * 1024 ** 3] diff --git a/shared/settings/files/index.native.tsx b/shared/settings/files/index.native.tsx index 66ecd2edf2f0..bbec8c0123d0 100644 --- a/shared/settings/files/index.native.tsx +++ b/shared/settings/files/index.native.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import useFiles from './hooks' -import * as FS from '@/constants/fs' -import {useFSState} from '@/constants/fs' +import * as FS from '@/stores/fs' +import {useFSState} from '@/stores/fs' type Props = ReturnType export const allowedNotificationThresholds = [100 * 1024 ** 2, 1024 ** 3, 3 * 1024 ** 3, 10 * 1024 ** 3] diff --git a/shared/settings/files/refresh-settings.tsx b/shared/settings/files/refresh-settings.tsx index aa4da1e72b56..383484e7b579 100644 --- a/shared/settings/files/refresh-settings.tsx +++ b/shared/settings/files/refresh-settings.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' const RefreshSettings = () => { const refresh = useFSState(s => s.dispatch.loadSettings) diff --git a/shared/stores/fs.tsx b/shared/stores/fs.tsx new file mode 100644 index 000000000000..b982fcf7ed09 --- /dev/null +++ b/shared/stores/fs.tsx @@ -0,0 +1,1812 @@ +import * as EngineGen from '@/actions/engine-gen-gen' +import {ignorePromise, timeoutPromise} from '../utils' +import * as S from '../strings' +import {requestPermissionsToWrite} from '../platform-specific' +import * as Tabs from '../tabs' +import * as T from '../types' +import * as Z from '@/util/zustand' +import NotifyPopup from '@/util/notify-popup' +import {RPCError} from '@/util/errors' +import logger from '@/logger' +import {tlfToPreferredOrder} from '@/util/kbfs' +import isObject from 'lodash/isObject' +import isEqual from 'lodash/isEqual' +import {navigateAppend, navigateUp} from '../router2/util' +import {storeRegistry} from '../store-registry' +import {useConfigState} from '../config' +import {useCurrentUserState} from '../current-user' +import * as Util from '@/constants/fs/util' + +export * from '@/constants/fs/util' + +const subscriptionDeduplicateIntervalSecond = 1 + +// RPC expects a string that's interpreted as [16]byte on Go side and it has to +// be unique among all ongoing ops at any given time. uuidv1 may exceed 16 +// bytes, so just roll something simple that's seeded with time. +// +// MAX_SAFE_INTEGER after toString(36) is 11 characters, so this should take <= +// 12 chars +const uuidSeed = Date.now().toString(36) + '-' +let counter = 0 +// We have 36^4=1,679,616 of space to work with in order to not exceed 16 +// bytes. +const counterMod = 36 * 36 * 36 * 36 +export const makeUUID = () => { + counter = (counter + 1) % counterMod + return uuidSeed + counter.toString(36) +} + +export const clientID = makeUUID() + +export const makeEditID = (): T.FS.EditID => T.FS.stringToEditID(makeUUID()) + +export const resetBannerType = (s: State, path: T.FS.Path): T.FS.ResetBannerType => { + const resetParticipants = Util.getTlfFromPath(s.tlfs, path).resetParticipants + if (resetParticipants.length === 0) { + return T.FS.ResetBannerNoOthersType.None + } + + const you = useCurrentUserState.getState().username + if (resetParticipants.findIndex(username => username === you) >= 0) { + return T.FS.ResetBannerNoOthersType.Self + } + return resetParticipants.length +} + +export const makeActionsForDestinationPickerOpen = (index: number, path: T.FS.Path) => { + useFSState.getState().dispatch.setDestinationPickerParentPath(index, path) + navigateAppend({props: {index}, selected: 'destinationPicker'}) +} + +const noAccessErrorCodes: Array = [ + T.RPCGen.StatusCode.scsimplefsnoaccess, + T.RPCGen.StatusCode.scteamnotfound, + T.RPCGen.StatusCode.scteamreaderror, +] + +export const errorToActionOrThrow = (error: unknown, path?: T.FS.Path) => { + if (!isObject(error)) return + const code = (error as {code?: T.RPCGen.StatusCode}).code + if (code === T.RPCGen.StatusCode.sckbfsclienttimeout) { + useFSState.getState().dispatch.checkKbfsDaemonRpcStatus() + return + } + if (code === T.RPCGen.StatusCode.scidentifiesfailed) { + // This is specifically to address the situation where when user tries to + // remove a shared TLF from their favorites but another user of the TLF has + // deleted their account the subscribePath call cauused from the popup will + // get SCIdentifiesFailed error. We can't do anything here so just move on. + // (Ideally we'd be able to tell it's becaue the user was deleted, but we + // don't have that from Go right now.) + // + // TODO: TRIAGE-2379 this should probably be ignored on Go side. We + // already use fsGui identifyBehavior and there's no reason we should get + // an identify error here. + return undefined + } + if (path && code === T.RPCGen.StatusCode.scsimplefsnotexist) { + useFSState.getState().dispatch.setPathSoftError(path, T.FS.SoftError.Nonexistent) + return + } + if (path && code && noAccessErrorCodes.includes(code)) { + const tlfPath = Util.getTlfPath(path) + if (tlfPath) { + useFSState.getState().dispatch.setTlfSoftError(tlfPath, T.FS.SoftError.NoAccess) + return + } + } + if (code === T.RPCGen.StatusCode.scdeleted) { + // The user is deleted. Let user know and move on. + useFSState.getState().dispatch.redbar('A user in this shared folder has deleted their account.') + return + } + throw error +} + +type Store = T.Immutable<{ + badge: T.RPCGen.FilesTabBadge + criticalUpdate: boolean + destinationPicker: T.FS.DestinationPicker + downloads: T.FS.Downloads + edits: T.FS.Edits + errors: ReadonlyArray + fileContext: ReadonlyMap + folderViewFilter: string | undefined // on mobile, '' is expanded empty, undefined is unexpanded + kbfsDaemonStatus: T.FS.KbfsDaemonStatus + lastPublicBannerClosedTlf: string + overallSyncStatus: T.FS.OverallSyncStatus + pathItemActionMenu: T.FS.PathItemActionMenu + pathItems: T.FS.PathItems + pathInfos: ReadonlyMap + pathUserSettings: ReadonlyMap + settings: T.FS.Settings + sfmi: T.FS.SystemFileManagerIntegration + softErrors: T.FS.SoftErrors + tlfUpdates: T.FS.UserTlfUpdates + tlfs: T.FS.Tlfs + uploads: T.FS.Uploads +}> +const initialStore: Store = { + badge: T.RPCGen.FilesTabBadge.none, + criticalUpdate: false, + destinationPicker: { + destinationParentPath: [], + source: { + type: T.FS.DestinationPickerSource.None, + }, + }, + downloads: { + info: new Map(), + regularDownloads: [], + state: new Map(), + }, + edits: new Map(), + errors: [], + fileContext: new Map(), + folderViewFilter: undefined, + kbfsDaemonStatus: Util.unknownKbfsDaemonStatus, + lastPublicBannerClosedTlf: '', + overallSyncStatus: Util.emptyOverallSyncStatus, + pathInfos: new Map(), + pathItemActionMenu: Util.emptyPathItemActionMenu, + pathItems: new Map(), + pathUserSettings: new Map(), + settings: Util.emptySettings, + sfmi: { + directMountDir: '', + driverStatus: Util.defaultDriverStatus, + preferredMountDirs: [], + }, + softErrors: { + pathErrors: new Map(), + tlfErrors: new Map(), + }, + tlfUpdates: [], + tlfs: { + additionalTlfs: new Map(), + loaded: false, + private: new Map(), + public: new Map(), + team: new Map(), + }, + uploads: { + endEstimate: undefined, + syncingPaths: new Set(), + totalSyncingBytes: 0, + writingToJournal: new Map(), + }, +} + +export interface State extends Store { + dispatch: { + cancelDownload: (downloadID: string) => void + checkKbfsDaemonRpcStatus: () => void + commitEdit: (editID: T.FS.EditID) => void + deleteFile: (path: T.FS.Path) => void + discardEdit: (editID: T.FS.EditID) => void + dismissDownload: (downloadID: string) => void + dismissRedbar: (index: number) => void + dismissUpload: (uploadID: string) => void + download: (path: T.FS.Path, type: 'download' | 'share' | 'saveMedia') => void + driverDisable: () => void + driverDisabling: () => void + driverEnable: (isRetry?: boolean) => void + driverKextPermissionError: () => void + dynamic: { + afterDriverDisable?: () => void + afterDriverDisabling?: () => void + afterDriverEnabled?: (isRetry: boolean) => void + afterKbfsDaemonRpcStatusChanged?: () => void + finishedDownloadWithIntentMobile?: ( + downloadID: string, + downloadIntent: T.FS.DownloadIntent, + mimeType: string + ) => void + finishedRegularDownloadMobile?: (downloadID: string, mimeType: string) => void + openFilesFromWidgetDesktop?: (path: T.FS.Path) => void + openAndUploadDesktop?: (type: T.FS.OpenDialogType, parentPath: T.FS.Path) => void + pickAndUploadMobile?: (type: T.FS.MobilePickType, parentPath: T.FS.Path) => void + openLocalPathInSystemFileManagerDesktop?: (localPath: string) => void + openPathInSystemFileManagerDesktop?: (path: T.FS.Path) => void + openSecurityPreferencesDesktop?: () => void + refreshDriverStatusDesktop?: () => void + refreshMountDirsDesktop?: () => void + setSfmiBannerDismissedDesktop?: (dismissed: boolean) => void + uploadFromDragAndDropDesktop?: (parentPath: T.FS.Path, localPaths: Array) => void + } + editError: (editID: T.FS.EditID, error: string) => void + editSuccess: (editID: T.FS.EditID) => void + favoritesLoad: () => void + favoriteIgnore: (path: T.FS.Path) => void + finishManualConflictResolution: (localViewTlfPath: T.FS.Path) => void + folderListLoad: (path: T.FS.Path, recursive: boolean) => void + getOnlineStatus: () => void + journalUpdate: (syncingPaths: Array, totalSyncingBytes: number, endEstimate?: number) => void + kbfsDaemonOnlineStatusChanged: (onlineStatus: T.RPCGen.KbfsOnlineStatus) => void + kbfsDaemonRpcStatusChanged: (rpcStatus: T.FS.KbfsDaemonRpcStatus) => void + letResetUserBackIn: (id: T.RPCGen.TeamID, username: string) => void + loadAdditionalTlf: (tlfPath: T.FS.Path) => void + loadFileContext: (path: T.FS.Path) => void + loadFilesTabBadge: () => void + loadPathInfo: (path: T.FS.Path) => void + loadPathMetadata: (path: T.FS.Path) => void + loadSettings: () => void + loadTlfSyncConfig: (tlfPath: T.FS.Path) => void + loadUploadStatus: () => void + loadDownloadInfo: (downloadID: string) => void + loadDownloadStatus: () => void + loadedPathInfo: (path: T.FS.Path, info: T.FS.PathInfo) => void + newFolderRow: (parentPath: T.FS.Path) => void + moveOrCopy: (destinationParentPath: T.FS.Path, type: 'move' | 'copy') => void + onChangedFocus: (appFocused: boolean) => void + onEngineIncomingImpl: (action: EngineGen.Actions) => void + onPathChange: ( + clientID: string, + path: string, + topics: ReadonlyArray + ) => void + onSubscriptionNotify: (clientID: string, topic: T.RPCGen.SubscriptionTopic) => void + pollJournalStatus: () => void + redbar: (error: string) => void + resetState: () => void + setCriticalUpdate: (u: boolean) => void + setDebugLevel: (level: string) => void + setDestinationPickerParentPath: (index: number, path: T.FS.Path) => void + setDirectMountDir: (directMountDir: string) => void + setDriverStatus: (driverStatus: T.FS.DriverStatus) => void + setEditName: (editID: T.FS.EditID, name: string) => void + setFolderViewFilter: (filter?: string) => void + setIncomingShareSource: (source: ReadonlyArray) => void + setLastPublicBannerClosedTlf: (tlf: string) => void + setMoveOrCopySource: (path: T.FS.Path) => void + setPathItemActionMenuDownload: (downloadID?: string, intent?: T.FS.DownloadIntent) => void + setPathItemActionMenuView: (view: T.FS.PathItemActionMenuView) => void + setPreferredMountDirs: (preferredMountDirs: ReadonlyArray) => void + setPathSoftError: (path: T.FS.Path, softError?: T.FS.SoftError) => void + setSpaceAvailableNotificationThreshold: (spaceAvailableNotificationThreshold: number) => void + setTlfSoftError: (path: T.FS.Path, softError?: T.FS.SoftError) => void + setTlfsAsUnloaded: () => void + setTlfSyncConfig: (tlfPath: T.FS.Path, enabled: boolean) => void + setSorting: (path: T.FS.Path, sortSetting: T.FS.SortSetting) => void + setupSubscriptions: () => Promise + showIncomingShare: (initialDestinationParentPath: T.FS.Path) => void + showMoveOrCopy: (initialDestinationParentPath: T.FS.Path) => void + startManualConflictResolution: (tlfPath: T.FS.Path) => void + startRename: (path: T.FS.Path) => void + subscribeNonPath: (subscriptionID: string, topic: T.RPCGen.SubscriptionTopic) => void + subscribePath: (subscriptionID: string, path: T.FS.Path, topic: T.RPCGen.PathSubscriptionTopic) => void + syncStatusChanged: (status: T.RPCGen.FolderSyncStatus) => void + unsubscribe: (subscriptionID: string) => void + upload: (parentPath: T.FS.Path, localPath: string) => void + userIn: () => void + userOut: () => void + userFileEditsLoad: () => void + waitForKbfsDaemon: () => void + } + getUploadIconForFilesTab: () => T.FS.UploadIcon | undefined +} + +const getPrefetchStatusFromRPC = ( + prefetchStatus: T.RPCGen.PrefetchStatus, + prefetchProgress: T.RPCGen.PrefetchProgress +) => { + switch (prefetchStatus) { + case T.RPCGen.PrefetchStatus.notStarted: + return Util.prefetchNotStarted + case T.RPCGen.PrefetchStatus.inProgress: + return { + ...Util.emptyPrefetchInProgress, + bytesFetched: prefetchProgress.bytesFetched, + bytesTotal: prefetchProgress.bytesTotal, + endEstimate: prefetchProgress.endEstimate, + startTime: prefetchProgress.start, + } + case T.RPCGen.PrefetchStatus.complete: + return Util.prefetchComplete + default: + return Util.prefetchNotStarted + } +} + +const direntToMetadata = (d: T.RPCGen.Dirent) => ({ + lastModifiedTimestamp: d.time, + lastWriter: d.lastWriterUnverified.username, + name: d.name.split('/').pop(), + prefetchStatus: getPrefetchStatusFromRPC(d.prefetchStatus, d.prefetchProgress), + size: d.size, + writable: d.writable, +}) + +const makeEntry = (d: T.RPCGen.Dirent, children?: Set): T.FS.PathItem => { + switch (d.direntType) { + case T.RPCGen.DirentType.dir: + return { + ...Util.emptyFolder, + ...direntToMetadata(d), + children: new Set(children || []), + progress: children ? T.FS.ProgressType.Loaded : T.FS.ProgressType.Pending, + } as T.FS.PathItem + case T.RPCGen.DirentType.sym: + return { + ...Util.emptySymlink, + ...direntToMetadata(d), + // TODO: plumb link target + } as T.FS.PathItem + case T.RPCGen.DirentType.file: + case T.RPCGen.DirentType.exec: + return { + ...Util.emptyFile, + ...direntToMetadata(d), + } as T.FS.PathItem + } +} + +const updatePathItem = ( + oldPathItem: T.Immutable, + newPathItemFromAction: T.Immutable +): T.Immutable => { + if ( + oldPathItem.type === T.FS.PathType.Folder && + newPathItemFromAction.type === T.FS.PathType.Folder && + oldPathItem.progress === T.FS.ProgressType.Loaded && + newPathItemFromAction.progress === T.FS.ProgressType.Pending + ) { + // The new one doesn't have children, but the old one has. We don't + // want to override a loaded folder into pending. So first set the children + // in new one using what we already have, see if they are equal. + const newPathItemNoOverridingChildrenAndProgress = { + ...newPathItemFromAction, + children: oldPathItem.children, + progress: T.FS.ProgressType.Loaded, + } + return newPathItemNoOverridingChildrenAndProgress + } + return newPathItemFromAction +} + +export const useFSState = Z.createZustand((set, get) => { + // Can't rely on kbfsDaemonStatus.rpcStatus === 'waiting' as that's set by + // reducer and happens before this. + let waitForKbfsDaemonInProgress = false + + const getUploadIconForFilesTab = () => { + switch (get().badge) { + case T.RPCGen.FilesTabBadge.awaitingUpload: + return T.FS.UploadIcon.AwaitingToUpload + case T.RPCGen.FilesTabBadge.uploadingStuck: + return T.FS.UploadIcon.UploadingStuck + case T.RPCGen.FilesTabBadge.uploading: + return T.FS.UploadIcon.Uploading + case T.RPCGen.FilesTabBadge.none: + return undefined + } + } + + // At start-up we might have a race where we get connected to a kbfs daemon + // which dies soon after, and we get an EOF here. So retry for a few times + // until we get through. After each try we delay for 2s, so this should give us + // e.g. 12s when n == 6. If it still doesn't work after 12s, something's wrong + // and we deserve a black bar. + const checkIfWeReConnectedToMDServerUpToNTimes = async (n: number): Promise => { + try { + const onlineStatus = await T.RPCGen.SimpleFSSimpleFSGetOnlineStatusRpcPromise({clientID}) + get().dispatch.kbfsDaemonOnlineStatusChanged(onlineStatus) + return + } catch (error) { + if (n > 0) { + logger.warn(`failed to check if we are connected to MDServer: ${String(error)}; n=${n}`) + await timeoutPromise(2000) + return checkIfWeReConnectedToMDServerUpToNTimes(n - 1) + } else { + logger.warn(`failed to check if we are connected to MDServer : ${String(error)}; n=${n}, throwing`) + throw error + } + } + } + + let fsBadgeSubscriptionID: string = '' + let settingsSubscriptionID: string = '' + let uploadStatusSubscriptionID: string = '' + let journalStatusSubscriptionID: string = '' + let pollJournalStatusPolling = false + + const dispatch: State['dispatch'] = { + cancelDownload: downloadID => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSCancelDownloadRpcPromise({downloadID}) + } + ignorePromise(f()) + }, + checkKbfsDaemonRpcStatus: () => { + const f = async () => { + const connected = await T.RPCGen.configWaitForClientRpcPromise({ + clientType: T.RPCGen.ClientType.kbfs, + timeout: 0, // Don't wait; just check if it's there. + }) + const newStatus = connected ? T.FS.KbfsDaemonRpcStatus.Connected : T.FS.KbfsDaemonRpcStatus.Waiting + const kbfsDaemonStatus = get().kbfsDaemonStatus + const {kbfsDaemonRpcStatusChanged, waitForKbfsDaemon} = get().dispatch + + if (kbfsDaemonStatus.rpcStatus !== newStatus) { + kbfsDaemonRpcStatusChanged(newStatus) + } + if (newStatus === T.FS.KbfsDaemonRpcStatus.Waiting) { + waitForKbfsDaemon() + } + } + ignorePromise(f()) + }, + commitEdit: editID => { + const edit = get().edits.get(editID) + if (!edit) { + return + } + const f = async () => { + switch (edit.type) { + case T.FS.EditType.NewFolder: + try { + await T.RPCGen.SimpleFSSimpleFSOpenRpcPromise( + { + dest: Util.pathToRPCPath(T.FS.pathConcat(edit.parentPath, edit.name)), + flags: T.RPCGen.OpenFlags.directory, + opID: makeUUID(), + }, + S.waitingKeyFSCommitEdit + ) + get().dispatch.editSuccess(editID) + return + } catch (e) { + errorToActionOrThrow(e, edit.parentPath) + return + } + case T.FS.EditType.Rename: + try { + const opID = makeUUID() + await T.RPCGen.SimpleFSSimpleFSMoveRpcPromise({ + dest: Util.pathToRPCPath(T.FS.pathConcat(edit.parentPath, edit.name)), + opID, + overwriteExistingFiles: false, + src: Util.pathToRPCPath(T.FS.pathConcat(edit.parentPath, edit.originalName)), + }) + await T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}, S.waitingKeyFSCommitEdit) + get().dispatch.editSuccess(editID) + return + } catch (error) { + if (!(error instanceof RPCError)) { + return + } + if ( + [ + T.RPCGen.StatusCode.scsimplefsnameexists, + T.RPCGen.StatusCode.scsimplefsdirnotempty, + ].includes(error.code) + ) { + get().dispatch.editError(editID, error.desc || 'name exists') + return + } + throw error + } + } + } + ignorePromise(f()) + }, + deleteFile: path => { + const f = async () => { + const opID = makeUUID() + try { + await T.RPCGen.SimpleFSSimpleFSRemoveRpcPromise({ + opID, + path: Util.pathToRPCPath(path), + recursive: true, + }) + await T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}) + } catch (e) { + errorToActionOrThrow(e, path) + } + } + ignorePromise(f()) + }, + discardEdit: editID => { + set(s => { + s.edits.delete(editID) + }) + }, + dismissDownload: downloadID => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSDismissDownloadRpcPromise({downloadID}) + } + ignorePromise(f()) + }, + dismissRedbar: index => { + set(s => { + s.errors = [...s.errors.slice(0, index), ...s.errors.slice(index + 1)] + }) + }, + dismissUpload: uploadID => { + const f = async () => { + try { + await T.RPCGen.SimpleFSSimpleFSDismissUploadRpcPromise({uploadID}) + } catch {} + } + ignorePromise(f()) + }, + download: (path, type) => { + const f = async () => { + await requestPermissionsToWrite() + const downloadID = await T.RPCGen.SimpleFSSimpleFSStartDownloadRpcPromise({ + isRegularDownload: type === 'download', + path: Util.pathToRPCPath(path).kbfs, + }) + if (type !== 'download') { + get().dispatch.setPathItemActionMenuDownload( + downloadID, + type === 'share' ? T.FS.DownloadIntent.Share : T.FS.DownloadIntent.CameraRoll + ) + } + } + ignorePromise(f()) + }, + driverDisable: () => { + get().dispatch.dynamic.afterDriverDisable?.() + }, + driverDisabling: () => { + set(s => { + if (s.sfmi.driverStatus.type === T.FS.DriverStatusType.Enabled) { + s.sfmi.driverStatus.isDisabling = true + } + }) + get().dispatch.dynamic.afterDriverDisabling?.() + }, + driverEnable: isRetry => { + set(s => { + if (s.sfmi.driverStatus.type === T.FS.DriverStatusType.Disabled) { + s.sfmi.driverStatus.isEnabling = true + } + }) + get().dispatch.dynamic.afterDriverEnabled?.(!!isRetry) + }, + driverKextPermissionError: () => { + set(s => { + if (s.sfmi.driverStatus.type === T.FS.DriverStatusType.Disabled) { + s.sfmi.driverStatus.kextPermissionError = true + s.sfmi.driverStatus.isEnabling = false + } + }) + }, + dynamic: { + afterDriverDisable: undefined, + afterDriverDisabling: undefined, + afterDriverEnabled: undefined, + afterKbfsDaemonRpcStatusChanged: undefined, + finishedDownloadWithIntentMobile: undefined, + finishedRegularDownloadMobile: undefined, + openAndUploadDesktop: undefined, + openFilesFromWidgetDesktop: undefined, + openLocalPathInSystemFileManagerDesktop: undefined, + openPathInSystemFileManagerDesktop: undefined, + openSecurityPreferencesDesktop: undefined, + pickAndUploadMobile: undefined, + refreshDriverStatusDesktop: undefined, + refreshMountDirsDesktop: undefined, + setSfmiBannerDismissedDesktop: undefined, + uploadFromDragAndDropDesktop: undefined, + }, + editError: (editID, error) => { + set(s => { + const e = s.edits.get(editID) + if (e) e.error = error + }) + }, + editSuccess: editID => { + set(s => { + s.edits.delete(editID) + }) + }, + favoriteIgnore: path => { + const f = async () => { + const folder = Util.folderRPCFromPath(path) + if (!folder) { + throw new Error('No folder specified') + } + try { + await T.RPCGen.favoriteFavoriteIgnoreRpcPromise({folder}) + } catch (error) { + errorToActionOrThrow(error, path) + set(s => { + const elems = T.FS.getPathElements(path) + const visibility = T.FS.getVisibilityFromElems(elems) + if (!visibility) { + return + } + s.tlfs[visibility] = new Map(s.tlfs[visibility]) + s.tlfs[visibility].set( + elems[2] ?? '', + T.castDraft({ + ...(s.tlfs[visibility].get(elems[2] ?? '') || Util.unknownTlf), + isIgnored: false, + }) + ) + }) + } + } + set(s => { + const elems = T.FS.getPathElements(path) + const visibility = T.FS.getVisibilityFromElems(elems) + if (!visibility) { + return + } + s.tlfs[visibility] = new Map(s.tlfs[visibility]) + s.tlfs[visibility].set( + elems[2] ?? '', + T.castDraft({ + ...(s.tlfs[visibility].get(elems[2] ?? '') || Util.unknownTlf), + isIgnored: true, + }) + ) + }) + ignorePromise(f()) + }, + favoritesLoad: () => { + const f = async () => { + try { + if (!useConfigState.getState().loggedIn) { + return + } + const results = await T.RPCGen.SimpleFSSimpleFSListFavoritesRpcPromise() + const payload = { + private: new Map(), + public: new Map(), + team: new Map(), + } as const + const fs = [ + ...(results.favoriteFolders + ? [{folders: results.favoriteFolders, isFavorite: true, isIgnored: false, isNew: false}] + : []), + ...(results.ignoredFolders + ? [{folders: results.ignoredFolders, isFavorite: false, isIgnored: true, isNew: false}] + : []), + ...(results.newFolders + ? [{folders: results.newFolders, isFavorite: true, isIgnored: false, isNew: true}] + : []), + ] + fs.forEach(({folders, isFavorite, isIgnored, isNew}) => + folders.forEach(folder => { + const tlfType = Util.rpcFolderTypeToTlfType(folder.folderType) + const tlfName = + tlfType === T.FS.TlfType.Private || tlfType === T.FS.TlfType.Public + ? tlfToPreferredOrder(folder.name, useCurrentUserState.getState().username) + : folder.name + tlfType && + payload[tlfType].set( + tlfName, + Util.makeTlf({ + conflictState: Util.rpcConflictStateToConflictState(folder.conflictState || undefined), + isFavorite, + isIgnored, + isNew, + name: tlfName, + resetParticipants: (folder.reset_members || []).map(({username}) => username), + syncConfig: Util.getSyncConfigFromRPC(tlfName, tlfType, folder.syncConfig || undefined), + teamId: folder.team_id || '', + tlfMtime: folder.mtime || 0, + }) + ) + }) + ) + + if (payload.private.size) { + set(s => { + s.tlfs.private = T.castDraft(payload.private) + s.tlfs.public = T.castDraft(payload.public) + s.tlfs.team = T.castDraft(payload.team) + s.tlfs.loaded = true + }) + const counts = new Map() + counts.set(Tabs.fsTab, Util.computeBadgeNumberForAll(get().tlfs)) + storeRegistry.getState('notifications').dispatch.setBadgeCounts(counts) + } + } catch (e) { + errorToActionOrThrow(e) + } + return + } + ignorePromise(f()) + }, + finishManualConflictResolution: localViewTlfPath => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSFinishResolvingConflictRpcPromise({ + path: Util.pathToRPCPath(localViewTlfPath), + }) + get().dispatch.favoritesLoad() + } + ignorePromise(f()) + }, + folderListLoad: (rootPath, isRecursive) => { + const f = async () => { + try { + const opID = makeUUID() + if (isRecursive) { + await T.RPCGen.SimpleFSSimpleFSListRecursiveToDepthRpcPromise({ + depth: 1, + filter: T.RPCGen.ListFilter.filterSystemHidden, + opID, + path: Util.pathToRPCPath(rootPath), + refreshSubscription: false, + }) + } else { + await T.RPCGen.SimpleFSSimpleFSListRpcPromise({ + filter: T.RPCGen.ListFilter.filterSystemHidden, + opID, + path: Util.pathToRPCPath(rootPath), + refreshSubscription: false, + }) + } + + await T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}, S.waitingKeyFSFolderList) + + const result = await T.RPCGen.SimpleFSSimpleFSReadListRpcPromise({opID}) + const entries = result.entries || [] + const childMap = entries.reduce((m, d) => { + const [parent, child] = d.name.split('/') + if (child) { + // Only add to the children set if the parent definitely has children. + const fullParent = T.FS.pathConcat(rootPath, parent ?? '') + let children = m.get(fullParent) + if (!children) { + children = new Set() + m.set(fullParent, children) + } + children.add(child) + } else { + let children = m.get(rootPath) + if (!children) { + children = new Set() + m.set(rootPath, children) + } + children.add(d.name) + } + return m + }, new Map>()) + + const direntToPathAndPathItem = (d: T.RPCGen.Dirent) => { + const path = T.FS.pathConcat(rootPath, d.name) + const entry = makeEntry(d, childMap.get(path)) + if (entry.type === T.FS.PathType.Folder && isRecursive && !d.name.includes('/')) { + // Since we are loading with a depth of 2, first level directories are + // considered "loaded". + return [ + path, + { + ...entry, + progress: T.FS.ProgressType.Loaded, + }, + ] as const + } + return [path, entry] as const + } + + // Get metadata fields of the directory that we just loaded from state to + // avoid overriding them. + const rootPathItem = Util.getPathItem(get().pathItems, rootPath) + const rootFolder: T.FS.FolderPathItem = { + ...(rootPathItem.type === T.FS.PathType.Folder + ? rootPathItem + : {...Util.emptyFolder, name: T.FS.getPathName(rootPath)}), + children: new Set(childMap.get(rootPath)), + progress: T.FS.ProgressType.Loaded, + } + + const pathItems = new Map([ + ...(T.FS.getPathLevel(rootPath) > 2 ? [[rootPath, rootFolder] as const] : []), + ...entries.map(direntToPathAndPathItem), + ] as const) + set(s => { + pathItems.forEach((pathItemFromAction, path) => { + const oldPathItem = Util.getPathItem(s.pathItems, path) + const newPathItem = updatePathItem(oldPathItem, pathItemFromAction) + oldPathItem.type === T.FS.PathType.Folder && + oldPathItem.children.forEach( + name => + (newPathItem.type !== T.FS.PathType.Folder || !newPathItem.children.has(name)) && + s.pathItems.delete(T.FS.pathConcat(path, name)) + ) + s.pathItems.set(path, T.castDraft(newPathItem)) + }) + + // Remove Rename edits that are for path items that don't exist anymore in + // case when/if a new item is added later the edit causes confusion. + const newEntries = [...s.edits.entries()].filter(([_, edit]) => { + if (edit.type !== T.FS.EditType.Rename) { + return true + } + const parent = Util.getPathItem(s.pathItems, edit.parentPath) + if (parent.type === T.FS.PathType.Folder && parent.children.has(edit.name)) { + return true + } + return false + }) + if (newEntries.length !== s.edits.size) { + s.edits = new Map(newEntries) + } + }) + } catch (error) { + errorToActionOrThrow(error, rootPath) + return + } + } + ignorePromise(f()) + }, + getOnlineStatus: () => { + const f = async () => { + await checkIfWeReConnectedToMDServerUpToNTimes(2) + } + ignorePromise(f()) + }, + journalUpdate: (syncingPaths, totalSyncingBytes, endEstimate) => { + set(s => { + const sp = new Set(syncingPaths) + if (!isEqual(sp, s.uploads.syncingPaths)) { + s.uploads.syncingPaths = sp + } + s.uploads.totalSyncingBytes = totalSyncingBytes + s.uploads.endEstimate = endEstimate + }) + }, + kbfsDaemonOnlineStatusChanged: onlineStatus => { + set(s => { + s.kbfsDaemonStatus.onlineStatus = + onlineStatus === T.RPCGen.KbfsOnlineStatus.offline + ? T.FS.KbfsDaemonOnlineStatus.Offline + : onlineStatus === T.RPCGen.KbfsOnlineStatus.trying + ? T.FS.KbfsDaemonOnlineStatus.Trying + : // eslint-disable-next-line + onlineStatus === T.RPCGen.KbfsOnlineStatus.online + ? T.FS.KbfsDaemonOnlineStatus.Online + : T.FS.KbfsDaemonOnlineStatus.Unknown + }) + }, + kbfsDaemonRpcStatusChanged: rpcStatus => { + set(s => { + if (rpcStatus !== T.FS.KbfsDaemonRpcStatus.Connected) { + s.kbfsDaemonStatus.onlineStatus = T.FS.KbfsDaemonOnlineStatus.Offline + } + s.kbfsDaemonStatus.rpcStatus = rpcStatus + }) + + const kbfsDaemonStatus = get().kbfsDaemonStatus + if (kbfsDaemonStatus.rpcStatus !== T.FS.KbfsDaemonRpcStatus.Connected) { + get().dispatch.setTlfsAsUnloaded() + } + + const subscribeAndLoadFsBadge = () => { + const oldFsBadgeSubscriptionID = fsBadgeSubscriptionID + fsBadgeSubscriptionID = makeUUID() + const kbfsDaemonStatus = get().kbfsDaemonStatus + if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { + if (oldFsBadgeSubscriptionID) { + get().dispatch.unsubscribe(oldFsBadgeSubscriptionID) + } + get().dispatch.subscribeNonPath(fsBadgeSubscriptionID, T.RPCGen.SubscriptionTopic.filesTabBadge) + get().dispatch.loadFilesTabBadge() + } + } + + subscribeAndLoadFsBadge() + + const subscribeAndLoadSettings = () => { + const oldSettingsSubscriptionID = settingsSubscriptionID + settingsSubscriptionID = makeUUID() + const kbfsDaemonStatus = get().kbfsDaemonStatus + if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { + get().dispatch.loadSettings() + } + + if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { + if (oldSettingsSubscriptionID) { + get().dispatch.unsubscribe(oldSettingsSubscriptionID) + } + get().dispatch.subscribeNonPath(settingsSubscriptionID, T.RPCGen.SubscriptionTopic.settings) + } + } + subscribeAndLoadSettings() + + const subscribeAndLoadUploadStatus = () => { + const oldUploadStatusSubscriptionID = uploadStatusSubscriptionID + uploadStatusSubscriptionID = makeUUID() + const kbfsDaemonStatus = get().kbfsDaemonStatus + + if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { + get().dispatch.loadUploadStatus() + } + + if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { + if (oldUploadStatusSubscriptionID) { + get().dispatch.unsubscribe(oldUploadStatusSubscriptionID) + } + + get().dispatch.subscribeNonPath(uploadStatusSubscriptionID, T.RPCGen.SubscriptionTopic.uploadStatus) + } + } + subscribeAndLoadUploadStatus() + + const subscribeAndLoadJournalStatus = () => { + const oldJournalStatusSubscriptionID = journalStatusSubscriptionID + journalStatusSubscriptionID = makeUUID() + const kbfsDaemonStatus = get().kbfsDaemonStatus + if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { + if (oldJournalStatusSubscriptionID) { + get().dispatch.unsubscribe(oldJournalStatusSubscriptionID) + } + get().dispatch.subscribeNonPath( + journalStatusSubscriptionID, + T.RPCGen.SubscriptionTopic.journalStatus + ) + get().dispatch.pollJournalStatus() + } + } + subscribeAndLoadJournalStatus() + // how this works isn't great. This function gets called way early before we set this + get().dispatch.dynamic.afterKbfsDaemonRpcStatusChanged?.() + }, + letResetUserBackIn: (id, username) => { + const f = async () => { + try { + await T.RPCGen.teamsTeamReAddMemberAfterResetRpcPromise({id, username}) + } catch (error) { + errorToActionOrThrow(error) + } + } + ignorePromise(f()) + }, + loadAdditionalTlf: tlfPath => { + const f = async () => { + if (T.FS.getPathLevel(tlfPath) !== 3) { + logger.warn('loadAdditionalTlf called on non-TLF path') + return + } + try { + const {folder, isFavorite, isIgnored, isNew} = await T.RPCGen.SimpleFSSimpleFSGetFolderRpcPromise({ + path: Util.pathToRPCPath(tlfPath).kbfs, + }) + const tlfType = Util.rpcFolderTypeToTlfType(folder.folderType) + const tlfName = + tlfType === T.FS.TlfType.Private || tlfType === T.FS.TlfType.Public + ? tlfToPreferredOrder(folder.name, useCurrentUserState.getState().username) + : folder.name + + if (tlfType) { + set(s => { + s.tlfs.additionalTlfs.set( + tlfPath, + T.castDraft( + Util.makeTlf({ + conflictState: Util.rpcConflictStateToConflictState(folder.conflictState || undefined), + isFavorite, + isIgnored, + isNew, + name: tlfName, + resetParticipants: (folder.reset_members || []).map(({username}) => username), + syncConfig: Util.getSyncConfigFromRPC(tlfName, tlfType, folder.syncConfig || undefined), + teamId: folder.team_id || '', + tlfMtime: folder.mtime || 0, + }) + ) + ) + }) + } + } catch (error) { + if (!(error instanceof RPCError)) { + return + } + if (error.code === T.RPCGen.StatusCode.scteamcontactsettingsblock) { + const fields = error.fields as undefined | Array<{key?: string; value?: string}> + const users = fields?.filter(elem => elem.key === 'usernames') + const usernames = users?.map(elem => elem.value ?? '') ?? [] + // Don't leave the user on a broken FS dir screen. + navigateUp() + navigateAppend({ + props: {source: 'newFolder', usernames}, + selected: 'contactRestricted', + }) + } + errorToActionOrThrow(error, tlfPath) + } + } + ignorePromise(f()) + }, + loadDownloadInfo: downloadID => { + const f = async () => { + try { + const res = await T.RPCGen.SimpleFSSimpleFSGetDownloadInfoRpcPromise({ + downloadID, + }) + set(s => { + s.downloads.info.set(downloadID, { + filename: res.filename, + isRegularDownload: res.isRegularDownload, + path: T.FS.stringToPath('/keybase' + res.path.path), + startTime: res.startTime, + }) + }) + } catch (error) { + errorToActionOrThrow(error) + } + } + ignorePromise(f()) + }, + loadDownloadStatus: () => { + const f = async () => { + try { + const res = await T.RPCGen.SimpleFSSimpleFSGetDownloadStatusRpcPromise() + + const regularDownloads = res.regularDownloadIDs || [] + const state = new Map( + (res.states || []).map(s => [ + s.downloadID, + { + canceled: s.canceled, + done: s.done, + endEstimate: s.endEstimate, + error: s.error, + localPath: s.localPath, + progress: s.progress, + }, + ]) + ) + + set(s => { + s.downloads.regularDownloads = T.castDraft(regularDownloads) + s.downloads.state = state + + const toDelete = [...s.downloads.info.keys()].filter(downloadID => !state.has(downloadID)) + if (toDelete.length) { + toDelete.forEach(downloadID => s.downloads.info.delete(downloadID)) + } + }) + } catch (error) { + errorToActionOrThrow(error) + } + } + ignorePromise(f()) + }, + loadFileContext: path => { + const f = async () => { + try { + const res = await T.RPCGen.SimpleFSSimpleFSGetGUIFileContextRpcPromise({ + path: Util.pathToRPCPath(path).kbfs, + }) + + set(s => { + s.fileContext.set(path, { + contentType: res.contentType, + url: res.url, + viewType: res.viewType, + }) + }) + } catch (err) { + errorToActionOrThrow(err) + return + } + } + ignorePromise(f()) + }, + loadFilesTabBadge: () => { + const f = async () => { + try { + const badge = await T.RPCGen.SimpleFSSimpleFSGetFilesTabBadgeRpcPromise() + set(s => { + s.badge = badge + }) + } catch { + // retry once HOTPOT-1226 + try { + const badge = await T.RPCGen.SimpleFSSimpleFSGetFilesTabBadgeRpcPromise() + set(s => { + s.badge = badge + }) + } catch {} + } + } + ignorePromise(f()) + }, + loadPathInfo: path => { + const f = async () => { + const pathInfo = await T.RPCGen.kbfsMountGetKBFSPathInfoRpcPromise({ + standardPath: T.FS.pathToString(path), + }) + get().dispatch.loadedPathInfo(path, { + deeplinkPath: pathInfo.deeplinkPath, + platformAfterMountPath: pathInfo.platformAfterMountPath, + }) + } + ignorePromise(f()) + }, + loadPathMetadata: path => { + const f = async () => { + try { + const dirent = await T.RPCGen.SimpleFSSimpleFSStatRpcPromise( + { + path: Util.pathToRPCPath(path), + refreshSubscription: false, + }, + S.waitingKeyFSStat + ) + + const pathItem = makeEntry(dirent) + set(s => { + const oldPathItem = Util.getPathItem(s.pathItems, path) + s.pathItems.set(path, T.castDraft(updatePathItem(oldPathItem, pathItem))) + s.softErrors.pathErrors.delete(path) + s.softErrors.tlfErrors.delete(path) + }) + } catch (err) { + errorToActionOrThrow(err, path) + return + } + } + ignorePromise(f()) + }, + loadSettings: () => { + const f = async () => { + set(s => { + s.settings.isLoading = true + }) + try { + const settings = await T.RPCGen.SimpleFSSimpleFSSettingsRpcPromise() + set(s => { + const o = s.settings + o.isLoading = false + o.loaded = true + o.sfmiBannerDismissed = settings.sfmiBannerDismissed + o.spaceAvailableNotificationThreshold = settings.spaceAvailableNotificationThreshold + o.syncOnCellular = settings.syncOnCellular + }) + } catch { + set(s => { + s.settings.isLoading = false + }) + } + } + ignorePromise(f()) + }, + loadTlfSyncConfig: tlfPath => { + const f = async () => { + const parsedPath = Util.parsePath(tlfPath) + if (parsedPath.kind !== T.FS.PathKind.GroupTlf && parsedPath.kind !== T.FS.PathKind.TeamTlf) { + return + } + try { + const result = await T.RPCGen.SimpleFSSimpleFSFolderSyncConfigAndStatusRpcPromise({ + path: Util.pathToRPCPath(tlfPath), + }) + const syncConfig = Util.getSyncConfigFromRPC(parsedPath.tlfName, parsedPath.tlfType, result.config) + const tlfName = parsedPath.tlfName + const tlfType = parsedPath.tlfType + + set(s => { + const oldTlfList = s.tlfs[tlfType] + const oldTlfFromFavorites = oldTlfList.get(tlfName) || Util.unknownTlf + if (oldTlfFromFavorites !== Util.unknownTlf) { + s.tlfs[tlfType] = T.castDraft( + new Map([...oldTlfList, [tlfName, {...oldTlfFromFavorites, syncConfig}]]) + ) + return + } + + const tlfPath = T.FS.pathConcat(T.FS.pathConcat(Util.defaultPath, tlfType), tlfName) + const oldTlfFromAdditional = s.tlfs.additionalTlfs.get(tlfPath) || Util.unknownTlf + if (oldTlfFromAdditional !== Util.unknownTlf) { + s.tlfs.additionalTlfs = T.castDraft( + new Map([...s.tlfs.additionalTlfs, [tlfPath, {...oldTlfFromAdditional, syncConfig}]]) + ) + return + } + }) + } catch (e) { + errorToActionOrThrow(e, tlfPath) + return + } + } + ignorePromise(f()) + }, + loadUploadStatus: () => { + const f = async () => { + try { + const uploadStates = await T.RPCGen.SimpleFSSimpleFSGetUploadStatusRpcPromise() + set(s => { + // return FsGen.createLoadedUploadStatus({uploadStates: uploadStates || []}) + + const writingToJournal = new Map( + uploadStates?.map(uploadState => { + const path = Util.rpcPathToPath(uploadState.targetPath) + const oldUploadState = s.uploads.writingToJournal.get(path) + return [ + path, + oldUploadState && + uploadState.error === oldUploadState.error && + uploadState.canceled === oldUploadState.canceled && + uploadState.uploadID === oldUploadState.uploadID + ? oldUploadState + : uploadState, + ] + }) + ) + if (!isEqual(writingToJournal, s.uploads.writingToJournal)) { + s.uploads.writingToJournal = writingToJournal + } + }) + } catch (err) { + errorToActionOrThrow(err) + } + } + ignorePromise(f()) + }, + loadedPathInfo: (path, info) => { + set(s => { + s.pathInfos.set(path, info) + }) + }, + moveOrCopy: (destinationParentPath: T.FS.Path, type: 'move' | 'copy') => { + const f = async () => { + const zState = get() + if (zState.destinationPicker.source.type === T.FS.DestinationPickerSource.None) { + return + } + + const params = + zState.destinationPicker.source.type === T.FS.DestinationPickerSource.MoveOrCopy + ? [ + { + dest: Util.pathToRPCPath( + T.FS.pathConcat( + destinationParentPath, + T.FS.getPathName(zState.destinationPicker.source.path) + ) + ), + opID: makeUUID(), + overwriteExistingFiles: false, + src: Util.pathToRPCPath(zState.destinationPicker.source.path), + }, + ] + : zState.destinationPicker.source.source + .map(item => ({originalPath: item.originalPath ?? '', scaledPath: item.scaledPath})) + .filter(({originalPath}) => !!originalPath) + .map(({originalPath, scaledPath}) => ({ + dest: Util.pathToRPCPath( + T.FS.pathConcat( + destinationParentPath, + T.FS.getLocalPathName(originalPath) + // We use the local path name here since we only care about file name. + ) + ), + opID: makeUUID(), + overwriteExistingFiles: false, + src: { + PathType: T.RPCGen.PathType.local, + local: T.FS.getNormalizedLocalPath( + useConfigState.getState().incomingShareUseOriginal + ? originalPath + : scaledPath || originalPath + ), + } as T.RPCGen.Path, + })) + + try { + const rpc = + type === 'move' + ? T.RPCGen.SimpleFSSimpleFSMoveRpcPromise + : T.RPCGen.SimpleFSSimpleFSCopyRecursiveRpcPromise + await Promise.all(params.map(async p => rpc(p))) + await Promise.all(params.map(async ({opID}) => T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}))) + // We get source/dest paths from state rather than action, so we can't + // just retry it. If we do want retry in the future we can include those + // paths in the action. + } catch (e) { + errorToActionOrThrow(e, destinationParentPath) + return + } + } + ignorePromise(f()) + }, + newFolderRow: parentPath => { + const parentPathItem = Util.getPathItem(get().pathItems, parentPath) + if (parentPathItem.type !== T.FS.PathType.Folder) { + console.warn(`bad parentPath: ${parentPathItem.type}`) + return + } + + const existingNewFolderNames = new Set([...get().edits.values()].map(({name}) => name)) + + let newFolderName = 'New Folder' + let i = 2 + while (parentPathItem.children.has(newFolderName) || existingNewFolderNames.has(newFolderName)) { + newFolderName = `New Folder ${i}` + ++i + } + + set(s => { + s.edits.set(makeEditID(), { + ...Util.emptyNewFolder, + name: newFolderName, + originalName: newFolderName, + parentPath, + }) + }) + }, + onChangedFocus: appFocused => { + const driverStatus = get().sfmi.driverStatus + if ( + appFocused && + driverStatus.type === T.FS.DriverStatusType.Disabled && + driverStatus.kextPermissionError + ) { + get().dispatch.driverEnable(true) + } + }, + onEngineIncomingImpl: action => { + switch (action.type) { + case EngineGen.keybase1NotifyFSFSOverallSyncStatusChanged: + get().dispatch.syncStatusChanged(action.payload.params.status) + break + case EngineGen.keybase1NotifyFSFSSubscriptionNotifyPath: { + const {clientID, path, topics} = action.payload.params + get().dispatch.onPathChange(clientID, path, topics ?? []) + break + } + case EngineGen.keybase1NotifyFSFSSubscriptionNotify: { + const {clientID, topic} = action.payload.params + get().dispatch.onSubscriptionNotify(clientID, topic) + break + } + default: + } + }, + onPathChange: (cid, path, topics) => { + if (cid !== clientID) { + return + } + + const {folderListLoad} = useFSState.getState().dispatch + topics.forEach(topic => { + switch (topic) { + case T.RPCGen.PathSubscriptionTopic.children: + folderListLoad(T.FS.stringToPath(path), false) + break + case T.RPCGen.PathSubscriptionTopic.stat: + get().dispatch.loadPathMetadata(T.FS.stringToPath(path)) + break + } + }) + }, + onSubscriptionNotify: (cid, topic) => { + const f = async () => { + if (cid !== clientID) { + return + } + switch (topic) { + case T.RPCGen.SubscriptionTopic.favorites: + get().dispatch.favoritesLoad() + break + case T.RPCGen.SubscriptionTopic.journalStatus: + get().dispatch.pollJournalStatus() + break + case T.RPCGen.SubscriptionTopic.onlineStatus: + await checkIfWeReConnectedToMDServerUpToNTimes(1) + break + case T.RPCGen.SubscriptionTopic.downloadStatus: + get().dispatch.loadDownloadStatus() + break + case T.RPCGen.SubscriptionTopic.uploadStatus: + get().dispatch.loadUploadStatus() + break + case T.RPCGen.SubscriptionTopic.filesTabBadge: + get().dispatch.loadFilesTabBadge() + break + case T.RPCGen.SubscriptionTopic.settings: + get().dispatch.loadSettings() + break + case T.RPCGen.SubscriptionTopic.overallSyncStatus: + break + } + } + ignorePromise(f()) + }, + pollJournalStatus: () => { + if (pollJournalStatusPolling) { + return + } + pollJournalStatusPolling = true + + const getWaitDuration = (endEstimate: number | undefined, lower: number, upper: number): number => { + if (!endEstimate) { + return upper + } + const diff = endEstimate - Date.now() + return diff < lower ? lower : diff > upper ? upper : diff + } + + const f = async () => { + try { + while (true) { + const {syncingPaths, totalSyncingBytes, endEstimate} = + await T.RPCGen.SimpleFSSimpleFSSyncStatusRpcPromise({ + filter: T.RPCGen.ListFilter.filterSystemHidden, + }) + get().dispatch.journalUpdate( + (syncingPaths || []).map(T.FS.stringToPath), + totalSyncingBytes, + endEstimate ?? undefined + ) + + // It's possible syncingPaths has not been emptied before + // totalSyncingBytes becomes 0. So check both. + if (totalSyncingBytes <= 0 && !syncingPaths?.length) { + break + } + storeRegistry.getState('notifications').dispatch.badgeApp('kbfsUploading', true) + await timeoutPromise(getWaitDuration(endEstimate || undefined, 100, 4000)) // 0.1s to 4s + } + } finally { + pollJournalStatusPolling = false + storeRegistry.getState('notifications').dispatch.badgeApp('kbfsUploading', false) + get().dispatch.checkKbfsDaemonRpcStatus() + } + } + ignorePromise(f()) + }, + redbar: error => { + set(s => { + s.errors.push(error) + }) + }, + resetState: () => { + set(s => ({ + ...s, + ...initialStore, + dispatch: s.dispatch, + })) + }, + setCriticalUpdate: u => { + set(s => { + s.criticalUpdate = u + }) + }, + setDebugLevel: level => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSSetDebugLevelRpcPromise({level}) + } + ignorePromise(f()) + }, + setDestinationPickerParentPath: (index, path) => { + set(s => { + s.destinationPicker.destinationParentPath[index] = path + }) + }, + setDirectMountDir: directMountDir => { + set(s => { + s.sfmi.directMountDir = directMountDir + }) + }, + setDriverStatus: driverStatus => { + set(s => { + s.sfmi.driverStatus = driverStatus + }) + get().dispatch.dynamic.refreshMountDirsDesktop?.() + }, + setEditName: (editID, name) => { + set(s => { + const e = s.edits.get(editID) + if (e) { + e.name = name + } + }) + }, + setFolderViewFilter: filter => { + set(s => { + s.folderViewFilter = filter + }) + }, + setIncomingShareSource: source => { + set(s => { + s.destinationPicker.source = { + source: T.castDraft(source), + type: T.FS.DestinationPickerSource.IncomingShare, + } + }) + }, + setLastPublicBannerClosedTlf: tlf => { + set(s => { + s.lastPublicBannerClosedTlf = tlf + }) + }, + setMoveOrCopySource: path => { + set(s => { + s.destinationPicker.source = {path, type: T.FS.DestinationPickerSource.MoveOrCopy} + }) + }, + setPathItemActionMenuDownload: (downloadID, intent) => { + set(s => { + s.pathItemActionMenu.downloadID = downloadID + s.pathItemActionMenu.downloadIntent = intent + }) + }, + setPathItemActionMenuView: view => { + set(s => { + s.pathItemActionMenu.previousView = s.pathItemActionMenu.view + s.pathItemActionMenu.view = view + }) + }, + setPathSoftError: (path, softError) => { + set(s => { + if (softError) { + s.softErrors.pathErrors.set(path, softError) + } else { + s.softErrors.pathErrors.delete(path) + } + }) + }, + setPreferredMountDirs: preferredMountDirs => { + set(s => { + s.sfmi.preferredMountDirs = T.castDraft(preferredMountDirs) + }) + }, + setSorting: (path, sortSetting) => { + set(s => { + const old = s.pathUserSettings.get(path) + if (old) { + old.sort = sortSetting + } else { + s.pathUserSettings.set(path, {...Util.defaultPathUserSetting, sort: sortSetting}) + } + }) + }, + setSpaceAvailableNotificationThreshold: threshold => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSSetNotificationThresholdRpcPromise({ + threshold, + }) + get().dispatch.loadSettings() + } + ignorePromise(f()) + }, + setTlfSoftError: (path, softError) => { + set(s => { + if (softError) { + s.softErrors.tlfErrors.set(path, softError) + } else { + s.softErrors.tlfErrors.delete(path) + } + }) + }, + setTlfSyncConfig: (tlfPath, enabled) => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSSetFolderSyncConfigRpcPromise( + { + config: {mode: enabled ? T.RPCGen.FolderSyncMode.enabled : T.RPCGen.FolderSyncMode.disabled}, + path: Util.pathToRPCPath(tlfPath), + }, + S.waitingKeyFSSyncToggle + ) + get().dispatch.loadTlfSyncConfig(tlfPath) + } + ignorePromise(f()) + }, + setTlfsAsUnloaded: () => { + set(s => { + s.tlfs.loaded = false + }) + }, + setupSubscriptions: async () => { + const initPlatformSpecific = await import('./platform-specific') + initPlatformSpecific.default() + }, + showIncomingShare: initialDestinationParentPath => { + set(s => { + if (s.destinationPicker.source.type !== T.FS.DestinationPickerSource.IncomingShare) { + s.destinationPicker.source = {source: [], type: T.FS.DestinationPickerSource.IncomingShare} + } + s.destinationPicker.destinationParentPath = [initialDestinationParentPath] + }) + navigateAppend({props: {index: 0}, selected: 'destinationPicker'}) + }, + showMoveOrCopy: initialDestinationParentPath => { + set(s => { + s.destinationPicker.source = + s.destinationPicker.source.type === T.FS.DestinationPickerSource.MoveOrCopy + ? s.destinationPicker.source + : { + path: Util.defaultPath, + type: T.FS.DestinationPickerSource.MoveOrCopy, + } + + s.destinationPicker.destinationParentPath = [initialDestinationParentPath] + }) + + navigateAppend({props: {index: 0}, selected: 'destinationPicker'}) + }, + startManualConflictResolution: tlfPath => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSClearConflictStateRpcPromise({ + path: Util.pathToRPCPath(tlfPath), + }) + get().dispatch.favoritesLoad() + } + ignorePromise(f()) + }, + startRename: path => { + const parentPath = T.FS.getPathParent(path) + const originalName = T.FS.getPathName(path) + set(s => { + s.edits.set(makeEditID(), { + name: originalName, + originalName, + parentPath, + type: T.FS.EditType.Rename, + }) + }) + }, + subscribeNonPath: (subscriptionID, topic) => { + const f = async () => { + try { + await T.RPCGen.SimpleFSSimpleFSSubscribeNonPathRpcPromise({ + clientID, + deduplicateIntervalSecond: subscriptionDeduplicateIntervalSecond, + identifyBehavior: T.RPCGen.TLFIdentifyBehavior.fsGui, + subscriptionID, + topic, + }) + } catch (err) { + errorToActionOrThrow(err) + } + } + ignorePromise(f()) + }, + subscribePath: (subscriptionID, path, topic) => { + const f = async () => { + try { + await T.RPCGen.SimpleFSSimpleFSSubscribePathRpcPromise({ + clientID, + deduplicateIntervalSecond: subscriptionDeduplicateIntervalSecond, + identifyBehavior: T.RPCGen.TLFIdentifyBehavior.fsGui, + kbfsPath: T.FS.pathToString(path), + subscriptionID, + topic, + }) + } catch (error) { + if (!(error instanceof RPCError)) { + return + } + if (error.code !== T.RPCGen.StatusCode.scteamcontactsettingsblock) { + // We'll handle this error in loadAdditionalTLF instead. + errorToActionOrThrow(error, path) + } + } + } + ignorePromise(f()) + }, + syncStatusChanged: status => { + const diskSpaceStatus = status.outOfSyncSpace + ? T.FS.DiskSpaceStatus.Error + : status.localDiskBytesAvailable < get().settings.spaceAvailableNotificationThreshold + ? T.FS.DiskSpaceStatus.Warning + : T.FS.DiskSpaceStatus.Ok + + const oldStatus = get().overallSyncStatus.diskSpaceStatus + set(s => { + s.overallSyncStatus.syncingFoldersProgress = status.prefetchProgress + s.overallSyncStatus.diskSpaceStatus = diskSpaceStatus + }) + + // Only notify about the disk space status if it has changed. + if (oldStatus !== diskSpaceStatus) { + switch (diskSpaceStatus) { + case T.FS.DiskSpaceStatus.Error: { + NotifyPopup('Sync Error', { + body: 'You are out of disk space. Some folders could not be synced.', + sound: true, + }) + storeRegistry.getState('notifications').dispatch.badgeApp('outOfSpace', status.outOfSyncSpace) + break + } + case T.FS.DiskSpaceStatus.Warning: + { + const threshold = Util.humanizeBytes(get().settings.spaceAvailableNotificationThreshold, 0) + NotifyPopup('Disk Space Low', { + body: `You have less than ${threshold} of storage space left.`, + }) + // Only show the banner if the previous state was OK and the new state + // is warning. Otherwise we rely on the previous state of the banner. + if (oldStatus === T.FS.DiskSpaceStatus.Ok) { + set(s => { + s.overallSyncStatus.showingBanner = true + }) + } + } + break + case T.FS.DiskSpaceStatus.Ok: + break + default: + } + } + }, + unsubscribe: subscriptionID => { + const f = async () => { + try { + await T.RPCGen.SimpleFSSimpleFSUnsubscribeRpcPromise({ + clientID, + identifyBehavior: T.RPCGen.TLFIdentifyBehavior.fsGui, + subscriptionID, + }) + } catch {} + } + ignorePromise(f()) + }, + upload: (parentPath, localPath) => { + const f = async () => { + try { + await T.RPCGen.SimpleFSSimpleFSStartUploadRpcPromise({ + sourceLocalPath: T.FS.getNormalizedLocalPath(localPath), + targetParentPath: Util.pathToRPCPath(parentPath).kbfs, + }) + } catch (err) { + errorToActionOrThrow(err) + } + } + ignorePromise(f()) + }, + userFileEditsLoad: () => { + const f = async () => { + try { + const writerEdits = await T.RPCGen.SimpleFSSimpleFSUserEditHistoryRpcPromise() + set(s => { + s.tlfUpdates = T.castDraft(Util.userTlfHistoryRPCToState(writerEdits || [])) + }) + } catch (error) { + errorToActionOrThrow(error) + } + } + ignorePromise(f()) + }, + userIn: () => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSUserInRpcPromise({clientID}) + } + ignorePromise(f()) + get().dispatch.checkKbfsDaemonRpcStatus() + }, + userOut: () => { + const f = async () => { + await T.RPCGen.SimpleFSSimpleFSUserOutRpcPromise({clientID}) + } + ignorePromise(f()) + }, + waitForKbfsDaemon: () => { + if (waitForKbfsDaemonInProgress) { + return + } + waitForKbfsDaemonInProgress = true + set(s => { + s.kbfsDaemonStatus.rpcStatus = T.FS.KbfsDaemonRpcStatus.Waiting + }) + const f = async () => { + try { + await T.RPCGen.configWaitForClientRpcPromise({ + clientType: T.RPCGen.ClientType.kbfs, + timeout: 60, // 1min. This is arbitrary since we're gonna check again anyway if we're not connected. + }) + } catch {} + + waitForKbfsDaemonInProgress = false + get().dispatch.checkKbfsDaemonRpcStatus() + } + ignorePromise(f()) + }, + } + + return { + ...initialStore, + dispatch, + getUploadIconForFilesTab, + } +}) diff --git a/shared/team-building/search-result/people-result.tsx b/shared/team-building/search-result/people-result.tsx index 82bf99580a2c..a0df7405e4d7 100644 --- a/shared/team-building/search-result/people-result.tsx +++ b/shared/team-building/search-result/people-result.tsx @@ -3,7 +3,7 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import CommonResult, {type ResultProps} from './common-result' import {useUsersState} from '@/constants/users' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/teams/container.tsx b/shared/teams/container.tsx index f3219023e020..0cdf2b620141 100644 --- a/shared/teams/container.tsx +++ b/shared/teams/container.tsx @@ -3,7 +3,7 @@ import * as Teams from '@/constants/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import * as FS from '@/constants/fs' +import * as FS from '@/stores/fs' import Main from './main' import openURL from '@/util/open-url' import {useTeamsSubscribe} from './subscriber' From b02b07fac4fa1c6ef0c8b751bb78dc982e5fa9ee Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:21:33 -0500 Subject: [PATCH 08/37] WIP --- shared/constants/fs/util.tsx | 1 - shared/stores/fs.tsx | 20 ++++++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/shared/constants/fs/util.tsx b/shared/constants/fs/util.tsx index 197a45cf13cd..d57ccfd6c7cc 100644 --- a/shared/constants/fs/util.tsx +++ b/shared/constants/fs/util.tsx @@ -1,4 +1,3 @@ -import * as EngineGen from '@/actions/engine-gen-gen' import type * as React from 'react' import * as Tabs from '../tabs' import * as T from '../types' diff --git a/shared/stores/fs.tsx b/shared/stores/fs.tsx index b982fcf7ed09..a2763376442e 100644 --- a/shared/stores/fs.tsx +++ b/shared/stores/fs.tsx @@ -1,9 +1,9 @@ import * as EngineGen from '@/actions/engine-gen-gen' -import {ignorePromise, timeoutPromise} from '../utils' -import * as S from '../strings' -import {requestPermissionsToWrite} from '../platform-specific' -import * as Tabs from '../tabs' -import * as T from '../types' +import {ignorePromise, timeoutPromise} from '@/constants/utils' +import * as S from '@/constants/strings' +import {requestPermissionsToWrite} from '@/constants/platform-specific' +import * as Tabs from '@/constants/tabs' +import * as T from '@/constants/types' import * as Z from '@/util/zustand' import NotifyPopup from '@/util/notify-popup' import {RPCError} from '@/util/errors' @@ -11,10 +11,10 @@ import logger from '@/logger' import {tlfToPreferredOrder} from '@/util/kbfs' import isObject from 'lodash/isObject' import isEqual from 'lodash/isEqual' -import {navigateAppend, navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' +import {navigateAppend, navigateUp} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' +import {useConfigState} from '@/constants/config' +import {useCurrentUserState} from '@/constants/current-user' import * as Util from '@/constants/fs/util' export * from '@/constants/fs/util' @@ -1598,7 +1598,7 @@ export const useFSState = Z.createZustand((set, get) => { }) }, setupSubscriptions: async () => { - const initPlatformSpecific = await import('./platform-specific') + const initPlatformSpecific = await import('../constants/fs/platform-specific') initPlatformSpecific.default() }, showIncomingShare: initialDestinationParentPath => { From 2f1b61ff6297fcfb306981c2fd02415ee1c3fed0 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 15:23:39 -0500 Subject: [PATCH 09/37] WIP --- .../messages/system-git-push/container.tsx | 2 +- shared/constants/git/util.tsx | 20 ------------------- shared/constants/init/shared.tsx | 11 ++++++++-- shared/constants/store-registry.tsx | 2 +- shared/git/delete-repo.tsx | 2 +- shared/git/index.tsx | 2 +- shared/git/nav-header.tsx | 2 +- shared/git/new-repo.tsx | 2 +- shared/git/row.tsx | 2 +- shared/git/select-channel.tsx | 2 +- .../git/index.tsx => stores/git.tsx} | 0 11 files changed, 17 insertions(+), 30 deletions(-) delete mode 100644 shared/constants/git/util.tsx rename shared/{constants/git/index.tsx => stores/git.tsx} (100%) diff --git a/shared/chat/conversation/messages/system-git-push/container.tsx b/shared/chat/conversation/messages/system-git-push/container.tsx index bc2fa9853091..686e7e0a2050 100644 --- a/shared/chat/conversation/messages/system-git-push/container.tsx +++ b/shared/chat/conversation/messages/system-git-push/container.tsx @@ -2,7 +2,7 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' -import {useGitState} from '@/constants/git' +import {useGitState} from '@/stores/git' import UserNotice from '../user-notice' import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/constants/git/util.tsx b/shared/constants/git/util.tsx deleted file mode 100644 index c72418bcf735..000000000000 --- a/shared/constants/git/util.tsx +++ /dev/null @@ -1,20 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - -let loadedStore = false -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyBadgesBadgeState: - { - const {badgeState} = action.payload.params - const badges = new Set(badgeState.newGitRepoGlobalUniqueIDs) - // don't bother loading the store if no badges - if (loadedStore || badges.size) { - loadedStore = true - storeRegistry.getState('git').dispatch.onEngineIncomingImpl(action) - } - } - break - default: - } -} diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index fd525d251d48..9b3e02c61ee9 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -19,7 +19,7 @@ import * as DeepLinksUtil from '../deeplinks/util' import {useFollowerState} from '@/stores/followers' import isEqual from 'lodash/isEqual' import type * as UseFSStateType from '@/stores/fs' -import * as GitUtil from '../git/util' +import type * as UseGitStateType from '@/stores/git' import * as NotifUtil from '../notifications/util' import * as PeopleUtil from '../people/util' import * as PinentryUtil from '../pinentry/util' @@ -37,6 +37,7 @@ import {useWhatsNewState} from '../whats-new' let _emitStartupOnLoadDaemonConnectedOnce = false let _devicesLoaded = false +let _gitLoaded = false export const onEngineConnected = () => { ChatUtil.onEngineConnected() @@ -267,6 +268,13 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { const {useDevicesState} = require('@/stores/devices') as typeof UseDevicesStateType useDevicesState.getState().dispatch.onEngineIncomingImpl(action) } + + const badges = new Set(badgeState.newGitRepoGlobalUniqueIDs) + if (_gitLoaded || badges.size) { + _gitLoaded = true + const {useGitState} = require('@/stores/git') as typeof UseGitStateType + useGitState.getState().dispatch.onEngineIncomingImpl(action) + } } break case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: @@ -310,7 +318,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - GitUtil.onEngineIncoming(action) NotifUtil.onEngineIncoming(action) PeopleUtil.onEngineIncoming(action) PinentryUtil.onEngineIncoming(action) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 46f4b1fa11b9..6b535e552f66 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -10,7 +10,7 @@ import type {State as ChatState, useChatState} from '@/constants/chat2' import type {State as DaemonState, useDaemonState} from '@/constants/daemon' import type {State as DevicesState, useDevicesState} from '@/stores/devices' import type {State as FSState, useFSState} from '@/stores/fs' -import type {State as GitState, useGitState} from '@/constants/git' +import type {State as GitState, useGitState} from '@/stores/git' import type {State as NotificationsState, useNotifState} from '@/constants/notifications' import type {State as PeopleState, usePeopleState} from '@/constants/people' import type {State as ProfileState, useProfileState} from '@/constants/profile' diff --git a/shared/git/delete-repo.tsx b/shared/git/delete-repo.tsx index 88b1804a1f83..1be08287171f 100644 --- a/shared/git/delete-repo.tsx +++ b/shared/git/delete-repo.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' -import * as Git from '@/constants/git' +import * as Git from '@/stores/git' type OwnProps = {id: string} diff --git a/shared/git/index.tsx b/shared/git/index.tsx index 168a9715ed72..aaf29607752f 100644 --- a/shared/git/index.tsx +++ b/shared/git/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Git from '@/constants/git' +import * as Git from '@/stores/git' import * as Kb from '@/common-adapters' import * as React from 'react' import Row, {NewContext} from './row' diff --git a/shared/git/nav-header.tsx b/shared/git/nav-header.tsx index 5dafe65dd6ca..26d239bb94c9 100644 --- a/shared/git/nav-header.tsx +++ b/shared/git/nav-header.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Git from '@/constants/git' +import * as Git from '@/stores/git' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/git/new-repo.tsx b/shared/git/new-repo.tsx index fd7ded7e79f5..bfac4cb443db 100644 --- a/shared/git/new-repo.tsx +++ b/shared/git/new-repo.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Git from '@/constants/git' +import * as Git from '@/stores/git' import * as Teams from '@/constants/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/git/row.tsx b/shared/git/row.tsx index ca132a409a88..d9f66f5c93d2 100644 --- a/shared/git/row.tsx +++ b/shared/git/row.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Git from '@/constants/git' +import * as Git from '@/stores/git' import * as Teams from '@/constants/teams' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' diff --git a/shared/git/select-channel.tsx b/shared/git/select-channel.tsx index a2cee7e5f3cb..ff8d850895dd 100644 --- a/shared/git/select-channel.tsx +++ b/shared/git/select-channel.tsx @@ -1,4 +1,4 @@ -import * as Git from '@/constants/git' +import * as Git from '@/stores/git' import * as Teams from '@/constants/teams' import {useSafeNavigation} from '@/util/safe-navigation' import * as Kb from '@/common-adapters' diff --git a/shared/constants/git/index.tsx b/shared/stores/git.tsx similarity index 100% rename from shared/constants/git/index.tsx rename to shared/stores/git.tsx From d249d011ba16bd959c0f28cde74d878808a76abf Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:26:02 -0500 Subject: [PATCH 10/37] WIP --- shared/stores/git.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/shared/stores/git.tsx b/shared/stores/git.tsx index 297dc32a67f4..f1b8ce2b39f8 100644 --- a/shared/stores/git.tsx +++ b/shared/stores/git.tsx @@ -1,12 +1,12 @@ -import * as S from '../strings' -import * as T from '../types' -import {ignorePromise} from '../utils' +import * as S from '@/constants/strings' +import * as T from '@/constants/types' +import {ignorePromise} from '@/constants/utils' import * as EngineGen from '@/actions/engine-gen-gen' import * as dateFns from 'date-fns' import * as Z from '@/util/zustand' import debounce from 'lodash/debounce' -import {navigateAppend} from '../router2/util' -import {useConfigState} from '../config' +import {navigateAppend} from '@/constants/router2/util' +import {useConfigState} from '@/constants/config' const parseRepos = (results: ReadonlyArray) => { const errors: Array = [] From 3a795d09192f2e535f8e38eccadc926b3d94560e Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:29:05 -0500 Subject: [PATCH 11/37] WIP --- shared/constants/store-registry.tsx | 54 ++++++++++++++--------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 6b535e552f66..1c8c22c05510 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -1,6 +1,6 @@ // used to allow non-circular cross-calls between stores // ONLY for zustand stores -import type * as T from './types' +import type * as T from '@/constants/types' import type * as TBType from '@/constants/team-building' import type * as ConvoStateType from '@/constants/chat2/convostate' import type {ConvoState} from '@/constants/chat2/convostate' @@ -117,99 +117,99 @@ class StoreRegistry { /* eslint-disable @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-return */ switch (storeName) { case 'autoreset': { - const {useAutoResetState} = require('../stores/autoreset') + const {useAutoResetState} = require('@/stores/autoreset') return useAutoResetState } case 'bots': { - const {useBotsState} = require('../stores/bots') + const {useBotsState} = require('@/stores/bots') return useBotsState } case 'chat': { - const {useChatState} = require('./chat2') + const {useChatState} = require('@/constants/chat2') return useChatState } case 'daemon': { - const {useDaemonState} = require('./daemon') + const {useDaemonState} = require('@/constants/daemon') return useDaemonState } case 'devices': { - const {useDevicesState} = require('../stores/devices') + const {useDevicesState} = require('@/stores/devices') return useDevicesState } case 'fs': { - const {useFSState} = require('./fs') + const {useFSState} = require('@/constants/fs') return useFSState } case 'git': { - const {useGitState} = require('./git') + const {useGitState} = require('@/stores/git') return useGitState } case 'notifications': { - const {useNotifState} = require('./notifications') + const {useNotifState} = require('@/constants/notifications') return useNotifState } case 'people': { - const {usePeopleState} = require('./people') + const {usePeopleState} = require('@/constants/people') return usePeopleState } case 'profile': { - const {useProfileState} = require('./profile') + const {useProfileState} = require('@/constants/profile') return useProfileState } case 'provision': { - const {useProvisionState} = require('./provision') + const {useProvisionState} = require('@/constants/provision') return useProvisionState } case 'push': { - const {usePushState} = require('./push') + const {usePushState} = require('@/constants/push') return usePushState } case 'recover-password': { - const {useState} = require('./recover-password') + const {useState} = require('@/constants/recover-password') return useState } case 'settings': { - const {useSettingsState} = require('./settings') + const {useSettingsState} = require('@/constants/settings') return useSettingsState } case 'settings-chat': { - const {useSettingsChatState} = require('./settings-chat') + const {useSettingsChatState} = require('@/constants/settings-chat') return useSettingsChatState } case 'settings-contacts': { - const {useSettingsContactsState} = require('./settings-contacts') + const {useSettingsContactsState} = require('@/constants/settings-contacts') return useSettingsContactsState } case 'settings-email': { - const {useSettingsEmailState} = require('./settings-email') + const {useSettingsEmailState} = require('@/constants/settings-email') return useSettingsEmailState } case 'settings-password': { - const {usePWState} = require('./settings-password') + const {usePWState} = require('@/constants/settings-password') return usePWState } case 'settings-phone': { - const {useSettingsPhoneState} = require('./settings-phone') + const {useSettingsPhoneState} = require('@/constants/settings-phone') return useSettingsPhoneState } case 'signup': { - const {useSignupState} = require('./signup') + const {useSignupState} = require('@/constants/signup') return useSignupState } case 'teams': { - const {useTeamsState} = require('./teams') + const {useTeamsState} = require('@/constants/teams') return useTeamsState } case 'tracker2': { - const {useTrackerState} = require('./tracker2') + const {useTrackerState} = require('@/constants/tracker2') return useTrackerState } case 'unlock-folders': { - const {useUnlockFoldersState} = require('./unlock-folders') + const {useUnlockFoldersState} = require('@/constants/unlock-folders') return useUnlockFoldersState } case 'users': { - const {useUsersState} = require('./users') + const {useUsersState} = require('@/constants/users') return useUsersState } default: @@ -222,13 +222,13 @@ class StoreRegistry { } getTBStore(name: T.TB.AllowedNamespace): TBType.State { - const {createTBStore} = require('./team-building') as typeof TBType + const {createTBStore} = require('@/constants/team-building') as typeof TBType const store = createTBStore(name) return store.getState() } getConvoState(id: T.Chat.ConversationIDKey): ConvoState { - const {getConvoState} = require('./chat2/convostate') as typeof ConvoStateType + const {getConvoState} = require('@/constants/chat2/convostate') as typeof ConvoStateType return getConvoState(id) } } From c8354c0b66d0f8f7d7d44ea19ef496b4de0dad7d Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 15:32:07 -0500 Subject: [PATCH 12/37] WIP --- shared/constants/init/shared.tsx | 10 +++++++++- shared/constants/notifications/util.tsx | 12 ------------ shared/constants/store-registry.tsx | 2 +- shared/desktop/app/menu-bar.desktop.tsx | 2 +- shared/menubar/remote-proxy.desktop.tsx | 4 ++-- shared/router-v2/tab-bar.desktop.tsx | 2 +- shared/router-v2/tab-bar.native.tsx | 2 +- shared/settings/root-phone.tsx | 2 +- shared/settings/sub-nav/left-nav.tsx | 2 +- .../index.tsx => stores/notifications.tsx} | 12 ++++++------ 10 files changed, 23 insertions(+), 27 deletions(-) rename shared/{constants/notifications/index.tsx => stores/notifications.tsx} (95%) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 9b3e02c61ee9..713ddd818ed4 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -20,6 +20,7 @@ import {useFollowerState} from '@/stores/followers' import isEqual from 'lodash/isEqual' import type * as UseFSStateType from '@/stores/fs' import type * as UseGitStateType from '@/stores/git' +import type * as UseNotificationsStateType from '@/stores/notifications' import * as NotifUtil from '../notifications/util' import * as PeopleUtil from '../people/util' import * as PinentryUtil from '../pinentry/util' @@ -291,6 +292,14 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { useFSState.getState().dispatch.onEngineIncomingImpl(action) } break + case EngineGen.keybase1NotifyAuditRootAuditError: + case EngineGen.keybase1NotifyAuditBoxAuditError: + case EngineGen.keybase1NotifyBadgesBadgeState: + { + const {useNotifState} = require('@/stores/notifications') as typeof UseNotificationsStateType + useNotifState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) @@ -318,7 +327,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - NotifUtil.onEngineIncoming(action) PeopleUtil.onEngineIncoming(action) PinentryUtil.onEngineIncoming(action) SettingsUtil.onEngineIncoming(action) diff --git a/shared/constants/notifications/util.tsx b/shared/constants/notifications/util.tsx index acc95a39dbf0..ef0d2e4d399f 100644 --- a/shared/constants/notifications/util.tsx +++ b/shared/constants/notifications/util.tsx @@ -55,15 +55,3 @@ export const onEngineConnected = () => { ignorePromise(f()) } -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyAuditRootAuditError: - case EngineGen.keybase1NotifyAuditBoxAuditError: - case EngineGen.keybase1NotifyBadgesBadgeState: - { - storeRegistry.getState('notifications').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 1c8c22c05510..d7399651a62e 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -11,7 +11,7 @@ import type {State as DaemonState, useDaemonState} from '@/constants/daemon' import type {State as DevicesState, useDevicesState} from '@/stores/devices' import type {State as FSState, useFSState} from '@/stores/fs' import type {State as GitState, useGitState} from '@/stores/git' -import type {State as NotificationsState, useNotifState} from '@/constants/notifications' +import type {State as NotificationsState, useNotifState} from '@/stores/notifications' import type {State as PeopleState, usePeopleState} from '@/constants/people' import type {State as ProfileState, useProfileState} from '@/constants/profile' import type {State as ProvisionState, useProvisionState} from '@/constants/provision' diff --git a/shared/desktop/app/menu-bar.desktop.tsx b/shared/desktop/app/menu-bar.desktop.tsx index cbc76a7e902f..bca0da6b42de 100644 --- a/shared/desktop/app/menu-bar.desktop.tsx +++ b/shared/desktop/app/menu-bar.desktop.tsx @@ -8,7 +8,7 @@ import {menubar} from 'menubar' import {showDevTools, skipSecondaryDevtools} from '@/local-debug' import {getMainWindow} from './main-window.desktop' import {assetRoot, htmlPrefix} from './html-root.desktop' -import type {BadgeType} from '@/constants/notifications' +import type {BadgeType} from '@/stores/notifications' const getIcons = (iconType: BadgeType, badges: number) => { const size = isWindows ? 16 : 22 diff --git a/shared/menubar/remote-proxy.desktop.tsx b/shared/menubar/remote-proxy.desktop.tsx index 9fe8cebe926e..356a96de7294 100644 --- a/shared/menubar/remote-proxy.desktop.tsx +++ b/shared/menubar/remote-proxy.desktop.tsx @@ -10,13 +10,13 @@ import {intersect} from '@/util/set' import {mapFilterByKey} from '@/util/map' import {serialize, type ProxyProps, type RemoteTlfUpdates} from './remote-serializer.desktop' import {useAvatarState} from '@/common-adapters/avatar/store' -import type * as NotifConstants from '@/constants/notifications' +import type * as NotifConstants from '@/stores/notifications' import {useColorScheme} from 'react-native' import * as FS from '@/stores/fs' import {useFSState} from '@/stores/fs' import {useFollowerState} from '@/stores/followers' import {useUsersState} from '@/constants/users' -import {useNotifState} from '@/constants/notifications' +import {useNotifState} from '@/stores/notifications' import {useCurrentUserState} from '@/constants/current-user' import {useDaemonState} from '@/constants/daemon' import {useDarkModeState} from '@/constants/darkmode' diff --git a/shared/router-v2/tab-bar.desktop.tsx b/shared/router-v2/tab-bar.desktop.tsx index a3569650f3d3..1a62a49d858a 100644 --- a/shared/router-v2/tab-bar.desktop.tsx +++ b/shared/router-v2/tab-bar.desktop.tsx @@ -17,7 +17,7 @@ import {settingsLogOutTab} from '@/constants/settings/util' import {useTrackerState} from '@/constants/tracker2' import {useFSState} from '@/stores/fs' import {useProfileState} from '@/constants/profile' -import {useNotifState} from '@/constants/notifications' +import {useNotifState} from '@/stores/notifications' import {useCurrentUserState} from '@/constants/current-user' import {useProvisionState} from '@/constants/provision' diff --git a/shared/router-v2/tab-bar.native.tsx b/shared/router-v2/tab-bar.native.tsx index 71bb34a5ff8f..3a136f6a74fd 100644 --- a/shared/router-v2/tab-bar.native.tsx +++ b/shared/router-v2/tab-bar.native.tsx @@ -7,7 +7,7 @@ import {View} from 'react-native' import {useSafeAreaFrame} from 'react-native-safe-area-context' import {useColorScheme} from 'react-native' import {usePushState} from '@/constants/push' -import {useNotifState} from '@/constants/notifications' +import {useNotifState} from '@/stores/notifications' const settingsTabChildren = [Tabs.gitTab, Tabs.devicesTab, Tabs.settingsTab] as const const tabs = C.isTablet ? Tabs.tabletTabs : Tabs.phoneTabs diff --git a/shared/settings/root-phone.tsx b/shared/settings/root-phone.tsx index 0ed12c417a3b..a94d5a7caa31 100644 --- a/shared/settings/root-phone.tsx +++ b/shared/settings/root-phone.tsx @@ -10,7 +10,7 @@ import noop from 'lodash/noop' import {useSettingsContactsState} from '@/constants/settings-contacts' import * as Settings from '@/constants/settings' import {usePushState} from '@/constants/push' -import {useNotifState} from '@/constants/notifications' +import {useNotifState} from '@/stores/notifications' const PerfRow = () => { const [toSubmit, setToSubmit] = React.useState('') diff --git a/shared/settings/sub-nav/left-nav.tsx b/shared/settings/sub-nav/left-nav.tsx index 12ecd1a074d8..1238f05ef3a0 100644 --- a/shared/settings/sub-nav/left-nav.tsx +++ b/shared/settings/sub-nav/left-nav.tsx @@ -6,7 +6,7 @@ import SettingsItem from './settings-item' import {keybaseFM} from '@/constants/whats-new' import * as Settings from '@/constants/settings' import {usePushState} from '@/constants/push' -import {useNotifState} from '@/constants/notifications' +import {useNotifState} from '@/stores/notifications' type Props = { onClick: (s: string) => void diff --git a/shared/constants/notifications/index.tsx b/shared/stores/notifications.tsx similarity index 95% rename from shared/constants/notifications/index.tsx rename to shared/stores/notifications.tsx index de0802fff654..eeaa186b75d8 100644 --- a/shared/constants/notifications/index.tsx +++ b/shared/stores/notifications.tsx @@ -1,12 +1,12 @@ import * as Z from '@/util/zustand' import * as EngineGen from '@/actions/engine-gen-gen' -import type * as T from '../types' -import {isMobile} from '../platform' +import type * as T from '@/constants/types' +import {isMobile} from '@/constants/platform' import isEqual from 'lodash/isEqual' -import * as Tabs from '../tabs' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' +import * as Tabs from '@/constants/tabs' +import {storeRegistry} from '@/constants/store-registry' +import {useConfigState} from '@/constants/config' +import {useCurrentUserState} from '@/constants/current-user' export type BadgeType = 'regular' | 'update' | 'error' | 'uploading' export type NotificationKeys = 'kbfsUploading' | 'outOfSpace' From 38fa2df066417bee3b2179e453ee29ea692162a9 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:37:38 -0500 Subject: [PATCH 13/37] WIP --- shared/constants/init/shared.tsx | 9 +++------ shared/constants/notifications/util.tsx | 3 --- shared/constants/store-registry.tsx | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 713ddd818ed4..9532e50cd782 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -276,6 +276,9 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { const {useGitState} = require('@/stores/git') as typeof UseGitStateType useGitState.getState().dispatch.onEngineIncomingImpl(action) } + + const {useNotifState} = require('@/stores/notifications') as typeof UseNotificationsStateType + useNotifState.getState().dispatch.onEngineIncomingImpl(action) } break case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: @@ -294,12 +297,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { break case EngineGen.keybase1NotifyAuditRootAuditError: case EngineGen.keybase1NotifyAuditBoxAuditError: - case EngineGen.keybase1NotifyBadgesBadgeState: - { - const {useNotifState} = require('@/stores/notifications') as typeof UseNotificationsStateType - useNotifState.getState().dispatch.onEngineIncomingImpl(action) - } - break default: } AvatarUtil.onEngineIncoming(action) diff --git a/shared/constants/notifications/util.tsx b/shared/constants/notifications/util.tsx index ef0d2e4d399f..ce8efc8cc9f0 100644 --- a/shared/constants/notifications/util.tsx +++ b/shared/constants/notifications/util.tsx @@ -1,7 +1,5 @@ import * as T from '../types' import {ignorePromise} from '../utils' -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' import {isMobile} from '../platform' import logger from '@/logger' @@ -54,4 +52,3 @@ export const onEngineConnected = () => { } ignorePromise(f()) } - diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index d7399651a62e..1114a5b7d554 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -145,7 +145,7 @@ class StoreRegistry { return useGitState } case 'notifications': { - const {useNotifState} = require('@/constants/notifications') + const {useNotifState} = require('@/stores/notifications') return useNotifState } case 'people': { From dff26385df60f9f36c9fde8493d93a36e837b23f Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 15:40:04 -0500 Subject: [PATCH 14/37] WIP --- shared/constants/init/shared.tsx | 14 +++++++++++++- shared/constants/people/util.tsx | 11 ----------- shared/constants/store-registry.tsx | 6 +++--- shared/people/announcement.tsx | 2 +- shared/people/container.tsx | 2 +- shared/people/index.shared.tsx | 2 +- shared/people/todo.tsx | 2 +- .../people/index.tsx => stores/people.tsx} | 10 +++++----- 8 files changed, 25 insertions(+), 24 deletions(-) rename shared/{constants/people/index.tsx => stores/people.tsx} (98%) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 9532e50cd782..1886ebf8fc2d 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -22,6 +22,7 @@ import type * as UseFSStateType from '@/stores/fs' import type * as UseGitStateType from '@/stores/git' import type * as UseNotificationsStateType from '@/stores/notifications' import * as NotifUtil from '../notifications/util' +import type * as UsePeopleStateType from '@/stores/people' import * as PeopleUtil from '../people/util' import * as PinentryUtil from '../pinentry/util' import {useProvisionState} from '../provision' @@ -297,6 +298,18 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { break case EngineGen.keybase1NotifyAuditRootAuditError: case EngineGen.keybase1NotifyAuditBoxAuditError: + { + const {useNotifState} = require('@/stores/notifications') as typeof UseNotificationsStateType + useNotifState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.keybase1HomeUIHomeUIRefresh: + case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: + { + const {usePeopleState} = require('@/stores/people') as typeof UsePeopleStateType + usePeopleState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) @@ -324,7 +337,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - PeopleUtil.onEngineIncoming(action) PinentryUtil.onEngineIncoming(action) SettingsUtil.onEngineIncoming(action) SignupUtil.onEngineIncoming(action) diff --git a/shared/constants/people/util.tsx b/shared/constants/people/util.tsx index 8deb5593c959..7ffa62fadadc 100644 --- a/shared/constants/people/util.tsx +++ b/shared/constants/people/util.tsx @@ -15,14 +15,3 @@ export const onEngineConnected = () => { ignorePromise(f()) } -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1HomeUIHomeUIRefresh: - case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: - { - storeRegistry.getState('people').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 1114a5b7d554..d6989f41784f 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -12,7 +12,7 @@ import type {State as DevicesState, useDevicesState} from '@/stores/devices' import type {State as FSState, useFSState} from '@/stores/fs' import type {State as GitState, useGitState} from '@/stores/git' import type {State as NotificationsState, useNotifState} from '@/stores/notifications' -import type {State as PeopleState, usePeopleState} from '@/constants/people' +import type {State as PeopleState, usePeopleState} from '@/stores/people' import type {State as ProfileState, useProfileState} from '@/constants/profile' import type {State as ProvisionState, useProvisionState} from '@/constants/provision' import type {State as PushState, usePushState} from '@/constants/push' @@ -137,7 +137,7 @@ class StoreRegistry { return useDevicesState } case 'fs': { - const {useFSState} = require('@/constants/fs') + const {useFSState} = require('@/stores/fs') return useFSState } case 'git': { @@ -149,7 +149,7 @@ class StoreRegistry { return useNotifState } case 'people': { - const {usePeopleState} = require('@/constants/people') + const {usePeopleState} = require('@/stores/people') return usePeopleState } case 'profile': { diff --git a/shared/people/announcement.tsx b/shared/people/announcement.tsx index 7a6e55dd442c..00f360c95fe3 100644 --- a/shared/people/announcement.tsx +++ b/shared/people/announcement.tsx @@ -5,7 +5,7 @@ import openURL from '@/util/open-url' import * as Kb from '@/common-adapters' import PeopleItem from './item' import * as Settings from '@/constants/settings/util' -import {usePeopleState} from '@/constants/people' +import {usePeopleState} from '@/stores/people' type OwnProps = { appLink?: T.RPCGen.AppLinkType diff --git a/shared/people/container.tsx b/shared/people/container.tsx index e1301cfc5f60..b868032a7339 100644 --- a/shared/people/container.tsx +++ b/shared/people/container.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import People from '.' import {useSignupState} from '@/constants/signup' import {useProfileState} from '@/constants/profile' -import {usePeopleState, getPeopleDataWaitingKey} from '@/constants/people' +import {usePeopleState, getPeopleDataWaitingKey} from '@/stores/people' import {useCurrentUserState} from '@/constants/current-user' const waitToRefresh = 1000 * 60 * 5 diff --git a/shared/people/index.shared.tsx b/shared/people/index.shared.tsx index 66edb1f66e6d..3382989cbb90 100644 --- a/shared/people/index.shared.tsx +++ b/shared/people/index.shared.tsx @@ -8,7 +8,7 @@ import FollowSuggestions from './follow-suggestions' import type {Props} from '.' import Todo from './todo' import {useSignupState} from '@/constants/signup' -import {usePeopleState} from '@/constants/people' +import {usePeopleState} from '@/stores/people' // import WotTask from './wot-task' const itemToComponent: (item: T.Immutable, props: Props) => React.ReactNode = ( diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index 512f1545b35f..ee7d657574e8 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -11,7 +11,7 @@ import {useSettingsEmailState} from '@/constants/settings-email' import {settingsAccountTab, settingsGitTab} from '@/constants/settings/util' import {useTrackerState} from '@/constants/tracker2' import {useProfileState} from '@/constants/profile' -import {usePeopleState, todoTypes} from '@/constants/people' +import {usePeopleState, todoTypes} from '@/stores/people' import {useCurrentUserState} from '@/constants/current-user' type TodoOwnProps = { diff --git a/shared/constants/people/index.tsx b/shared/stores/people.tsx similarity index 98% rename from shared/constants/people/index.tsx rename to shared/stores/people.tsx index 5ac7397bc6c7..c3a6cda910af 100644 --- a/shared/constants/people/index.tsx +++ b/shared/stores/people.tsx @@ -1,17 +1,17 @@ import * as EngineGen from '@/actions/engine-gen-gen' -import {ignorePromise} from '../utils' +import {ignorePromise} from '@/constants/utils' import * as Z from '@/util/zustand' import invert from 'lodash/invert' import isEqual from 'lodash/isEqual' import logger from '@/logger' -import * as T from '../types' +import * as T from '@/constants/types' import type {IconType} from '@/common-adapters/icon.constants-gen' // do NOT pull in all of common-adapters -import {isMobile} from '../platform' +import {isMobile} from '@/constants/platform' import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' import debounce from 'lodash/debounce' -import {useConfigState} from '../config' +import {useConfigState} from '@/constants/config' import {useFollowerState} from '@/stores/followers' -import {RPCError, isNetworkErr} from '../utils' +import {RPCError, isNetworkErr} from '@/constants/utils' // set this to true to have all todo items + a contact joined notification show up all the time const debugTodo = false as boolean From 87338e6c928d2fe6db45f256bb280853252a9aed Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 15:43:24 -0500 Subject: [PATCH 15/37] WIP --- shared/constants/people/util.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/shared/constants/people/util.tsx b/shared/constants/people/util.tsx index 7ffa62fadadc..1e3112fb6f93 100644 --- a/shared/constants/people/util.tsx +++ b/shared/constants/people/util.tsx @@ -1,7 +1,5 @@ import * as T from '../types' import {ignorePromise} from '../utils' -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' export const onEngineConnected = () => { const f = async () => { @@ -14,4 +12,3 @@ export const onEngineConnected = () => { } ignorePromise(f()) } - From 443d41de3c9d7386e2a9d3052e16f852d039674f Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 15:51:11 -0500 Subject: [PATCH 16/37] WIP --- shared/constants/init/shared.tsx | 87 +++++++++++++++++-- shared/constants/notifications/util.tsx | 54 ------------ shared/constants/people/util.tsx | 14 --- shared/constants/pinentry/util.tsx | 28 ------ shared/desktop/renderer/main2.desktop.tsx | 2 +- shared/pinentry/remote-proxy.desktop.tsx | 2 +- shared/pinentry/remote-serializer.desktop.tsx | 2 +- .../index.tsx => stores/pinentry.tsx} | 4 +- 8 files changed, 84 insertions(+), 109 deletions(-) delete mode 100644 shared/constants/pinentry/util.tsx rename shared/{constants/pinentry/index.tsx => stores/pinentry.tsx} (97%) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 1886ebf8fc2d..bf87081d3501 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -1,6 +1,6 @@ import * as EngineGen from '@/actions/engine-gen-gen' import logger from '@/logger' -import {serverConfigFileName} from '../platform' +import {isMobile, serverConfigFileName} from '../platform' import * as T from '../types' import {ignorePromise} from '../utils' import type * as UseArchiveStateType from '@/stores/archive' @@ -21,10 +21,8 @@ import isEqual from 'lodash/isEqual' import type * as UseFSStateType from '@/stores/fs' import type * as UseGitStateType from '@/stores/git' import type * as UseNotificationsStateType from '@/stores/notifications' -import * as NotifUtil from '../notifications/util' import type * as UsePeopleStateType from '@/stores/people' -import * as PeopleUtil from '../people/util' -import * as PinentryUtil from '../pinentry/util' +import type * as UsePinentryStateType from '@/stores/pinentry' import {useProvisionState} from '../provision' import {storeRegistry} from '../store-registry' import {useSettingsContactsState} from '../settings-contacts' @@ -45,9 +43,77 @@ export const onEngineConnected = () => { ChatUtil.onEngineConnected() useConfigState.getState().dispatch.onEngineConnected() storeRegistry.getState('daemon').dispatch.startHandshake() - NotifUtil.onEngineConnected() - PeopleUtil.onEngineConnected() - PinentryUtil.onEngineConnected() + { + const f = async () => { + try { + await T.RPCGen.notifyCtlSetNotificationsRpcPromise({ + channels: { + allowChatNotifySkips: true, + app: true, + audit: true, + badges: true, + chat: true, + chatarchive: true, + chatattachments: true, + chatdev: false, + chatemoji: false, + chatemojicross: false, + chatkbfsedits: false, + deviceclone: false, + ephemeral: false, + favorites: false, + featuredBots: true, + kbfs: true, + kbfsdesktop: !isMobile, + kbfslegacy: false, + kbfsrequest: false, + kbfssubscription: true, + keyfamily: false, + notifysimplefs: true, + paperkeys: false, + pgp: true, + reachability: true, + runtimestats: true, + saltpack: true, + service: true, + session: true, + team: true, + teambot: false, + tracking: true, + users: true, + wallet: false, + }, + }) + } catch (error) { + if (error) { + logger.warn('error in toggling notifications: ', error) + } + } + } + ignorePromise(f()) + } + { + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterHomeUIRpcPromise() + console.log('Registered home UI') + } catch (error) { + console.warn('Error in registering home UI:', error) + } + } + ignorePromise(f()) + } + { + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterSecretUIRpcPromise() + logger.info('Registered secret ui') + } catch (error) { + logger.warn('error in registering secret ui: ', error) + } + } + ignorePromise(f()) + } TrackerUtil.onEngineConnected() UnlockFoldersUtil.onEngineConnected() } @@ -310,6 +376,12 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { usePeopleState.getState().dispatch.onEngineIncomingImpl(action) } break + case EngineGen.keybase1SecretUiGetPassphrase: + { + const {usePinentryState} = require('@/stores/pinentry') as typeof UsePinentryStateType + usePinentryState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) @@ -337,7 +409,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - PinentryUtil.onEngineIncoming(action) SettingsUtil.onEngineIncoming(action) SignupUtil.onEngineIncoming(action) TeamsUtil.onEngineIncoming(action) diff --git a/shared/constants/notifications/util.tsx b/shared/constants/notifications/util.tsx index ce8efc8cc9f0..e69de29bb2d1 100644 --- a/shared/constants/notifications/util.tsx +++ b/shared/constants/notifications/util.tsx @@ -1,54 +0,0 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import {isMobile} from '../platform' -import logger from '@/logger' - -export const onEngineConnected = () => { - const f = async () => { - try { - await T.RPCGen.notifyCtlSetNotificationsRpcPromise({ - channels: { - allowChatNotifySkips: true, - app: true, - audit: true, - badges: true, - chat: true, - chatarchive: true, - chatattachments: true, - chatdev: false, - chatemoji: false, - chatemojicross: false, - chatkbfsedits: false, - deviceclone: false, - ephemeral: false, - favorites: false, - featuredBots: true, - kbfs: true, - kbfsdesktop: !isMobile, - kbfslegacy: false, - kbfsrequest: false, - kbfssubscription: true, - keyfamily: false, - notifysimplefs: true, - paperkeys: false, - pgp: true, - reachability: true, - runtimestats: true, - saltpack: true, - service: true, - session: true, - team: true, - teambot: false, - tracking: true, - users: true, - wallet: false, - }, - }) - } catch (error) { - if (error) { - logger.warn('error in toggling notifications: ', error) - } - } - } - ignorePromise(f()) -} diff --git a/shared/constants/people/util.tsx b/shared/constants/people/util.tsx index 1e3112fb6f93..e69de29bb2d1 100644 --- a/shared/constants/people/util.tsx +++ b/shared/constants/people/util.tsx @@ -1,14 +0,0 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' - -export const onEngineConnected = () => { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterHomeUIRpcPromise() - console.log('Registered home UI') - } catch (error) { - console.warn('Error in registering home UI:', error) - } - } - ignorePromise(f()) -} diff --git a/shared/constants/pinentry/util.tsx b/shared/constants/pinentry/util.tsx deleted file mode 100644 index 5bc792128d6e..000000000000 --- a/shared/constants/pinentry/util.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import * as EngineGen from '@/actions/engine-gen-gen' -import {usePinentryState} from '../pinentry' -import logger from '@/logger' - -export const onEngineConnected = () => { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterSecretUIRpcPromise() - logger.info('Registered secret ui') - } catch (error) { - logger.warn('error in registering secret ui: ', error) - } - } - ignorePromise(f()) -} - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1SecretUiGetPassphrase: - { - usePinentryState.getState().dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/desktop/renderer/main2.desktop.tsx b/shared/desktop/renderer/main2.desktop.tsx index 806f02d32eae..03b89cecfe96 100644 --- a/shared/desktop/renderer/main2.desktop.tsx +++ b/shared/desktop/renderer/main2.desktop.tsx @@ -13,7 +13,7 @@ import {isWindows} from '@/constants/platform' import KB2 from '@/util/electron.desktop' import {ignorePromise} from '@/constants/utils' import {useConfigState} from '@/constants/config' -import {usePinentryState} from '@/constants/pinentry' +import {usePinentryState} from '@/stores/pinentry' import * as T from '@/constants/types' import {RPCError} from '@/util/errors' import {switchTab} from '@/constants/router2/util' diff --git a/shared/pinentry/remote-proxy.desktop.tsx b/shared/pinentry/remote-proxy.desktop.tsx index 587043c04c1d..ea897586694b 100644 --- a/shared/pinentry/remote-proxy.desktop.tsx +++ b/shared/pinentry/remote-proxy.desktop.tsx @@ -6,7 +6,7 @@ import useBrowserWindow from '../desktop/remote/use-browser-window.desktop' import useSerializeProps from '../desktop/remote/use-serialize-props.desktop' import {serialize, type ProxyProps} from './remote-serializer.desktop' import {useColorScheme} from 'react-native' -import {usePinentryState} from '@/constants/pinentry' +import {usePinentryState} from '@/stores/pinentry' const windowOpts = {height: 230, width: 440} diff --git a/shared/pinentry/remote-serializer.desktop.tsx b/shared/pinentry/remote-serializer.desktop.tsx index 96f859f93cce..ca291a3014af 100644 --- a/shared/pinentry/remote-serializer.desktop.tsx +++ b/shared/pinentry/remote-serializer.desktop.tsx @@ -1,5 +1,5 @@ import * as T from '@/constants/types' -import type * as Constants from '@/constants/pinentry' +import type * as Constants from '@/stores/pinentry' import {produce} from 'immer' export type ProxyProps = { diff --git a/shared/constants/pinentry/index.tsx b/shared/stores/pinentry.tsx similarity index 97% rename from shared/constants/pinentry/index.tsx rename to shared/stores/pinentry.tsx index 45caef2e55d3..8ad874ff5cf1 100644 --- a/shared/constants/pinentry/index.tsx +++ b/shared/stores/pinentry.tsx @@ -1,9 +1,9 @@ import * as Z from '@/util/zustand' import * as EngineGen from '@/actions/engine-gen-gen' -import * as T from '../types' +import * as T from '@/constants/types' import logger from '@/logger' import {invalidPasswordErrorString} from '@/constants/config/util' -import {wrapErrors} from '../utils' +import {wrapErrors} from '@/constants/utils' // This store has no dependencies on other stores and is safe to import directly from other stores. export type Store = T.Immutable<{ From 61301fc832e510a75bed9f39ea1053a383f7c777 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:01:05 -0500 Subject: [PATCH 17/37] WIP --- shared/constants/init/shared.tsx | 22 +++++++++++++---- shared/constants/settings/util.tsx | 13 ---------- shared/constants/signup/util.tsx | 13 ---------- shared/constants/store-registry.tsx | 8 +++---- shared/devices/device-revoke.tsx | 2 +- shared/incoming-share/index.tsx | 2 +- shared/login/join-or-login.tsx | 2 +- shared/login/relogin/container.tsx | 2 +- shared/login/signup/error.tsx | 2 +- shared/people/container.tsx | 2 +- shared/people/index.shared.tsx | 2 +- shared/provision/username-or-email.tsx | 2 +- shared/settings/account/index.tsx | 2 +- shared/settings/advanced.tsx | 2 +- shared/settings/archive/modal.tsx | 2 +- shared/settings/chat.tsx | 2 +- shared/settings/db-nuke.confirm.tsx | 2 +- .../check-passphrase.native.tsx | 2 +- shared/settings/delete-confirm/index.tsx | 2 +- .../settings/disable-cert-pinning-modal.tsx | 2 +- shared/settings/logout.tsx | 2 +- shared/settings/manage-contacts.tsx | 2 +- shared/settings/notifications/hooks.tsx | 2 +- .../settings/notifications/index.desktop.tsx | 2 +- .../settings/notifications/index.native.tsx | 2 +- shared/settings/proxy.tsx | 2 +- shared/settings/root-desktop-tablet.tsx | 2 +- shared/settings/root-phone.tsx | 2 +- shared/settings/sub-nav/left-nav.tsx | 2 +- shared/signup/device-name.tsx | 2 +- shared/signup/email.tsx | 2 +- shared/signup/username.tsx | 2 +- .../index.tsx => stores/settings.tsx} | 24 +++++++++---------- .../signup/index.tsx => stores/signup.tsx} | 14 +++++------ 34 files changed, 69 insertions(+), 81 deletions(-) delete mode 100644 shared/constants/signup/util.tsx rename shared/{constants/settings/index.tsx => stores/settings.tsx} (92%) rename shared/{constants/signup/index.tsx => stores/signup.tsx} (96%) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index bf87081d3501..d7cb9a8dcb19 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -26,8 +26,8 @@ import type * as UsePinentryStateType from '@/stores/pinentry' import {useProvisionState} from '../provision' import {storeRegistry} from '../store-registry' import {useSettingsContactsState} from '../settings-contacts' -import * as SettingsUtil from '../settings/util' -import * as SignupUtil from '../signup/util' +import type * as UseSettingsStateType from '@/stores/settings' +import type * as UseSignupStateType from '@/stores/signup' import {useTeamsState} from '../teams' import * as TeamsUtil from '../teams/util' import * as TrackerUtil from '../tracker2/util' @@ -382,6 +382,22 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { usePinentryState.getState().dispatch.onEngineIncomingImpl(action) } break + case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: + { + const {useSettingsState} = require('@/stores/settings') as typeof UseSettingsStateType + useSettingsState.getState().dispatch.onEngineIncomingImpl(action) + const {useSignupState} = require('@/stores/signup') as typeof UseSignupStateType + useSignupState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.keybase1NotifyUsersPasswordChanged: + case EngineGen.keybase1NotifyPhoneNumberPhoneNumbersChanged: + case EngineGen.keybase1NotifyEmailAddressEmailsChanged: + { + const {useSettingsState} = require('@/stores/settings') as typeof UseSettingsStateType + useSettingsState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) @@ -409,8 +425,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - SettingsUtil.onEngineIncoming(action) - SignupUtil.onEngineIncoming(action) TeamsUtil.onEngineIncoming(action) TrackerUtil.onEngineIncoming(action) UnlockFoldersUtil.onEngineIncoming(action) diff --git a/shared/constants/settings/util.tsx b/shared/constants/settings/util.tsx index 281dc0582fd5..060f312720d7 100644 --- a/shared/constants/settings/util.tsx +++ b/shared/constants/settings/util.tsx @@ -48,16 +48,3 @@ export type SettingsTab = | typeof settingsContactsTab | typeof settingsWhatsNewTab -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: - case EngineGen.keybase1NotifyUsersPasswordChanged: - case EngineGen.keybase1NotifyPhoneNumberPhoneNumbersChanged: - case EngineGen.keybase1NotifyEmailAddressEmailsChanged: - { - storeRegistry.getState('settings').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/signup/util.tsx b/shared/constants/signup/util.tsx deleted file mode 100644 index 7c58483bdb13..000000000000 --- a/shared/constants/signup/util.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: - { - storeRegistry.getState('signup').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index d6989f41784f..254c59bac820 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -20,13 +20,13 @@ import type { State as RecoverPasswordState, useState as useRecoverPasswordState, } from '@/constants/recover-password' -import type {State as SettingsState, useSettingsState} from '@/constants/settings' +import type {State as SettingsState, useSettingsState} from '@/stores/settings' import type {State as SettingsChatState, useSettingsChatState} from '@/constants/settings-chat' import type {State as SettingsContactsState, useSettingsContactsState} from '@/constants/settings-contacts' import type {State as SettingsEmailState, useSettingsEmailState} from '@/constants/settings-email' import type {State as SettingsPasswordState, usePWState} from '@/constants/settings-password' import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/constants/settings-phone' -import type {State as SignupState, useSignupState} from '@/constants/signup' +import type {State as SignupState, useSignupState} from '@/stores/signup' import type {State as TeamsState, useTeamsState} from '@/constants/teams' import type {State as Tracker2State, useTrackerState} from '@/constants/tracker2' import type {State as UnlockFoldersState, useUnlockFoldersState} from '@/constants/unlock-folders' @@ -169,7 +169,7 @@ class StoreRegistry { return useState } case 'settings': { - const {useSettingsState} = require('@/constants/settings') + const {useSettingsState} = require('@/stores/settings') return useSettingsState } case 'settings-chat': { @@ -193,7 +193,7 @@ class StoreRegistry { return useSettingsPhoneState } case 'signup': { - const {useSignupState} = require('@/constants/signup') + const {useSignupState} = require('@/stores/signup') return useSignupState } case 'teams': { diff --git a/shared/devices/device-revoke.tsx b/shared/devices/device-revoke.tsx index 26f9a09bb95d..71dd2af936dc 100644 --- a/shared/devices/device-revoke.tsx +++ b/shared/devices/device-revoke.tsx @@ -4,7 +4,7 @@ import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' -import {settingsDevicesTab} from '@/constants/settings' +import {settingsDevicesTab} from '@/stores/settings' import {useCurrentUserState} from '@/constants/current-user' type OwnProps = {deviceID: string} diff --git a/shared/incoming-share/index.tsx b/shared/incoming-share/index.tsx index dcfb5e355583..aa272f32fe90 100644 --- a/shared/incoming-share/index.tsx +++ b/shared/incoming-share/index.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as FsCommon from '@/fs/common' import {MobileSendToChat} from '../chat/send-to-chat' -import {settingsFeedbackTab} from '@/constants/settings' +import {settingsFeedbackTab} from '@/stores/settings' import * as FS from '@/stores/fs' import {useFSState} from '@/stores/fs' import {useConfigState} from '@/constants/config' diff --git a/shared/login/join-or-login.tsx b/shared/login/join-or-login.tsx index 543fb0be1d2c..db53e45b736d 100644 --- a/shared/login/join-or-login.tsx +++ b/shared/login/join-or-login.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import {useConfigState} from '@/constants/config' import * as Kb from '@/common-adapters' import {InfoIcon} from '@/signup/common' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {useProvisionState} from '@/constants/provision' const Intro = () => { diff --git a/shared/login/relogin/container.tsx b/shared/login/relogin/container.tsx index 2e80b7856bc6..ca30787bccfb 100644 --- a/shared/login/relogin/container.tsx +++ b/shared/login/relogin/container.tsx @@ -4,7 +4,7 @@ import {useConfigState} from '@/constants/config' import Login from '.' import sortBy from 'lodash/sortBy' import {useState as useRecoverState} from '@/constants/recover-password' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {useProvisionState} from '@/constants/provision' const needPasswordError = 'passphrase cannot be empty' diff --git a/shared/login/signup/error.tsx b/shared/login/signup/error.tsx index f646b1337698..04ff47e90e7b 100644 --- a/shared/login/signup/error.tsx +++ b/shared/login/signup/error.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import {Wrapper, ContinueButton} from './common' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' const ConnectedSignupError = () => { const error = useSignupState(s => s.signupError) diff --git a/shared/people/container.tsx b/shared/people/container.tsx index b868032a7339..1c97cebe18d3 100644 --- a/shared/people/container.tsx +++ b/shared/people/container.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import People from '.' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {useProfileState} from '@/constants/profile' import {usePeopleState, getPeopleDataWaitingKey} from '@/stores/people' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/people/index.shared.tsx b/shared/people/index.shared.tsx index 3382989cbb90..e51585aa6339 100644 --- a/shared/people/index.shared.tsx +++ b/shared/people/index.shared.tsx @@ -7,7 +7,7 @@ import FollowNotification from './follow-notification' import FollowSuggestions from './follow-suggestions' import type {Props} from '.' import Todo from './todo' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {usePeopleState} from '@/stores/people' // import WotTask from './wot-task' diff --git a/shared/provision/username-or-email.tsx b/shared/provision/username-or-email.tsx index f9e69919dbd7..5d38de65f6b9 100644 --- a/shared/provision/username-or-email.tsx +++ b/shared/provision/username-or-email.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as AutoReset from '@/stores/autoreset' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {useSafeSubmit} from '@/util/safe-submit' import * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/settings/account/index.tsx b/shared/settings/account/index.tsx index 1cc8a39c9352..6137476c099e 100644 --- a/shared/settings/account/index.tsx +++ b/shared/settings/account/index.tsx @@ -5,7 +5,7 @@ import EmailPhoneRow from './email-phone-row' import {usePWState} from '@/constants/settings-password' import {useSettingsPhoneState} from '@/constants/settings-phone' import {useSettingsEmailState} from '@/constants/settings-email' -import {useSettingsState, settingsPasswordTab} from '@/constants/settings' +import {useSettingsState, settingsPasswordTab} from '@/stores/settings' export const SettingsSection = ({children}: {children: React.ReactNode}) => ( diff --git a/shared/settings/advanced.tsx b/shared/settings/advanced.tsx index f72060b34b02..a19b5e870d9e 100644 --- a/shared/settings/advanced.tsx +++ b/shared/settings/advanced.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as React from 'react' import {ProxySettings} from './proxy' -import {useSettingsState, traceInProgressKey, processorProfileInProgressKey} from '@/constants/settings' +import {useSettingsState, traceInProgressKey, processorProfileInProgressKey} from '@/stores/settings' import {usePWState} from '@/constants/settings-password' import {useFSState} from '@/stores/fs' import {useConfigState} from '@/constants/config' diff --git a/shared/settings/archive/modal.tsx b/shared/settings/archive/modal.tsx index 4b12731e4d79..dc236ceadc17 100644 --- a/shared/settings/archive/modal.tsx +++ b/shared/settings/archive/modal.tsx @@ -5,7 +5,7 @@ import type * as T from '@/constants/types' import {pickSave} from '@/util/pick-files' import * as FsCommon from '@/fs/common' import {useArchiveState} from '@/stores/archive' -import {settingsArchiveTab} from '@/constants/settings' +import {settingsArchiveTab} from '@/stores/settings' import {useCurrentUserState} from '@/constants/current-user' import {getConvoState} from '@/constants/chat2/convostate' diff --git a/shared/settings/chat.tsx b/shared/settings/chat.tsx index 5a0fc327fbe0..81040dd72cfd 100644 --- a/shared/settings/chat.tsx +++ b/shared/settings/chat.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import Group from './group' import {useSettingsChatState as useSettingsChatState} from '@/constants/settings-chat' import {useSettingsNotifState} from '@/constants/settings-notifications' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' import {useConfigState} from '@/constants/config' const emptyList = new Array() diff --git a/shared/settings/db-nuke.confirm.tsx b/shared/settings/db-nuke.confirm.tsx index 5c4b71083a5d..d286b5367ddd 100644 --- a/shared/settings/db-nuke.confirm.tsx +++ b/shared/settings/db-nuke.confirm.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' const DbNukeConfirm = () => { const navigateUp = C.useRouterState(s => s.dispatch.navigateUp) diff --git a/shared/settings/delete-confirm/check-passphrase.native.tsx b/shared/settings/delete-confirm/check-passphrase.native.tsx index a861c09207b8..00010f8bf4db 100644 --- a/shared/settings/delete-confirm/check-passphrase.native.tsx +++ b/shared/settings/delete-confirm/check-passphrase.native.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' const CheckPassphraseMobile = () => { const [password, setPassword] = React.useState('') diff --git a/shared/settings/delete-confirm/index.tsx b/shared/settings/delete-confirm/index.tsx index 1a4a243a2ca5..e87a8cdc0d20 100644 --- a/shared/settings/delete-confirm/index.tsx +++ b/shared/settings/delete-confirm/index.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' import {usePWState} from '@/constants/settings-password' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' import {useCurrentUserState} from '@/constants/current-user' type CheckboxesProps = { diff --git a/shared/settings/disable-cert-pinning-modal.tsx b/shared/settings/disable-cert-pinning-modal.tsx index b84956f0114d..8fe63caf18c2 100644 --- a/shared/settings/disable-cert-pinning-modal.tsx +++ b/shared/settings/disable-cert-pinning-modal.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' const DisableCertPinningModal = () => { const navigateUp = C.useRouterState(s => s.dispatch.navigateUp) diff --git a/shared/settings/logout.tsx b/shared/settings/logout.tsx index b5d765d9287c..e16bce574a43 100644 --- a/shared/settings/logout.tsx +++ b/shared/settings/logout.tsx @@ -4,7 +4,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import {UpdatePassword} from './password' import {usePWState} from '@/constants/settings-password' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' import {useLogoutState} from '@/constants/logout' const LogoutContainer = () => { diff --git a/shared/settings/manage-contacts.tsx b/shared/settings/manage-contacts.tsx index fa5f9f6a3764..58c78aa8070b 100644 --- a/shared/settings/manage-contacts.tsx +++ b/shared/settings/manage-contacts.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import {SettingsSection} from './account' import {useSettingsContactsState} from '@/constants/settings-contacts' -import {settingsFeedbackTab} from '@/constants/settings' +import {settingsFeedbackTab} from '@/stores/settings' import {useConfigState} from '@/constants/config' const enabledDescription = 'Your phone contacts are being synced on this device.' diff --git a/shared/settings/notifications/hooks.tsx b/shared/settings/notifications/hooks.tsx index 210c1149d735..611f53430ac0 100644 --- a/shared/settings/notifications/hooks.tsx +++ b/shared/settings/notifications/hooks.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import {useSettingsEmailState} from '@/constants/settings-email' import {useSettingsNotifState} from '@/constants/settings-notifications' -import {useSettingsState, settingsAccountTab} from '@/constants/settings' +import {useSettingsState, settingsAccountTab} from '@/stores/settings' const useNotifications = () => { const _groups = useSettingsNotifState(s => s.groups) diff --git a/shared/settings/notifications/index.desktop.tsx b/shared/settings/notifications/index.desktop.tsx index 003323b3e450..a0ad16c1172e 100644 --- a/shared/settings/notifications/index.desktop.tsx +++ b/shared/settings/notifications/index.desktop.tsx @@ -2,7 +2,7 @@ import {Reloadable} from '@/common-adapters' import * as C from '@/constants' import Render from './render' import {useSettingsNotifState} from '@/constants/settings-notifications' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' const Notifications = () => { const loadSettings = useSettingsState(s => s.dispatch.loadSettings) diff --git a/shared/settings/notifications/index.native.tsx b/shared/settings/notifications/index.native.tsx index 50eb9263f81a..97d950d11bcd 100644 --- a/shared/settings/notifications/index.native.tsx +++ b/shared/settings/notifications/index.native.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import Notifications from './render' import {Reloadable} from '@/common-adapters' import {useSettingsNotifState} from '@/constants/settings-notifications' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' import {usePushState} from '@/constants/push' const MobileNotifications = () => { diff --git a/shared/settings/proxy.tsx b/shared/settings/proxy.tsx index 06975d317b3d..3239af09aba9 100644 --- a/shared/settings/proxy.tsx +++ b/shared/settings/proxy.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import {useSettingsState} from '@/constants/settings' +import {useSettingsState} from '@/stores/settings' const useConnect = () => { const allowTlsMitmToggle = useSettingsState(s => s.didToggleCertificatePinning) diff --git a/shared/settings/root-desktop-tablet.tsx b/shared/settings/root-desktop-tablet.tsx index 7b29c0799c0d..8c76227cdd56 100644 --- a/shared/settings/root-desktop-tablet.tsx +++ b/shared/settings/root-desktop-tablet.tsx @@ -6,7 +6,7 @@ import LeftNav from './sub-nav/left-nav' import {useNavigationBuilder, TabRouter, createNavigatorFactory} from '@react-navigation/core' import type {TypedNavigator, NavigatorTypeBagBase, StaticConfig} from '@react-navigation/native' import {sharedNewRoutes} from './routes' -import {settingsAccountTab} from '@/constants/settings' +import {settingsAccountTab} from '@/stores/settings' const settingsSubRoutes = { ...sharedNewRoutes, diff --git a/shared/settings/root-phone.tsx b/shared/settings/root-phone.tsx index a94d5a7caa31..168f01bca1df 100644 --- a/shared/settings/root-phone.tsx +++ b/shared/settings/root-phone.tsx @@ -8,7 +8,7 @@ import SettingsItem from './sub-nav/settings-item' import WhatsNewIcon from '../whats-new/icon' import noop from 'lodash/noop' import {useSettingsContactsState} from '@/constants/settings-contacts' -import * as Settings from '@/constants/settings' +import * as Settings from '@/stores/settings' import {usePushState} from '@/constants/push' import {useNotifState} from '@/stores/notifications' diff --git a/shared/settings/sub-nav/left-nav.tsx b/shared/settings/sub-nav/left-nav.tsx index 1238f05ef3a0..4608d0727afb 100644 --- a/shared/settings/sub-nav/left-nav.tsx +++ b/shared/settings/sub-nav/left-nav.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import WhatsNewIcon from '@/whats-new/icon' import SettingsItem from './settings-item' import {keybaseFM} from '@/constants/whats-new' -import * as Settings from '@/constants/settings' +import * as Settings from '@/stores/settings' import {usePushState} from '@/constants/push' import {useNotifState} from '@/stores/notifications' diff --git a/shared/signup/device-name.tsx b/shared/signup/device-name.tsx index 8abc7478d70d..6f558ccd00ed 100644 --- a/shared/signup/device-name.tsx +++ b/shared/signup/device-name.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import {SignupScreen, errorBanner} from './common' import * as Provision from '@/constants/provision' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' const ConnectedEnterDevicename = () => { const error = useSignupState(s => s.devicenameError) diff --git a/shared/signup/email.tsx b/shared/signup/email.tsx index 1593cf89c1e0..e0585812a33b 100644 --- a/shared/signup/email.tsx +++ b/shared/signup/email.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen, errorBanner} from './common' import {useSettingsEmailState} from '@/constants/settings-email' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {usePushState} from '@/constants/push' const ConnectedEnterEmail = () => { diff --git a/shared/signup/username.tsx b/shared/signup/username.tsx index b22cfb0705fb..68f1d9019e15 100644 --- a/shared/signup/username.tsx +++ b/shared/signup/username.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' import {SignupScreen, errorBanner} from './common' -import {useSignupState} from '@/constants/signup' +import {useSignupState} from '@/stores/signup' import {useProvisionState} from '@/constants/provision' const ConnectedEnterUsername = () => { diff --git a/shared/constants/settings/index.tsx b/shared/stores/settings.tsx similarity index 92% rename from shared/constants/settings/index.tsx rename to shared/stores/settings.tsx index 16ffc111cdcf..8eace187e75c 100644 --- a/shared/constants/settings/index.tsx +++ b/shared/stores/settings.tsx @@ -1,21 +1,21 @@ -import * as T from '../types' -import {ignorePromise, timeoutPromise} from '../utils' -import * as S from '../strings' -import {androidIsTestDevice, pprofDir} from '../platform' +import * as T from '@/constants/types' +import {ignorePromise, timeoutPromise} from '@/constants/utils' +import * as S from '@/constants/strings' +import {androidIsTestDevice, pprofDir} from '@/constants/platform' import * as EngineGen from '@/actions/engine-gen-gen' import openURL from '@/util/open-url' import * as Z from '@/util/zustand' import {RPCError} from '@/util/errors' -import * as Tabs from '../tabs' +import * as Tabs from '@/constants/tabs' import logger from '@/logger' -import {clearModals, navigateAppend, switchTab} from '../router2/util' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' -import {useWaitingState} from '../waiting' -import {processorProfileInProgressKey, traceInProgressKey} from './util' +import {clearModals, navigateAppend, switchTab} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' +import {useConfigState} from '@/constants/config' +import {useCurrentUserState} from '@/constants/current-user' +import {useWaitingState} from '@/constants/waiting' +import {processorProfileInProgressKey, traceInProgressKey} from '@/constants/settings/util' -export * from './util' +export * from '@/constants/settings/util' type Store = T.Immutable<{ checkPasswordIsCorrect?: boolean diff --git a/shared/constants/signup/index.tsx b/shared/stores/signup.tsx similarity index 96% rename from shared/constants/signup/index.tsx rename to shared/stores/signup.tsx index dfa015b6319a..f885e51bdd0f 100644 --- a/shared/constants/signup/index.tsx +++ b/shared/stores/signup.tsx @@ -1,16 +1,16 @@ -import * as Platforms from '../platform' -import {ignorePromise} from '../utils' -import * as S from '../strings' +import * as Platforms from '@/constants/platform' +import {ignorePromise} from '@/constants/utils' +import * as S from '@/constants/strings' import * as EngineGen from '@/actions/engine-gen-gen' -import * as T from '../types' +import * as T from '@/constants/types' import * as Z from '@/util/zustand' import logger from '@/logger' import trim from 'lodash/trim' import {RPCError} from '@/util/errors' import {isValidEmail, isValidName, isValidUsername} from '@/util/simple-validators' -import {navigateAppend, navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' +import {navigateAppend, navigateUp} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' +import {useConfigState} from '@/constants/config' type Store = T.Immutable<{ devicename: string From a463d2ad0ec919918c632d7c2202bf78140e9a8c Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:10:37 -0500 Subject: [PATCH 18/37] WIP --- shared/constants/init/shared.tsx | 33 ++++++++++++++++++------------ shared/constants/logout/index.tsx | 2 +- shared/constants/settings/util.tsx | 4 ---- shared/stores/settings.tsx | 30 --------------------------- 4 files changed, 21 insertions(+), 48 deletions(-) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index d7cb9a8dcb19..973e6c649be3 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -26,7 +26,6 @@ import type * as UsePinentryStateType from '@/stores/pinentry' import {useProvisionState} from '../provision' import {storeRegistry} from '../store-registry' import {useSettingsContactsState} from '../settings-contacts' -import type * as UseSettingsStateType from '@/stores/settings' import type * as UseSignupStateType from '@/stores/signup' import {useTeamsState} from '../teams' import * as TeamsUtil from '../teams/util' @@ -374,6 +373,12 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { { const {usePeopleState} = require('@/stores/people') as typeof UsePeopleStateType usePeopleState.getState().dispatch.onEngineIncomingImpl(action) + const emailAddress = action.payload.params?.emailAddress + if (emailAddress) { + storeRegistry.getState('settings-email').dispatch.notifyEmailVerified(emailAddress) + } + const {useSignupState} = require('@/stores/signup') as typeof UseSignupStateType + useSignupState.getState().dispatch.onEngineIncomingImpl(action) } break case EngineGen.keybase1SecretUiGetPassphrase: @@ -382,22 +387,24 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { usePinentryState.getState().dispatch.onEngineIncomingImpl(action) } break - case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: - { - const {useSettingsState} = require('@/stores/settings') as typeof UseSettingsStateType - useSettingsState.getState().dispatch.onEngineIncomingImpl(action) - const {useSignupState} = require('@/stores/signup') as typeof UseSignupStateType - useSignupState.getState().dispatch.onEngineIncomingImpl(action) - } - break case EngineGen.keybase1NotifyUsersPasswordChanged: - case EngineGen.keybase1NotifyPhoneNumberPhoneNumbersChanged: - case EngineGen.keybase1NotifyEmailAddressEmailsChanged: { - const {useSettingsState} = require('@/stores/settings') as typeof UseSettingsStateType - useSettingsState.getState().dispatch.onEngineIncomingImpl(action) + const randomPW = action.payload.params.state === T.RPCGen.PassphraseState.random + storeRegistry.getState('settings-password').dispatch.notifyUsersPasswordChanged(randomPW) } break + case EngineGen.keybase1NotifyPhoneNumberPhoneNumbersChanged: { + const {list} = action.payload.params + storeRegistry + .getState('settings-phone') + .dispatch.notifyPhoneNumberPhoneNumbersChanged(list ?? undefined) + break + } + case EngineGen.keybase1NotifyEmailAddressEmailsChanged: { + const list = action.payload.params.list ?? [] + storeRegistry.getState('settings-email').dispatch.notifyEmailAddressEmailsChanged(list) + break + } default: } AvatarUtil.onEngineIncoming(action) diff --git a/shared/constants/logout/index.tsx b/shared/constants/logout/index.tsx index 82a3c99c749f..bcf8c637a648 100644 --- a/shared/constants/logout/index.tsx +++ b/shared/constants/logout/index.tsx @@ -3,7 +3,7 @@ import {ignorePromise, timeoutPromise} from '../utils' import * as T from '@/constants/types' // normally util.container but it re-exports from us so break the cycle import * as Z from '@/util/zustand' -import {settingsPasswordTab} from '../settings' +import {settingsPasswordTab} from '@/constants/settings/util' import {navigateAppend} from '../router2/util' import {isMobile} from '../platform' import * as Tabs from '../tabs' diff --git a/shared/constants/settings/util.tsx b/shared/constants/settings/util.tsx index 060f312720d7..b54c44d6f26e 100644 --- a/shared/constants/settings/util.tsx +++ b/shared/constants/settings/util.tsx @@ -1,6 +1,3 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - export const traceInProgressKey = 'settings:traceInProgress' export const processorProfileInProgressKey = 'settings:processorProfileInProgress' @@ -47,4 +44,3 @@ export type SettingsTab = | typeof settingsCryptoTab | typeof settingsContactsTab | typeof settingsWhatsNewTab - diff --git a/shared/stores/settings.tsx b/shared/stores/settings.tsx index 8eace187e75c..03545e1f668b 100644 --- a/shared/stores/settings.tsx +++ b/shared/stores/settings.tsx @@ -2,7 +2,6 @@ import * as T from '@/constants/types' import {ignorePromise, timeoutPromise} from '@/constants/utils' import * as S from '@/constants/strings' import {androidIsTestDevice, pprofDir} from '@/constants/platform' -import * as EngineGen from '@/actions/engine-gen-gen' import openURL from '@/util/open-url' import * as Z from '@/util/zustand' import {RPCError} from '@/util/errors' @@ -40,7 +39,6 @@ export interface State extends Store { loadProxyData: () => void loadSettings: () => void loginBrowserViaWebAuthToken: () => void - onEngineIncomingImpl: (action: EngineGen.Actions) => void processorProfile: (durationSeconds: number) => void resetCheckPassword: () => void resetState: 'default' @@ -173,34 +171,6 @@ export const useSettingsState = Z.createZustand(set => { } ignorePromise(f()) }, - onEngineIncomingImpl: action => { - switch (action.type) { - case EngineGen.keybase1NotifyEmailAddressEmailAddressVerified: - logger.info('email verified') - storeRegistry - .getState('settings-email') - .dispatch.notifyEmailVerified(action.payload.params.emailAddress) - break - case EngineGen.keybase1NotifyUsersPasswordChanged: { - const randomPW = action.payload.params.state === T.RPCGen.PassphraseState.random - storeRegistry.getState('settings-password').dispatch.notifyUsersPasswordChanged(randomPW) - break - } - case EngineGen.keybase1NotifyPhoneNumberPhoneNumbersChanged: { - const {list} = action.payload.params - storeRegistry - .getState('settings-phone') - .dispatch.notifyPhoneNumberPhoneNumbersChanged(list ?? undefined) - break - } - case EngineGen.keybase1NotifyEmailAddressEmailsChanged: { - const list = action.payload.params.list ?? [] - storeRegistry.getState('settings-email').dispatch.notifyEmailAddressEmailsChanged(list) - break - } - default: - } - }, processorProfile: profileDurationSeconds => { const f = async () => { await T.RPCGen.pprofLogProcessorProfileRpcPromise({ From 2c4229ce68a7d3827e0eb28c3240eb18f9468833 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:13:36 -0500 Subject: [PATCH 19/37] WIP --- shared/chat/blocking/block-modal.tsx | 2 +- shared/chat/conversation/bot/install.tsx | 2 +- .../conversation/info-panel/add-people.tsx | 2 +- .../info-panel/add-to-channel.tsx | 2 +- shared/chat/conversation/info-panel/bot.tsx | 2 +- .../chat/conversation/info-panel/common.tsx | 2 +- .../chat/conversation/info-panel/header.tsx | 2 +- shared/chat/conversation/info-panel/index.tsx | 2 +- .../chat/conversation/info-panel/members.tsx | 2 +- shared/chat/conversation/info-panel/menu.tsx | 2 +- .../info-panel/settings/index.tsx | 2 +- .../info-panel/settings/min-writer-role.tsx | 2 +- .../input-area/suggestors/channels.tsx | 2 +- .../input-area/suggestors/users.tsx | 2 +- .../messages/cards/team-journey/container.tsx | 2 +- .../messages/message-popup/hooks.tsx | 2 +- .../messages/retention-notice.tsx | 2 +- .../chat/conversation/messages/separator.tsx | 2 +- .../system-added-to-team/container.tsx | 2 +- .../system-change-retention/container.tsx | 2 +- .../messages/system-create-team/container.tsx | 2 +- .../system-invite-accepted/container.tsx | 2 +- .../messages/system-new-channel/container.tsx | 2 +- .../system-simple-to-complex/container.tsx | 2 +- shared/chat/conversation/pinned-message.tsx | 2 +- shared/chat/create-channel/hooks.tsx | 2 +- shared/chat/emoji-picker/container.tsx | 2 +- shared/chat/inbox-and-conversation-header.tsx | 2 +- shared/chat/inbox-search/index.tsx | 2 +- shared/chat/inbox/row/big-team-header.tsx | 2 +- shared/chat/inbox/row/build-team.tsx | 2 +- shared/chat/new-team-dialog-container.tsx | 2 +- .../markdown/maybe-mention/team.tsx | 2 +- shared/common-adapters/name-with-icon.tsx | 2 +- shared/common-adapters/team-with-popup.tsx | 2 +- shared/constants/init/shared.tsx | 23 +++++++++++++++--- shared/constants/store-registry.tsx | 4 ++-- shared/constants/teams/util.tsx | 20 ---------------- shared/git/new-repo.tsx | 2 +- shared/git/row.tsx | 2 +- shared/git/select-channel.tsx | 2 +- shared/people/todo.tsx | 2 +- shared/profile/add-to-team.tsx | 2 +- shared/profile/edit-avatar/hooks.tsx | 2 +- shared/profile/showcase-team-offer.tsx | 2 +- shared/profile/user/teams/index.tsx | 2 +- shared/settings/chat.tsx | 2 +- .../teams/index.tsx => stores/teams.tsx} | 24 +++++++++---------- shared/team-building/index.tsx | 2 +- shared/team-building/list-body.tsx | 2 +- .../add-contacts.native.tsx | 2 +- shared/teams/add-members-wizard/add-email.tsx | 2 +- .../add-members-wizard/add-from-where.tsx | 2 +- shared/teams/add-members-wizard/add-phone.tsx | 2 +- shared/teams/add-members-wizard/confirm.tsx | 4 ++-- shared/teams/channel/create-channels.tsx | 2 +- shared/teams/channel/header.tsx | 4 ++-- shared/teams/channel/index.tsx | 2 +- shared/teams/channel/rows.tsx | 2 +- shared/teams/channel/tabs.tsx | 2 +- shared/teams/common/activity.tsx | 4 ++-- shared/teams/common/channel-hooks.tsx | 2 +- shared/teams/common/selection-popup.tsx | 4 ++-- .../teams/confirm-modals/confirm-kick-out.tsx | 4 ++-- .../confirm-remove-from-channel.tsx | 4 ++-- .../teams/confirm-modals/delete-channel.tsx | 2 +- .../really-leave-team/index.tsx | 4 ++-- shared/teams/container.tsx | 2 +- shared/teams/delete-team.tsx | 4 ++-- shared/teams/edit-team-description.tsx | 2 +- shared/teams/external-team.tsx | 2 +- shared/teams/get-options.tsx | 2 +- .../team-invite-by-contacts.native.tsx | 2 +- shared/teams/invite-by-email.tsx | 2 +- shared/teams/join-team/container.tsx | 2 +- shared/teams/join-team/join-from-invite.tsx | 2 +- shared/teams/main/index.tsx | 2 +- shared/teams/main/team-row.tsx | 4 ++-- shared/teams/new-team/index.tsx | 2 +- .../new-team/wizard/add-subteam-members.tsx | 2 +- .../teams/new-team/wizard/create-channels.tsx | 2 +- .../teams/new-team/wizard/create-subteams.tsx | 2 +- .../teams/new-team/wizard/make-big-team.tsx | 2 +- .../teams/new-team/wizard/new-team-info.tsx | 4 ++-- shared/teams/new-team/wizard/team-purpose.tsx | 2 +- shared/teams/rename-team.tsx | 2 +- shared/teams/subscriber.tsx | 2 +- shared/teams/team/index.tsx | 2 +- shared/teams/team/member/add-to-channels.tsx | 2 +- shared/teams/team/member/edit-channel.tsx | 2 +- shared/teams/team/member/index.new.tsx | 2 +- shared/teams/team/menu-container.tsx | 2 +- shared/teams/team/new-header.tsx | 4 ++-- shared/teams/team/rows/bot-row/bot.tsx | 2 +- .../teams/team/rows/channel-row/channel.tsx | 4 ++-- shared/teams/team/rows/emoji-row/add.tsx | 4 ++-- shared/teams/team/rows/emoji-row/item.tsx | 2 +- shared/teams/team/rows/empty-row.tsx | 2 +- shared/teams/team/rows/index.tsx | 2 +- shared/teams/team/rows/invite-row/invite.tsx | 4 ++-- shared/teams/team/rows/invite-row/request.tsx | 2 +- shared/teams/team/rows/member-row.tsx | 2 +- shared/teams/team/rows/subteam-row/add.tsx | 2 +- .../team/settings-tab/default-channels.tsx | 4 ++-- shared/teams/team/settings-tab/index.tsx | 2 +- .../team/settings-tab/retention/index.tsx | 4 ++-- shared/teams/team/tabs.tsx | 2 +- shared/teams/team/team-info.tsx | 2 +- 108 files changed, 154 insertions(+), 157 deletions(-) rename shared/{constants/teams/index.tsx => stores/teams.tsx} (99%) diff --git a/shared/chat/blocking/block-modal.tsx b/shared/chat/blocking/block-modal.tsx index e0c695937385..35e8a5270a81 100644 --- a/shared/chat/blocking/block-modal.tsx +++ b/shared/chat/blocking/block-modal.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import * as Chat from '@/constants/chat2' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import {useUsersState} from '@/constants/users' // Type for extra RouteProp passed to block modal sometimes when launching the diff --git a/shared/chat/conversation/bot/install.tsx b/shared/chat/conversation/bot/install.tsx index 9e96801ec38e..c114624f7970 100644 --- a/shared/chat/conversation/bot/install.tsx +++ b/shared/chat/conversation/bot/install.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import ChannelPicker from './channel-picker' import openURL from '@/util/open-url' diff --git a/shared/chat/conversation/info-panel/add-people.tsx b/shared/chat/conversation/info-panel/add-people.tsx index 9e7492a91f92..d205f0f75df6 100644 --- a/shared/chat/conversation/info-panel/add-people.tsx +++ b/shared/chat/conversation/info-panel/add-people.tsx @@ -1,5 +1,5 @@ import * as Chat from '@/constants/chat2' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/info-panel/add-to-channel.tsx b/shared/chat/conversation/info-panel/add-to-channel.tsx index 59bfd1d8e9ca..e23827118b04 100644 --- a/shared/chat/conversation/info-panel/add-to-channel.tsx +++ b/shared/chat/conversation/info-panel/add-to-channel.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/info-panel/bot.tsx b/shared/chat/conversation/info-panel/bot.tsx index 5786c496280f..38e993819338 100644 --- a/shared/chat/conversation/info-panel/bot.tsx +++ b/shared/chat/conversation/info-panel/bot.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/info-panel/common.tsx b/shared/chat/conversation/info-panel/common.tsx index 1de1bb893716..945a958f3741 100644 --- a/shared/chat/conversation/info-panel/common.tsx +++ b/shared/chat/conversation/info-panel/common.tsx @@ -1,5 +1,5 @@ import type * as Chat from '@/constants/chat2' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import * as Styles from '@/styles' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/info-panel/header.tsx b/shared/chat/conversation/info-panel/header.tsx index 121f86d02404..ff048b085cb6 100644 --- a/shared/chat/conversation/info-panel/header.tsx +++ b/shared/chat/conversation/info-panel/header.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import InfoPanelMenu from './menu' import * as InfoPanelCommon from './common' diff --git a/shared/chat/conversation/info-panel/index.tsx b/shared/chat/conversation/info-panel/index.tsx index f2bcd79a3346..9dfb7e2b18fa 100644 --- a/shared/chat/conversation/info-panel/index.tsx +++ b/shared/chat/conversation/info-panel/index.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import {AdhocHeader, TeamHeader} from './header' import SettingsList from './settings' diff --git a/shared/chat/conversation/info-panel/members.tsx b/shared/chat/conversation/info-panel/members.tsx index 5c1242ee02d7..24cec03697d2 100644 --- a/shared/chat/conversation/info-panel/members.tsx +++ b/shared/chat/conversation/info-panel/members.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import {useProfileState} from '@/constants/profile' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/info-panel/menu.tsx b/shared/chat/conversation/info-panel/menu.tsx index eac5285c62f0..c5e0d222f0cb 100644 --- a/shared/chat/conversation/info-panel/menu.tsx +++ b/shared/chat/conversation/info-panel/menu.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as T from '@/constants/types' import * as InfoPanelCommon from './common' diff --git a/shared/chat/conversation/info-panel/settings/index.tsx b/shared/chat/conversation/info-panel/settings/index.tsx index 6535768ef672..6e4297882778 100644 --- a/shared/chat/conversation/info-panel/settings/index.tsx +++ b/shared/chat/conversation/info-panel/settings/index.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as T from '@/constants/types' import * as React from 'react' import MinWriterRole from './min-writer-role' diff --git a/shared/chat/conversation/info-panel/settings/min-writer-role.tsx b/shared/chat/conversation/info-panel/settings/min-writer-role.tsx index a25934607682..7900cff41a0c 100644 --- a/shared/chat/conversation/info-panel/settings/min-writer-role.tsx +++ b/shared/chat/conversation/info-panel/settings/min-writer-role.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Style from '@/styles' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/input-area/suggestors/channels.tsx b/shared/chat/conversation/input-area/suggestors/channels.tsx index 0fcf0b2bb3ba..350526631aca 100644 --- a/shared/chat/conversation/input-area/suggestors/channels.tsx +++ b/shared/chat/conversation/input-area/suggestors/channels.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Common from './common' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/input-area/suggestors/users.tsx b/shared/chat/conversation/input-area/suggestors/users.tsx index 841ea76922fd..c130a7cb4ee5 100644 --- a/shared/chat/conversation/input-area/suggestors/users.tsx +++ b/shared/chat/conversation/input-area/suggestors/users.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as T from '@/constants/types' import * as Common from './common' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/cards/team-journey/container.tsx b/shared/chat/conversation/messages/cards/team-journey/container.tsx index 249383bf41a7..94f8fdeb3143 100644 --- a/shared/chat/conversation/messages/cards/team-journey/container.tsx +++ b/shared/chat/conversation/messages/cards/team-journey/container.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import {renderWelcomeMessage} from './util' import {useAllChannelMetas} from '@/teams/common/channel-hooks' diff --git a/shared/chat/conversation/messages/message-popup/hooks.tsx b/shared/chat/conversation/messages/message-popup/hooks.tsx index 6a8a35db164b..7bd9c7f5c81b 100644 --- a/shared/chat/conversation/messages/message-popup/hooks.tsx +++ b/shared/chat/conversation/messages/message-popup/hooks.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import type * as T from '@/constants/types' import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import {useConfigState} from '@/constants/config' import {useProfileState} from '@/constants/profile' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/chat/conversation/messages/retention-notice.tsx b/shared/chat/conversation/messages/retention-notice.tsx index add6faf305ea..20815e3b8457 100644 --- a/shared/chat/conversation/messages/retention-notice.tsx +++ b/shared/chat/conversation/messages/retention-notice.tsx @@ -1,6 +1,6 @@ import type * as T from '@/constants/types' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/conversation/messages/separator.tsx b/shared/chat/conversation/messages/separator.tsx index d2a640007553..2e1919bb6fb1 100644 --- a/shared/chat/conversation/messages/separator.tsx +++ b/shared/chat/conversation/messages/separator.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/system-added-to-team/container.tsx b/shared/chat/conversation/messages/system-added-to-team/container.tsx index 58c6e70e030f..4a9ce7b40884 100644 --- a/shared/chat/conversation/messages/system-added-to-team/container.tsx +++ b/shared/chat/conversation/messages/system-added-to-team/container.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' diff --git a/shared/chat/conversation/messages/system-change-retention/container.tsx b/shared/chat/conversation/messages/system-change-retention/container.tsx index c0ad42530fa3..3d5162914370 100644 --- a/shared/chat/conversation/messages/system-change-retention/container.tsx +++ b/shared/chat/conversation/messages/system-change-retention/container.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/system-create-team/container.tsx b/shared/chat/conversation/messages/system-create-team/container.tsx index f248de32f0f6..46f66b1d655b 100644 --- a/shared/chat/conversation/messages/system-create-team/container.tsx +++ b/shared/chat/conversation/messages/system-create-team/container.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/system-invite-accepted/container.tsx b/shared/chat/conversation/messages/system-invite-accepted/container.tsx index b3b76a752bba..0b0744749876 100644 --- a/shared/chat/conversation/messages/system-invite-accepted/container.tsx +++ b/shared/chat/conversation/messages/system-invite-accepted/container.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' diff --git a/shared/chat/conversation/messages/system-new-channel/container.tsx b/shared/chat/conversation/messages/system-new-channel/container.tsx index fb791f2b70b4..88579029fc92 100644 --- a/shared/chat/conversation/messages/system-new-channel/container.tsx +++ b/shared/chat/conversation/messages/system-new-channel/container.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import type * as T from '@/constants/types' import UserNotice from '../user-notice' diff --git a/shared/chat/conversation/messages/system-simple-to-complex/container.tsx b/shared/chat/conversation/messages/system-simple-to-complex/container.tsx index d0066afafefb..1a72fe42901f 100644 --- a/shared/chat/conversation/messages/system-simple-to-complex/container.tsx +++ b/shared/chat/conversation/messages/system-simple-to-complex/container.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/constants/chat2' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' diff --git a/shared/chat/conversation/pinned-message.tsx b/shared/chat/conversation/pinned-message.tsx index c1bee40e5890..07ce1d1a68d4 100644 --- a/shared/chat/conversation/pinned-message.tsx +++ b/shared/chat/conversation/pinned-message.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/chat/create-channel/hooks.tsx b/shared/chat/create-channel/hooks.tsx index ec52505df5e5..ae69f3d75443 100644 --- a/shared/chat/create-channel/hooks.tsx +++ b/shared/chat/create-channel/hooks.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import upperFirst from 'lodash/upperFirst' import type {Props} from '.' diff --git a/shared/chat/emoji-picker/container.tsx b/shared/chat/emoji-picker/container.tsx index abe1b741f551..0c6b391630a7 100644 --- a/shared/chat/emoji-picker/container.tsx +++ b/shared/chat/emoji-picker/container.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/chat/inbox-and-conversation-header.tsx b/shared/chat/inbox-and-conversation-header.tsx index 157b61f73d3b..8e6cddc344bc 100644 --- a/shared/chat/inbox-and-conversation-header.tsx +++ b/shared/chat/inbox-and-conversation-header.tsx @@ -9,7 +9,7 @@ import {useRoute} from '@react-navigation/native' import type {RootRouteProps} from '@/router-v2/route-params' import {useUsersState} from '@/constants/users' import {useCurrentUserState} from '@/constants/current-user' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' const Header = () => { const {params} = useRoute>() diff --git a/shared/chat/inbox-search/index.tsx b/shared/chat/inbox-search/index.tsx index f85ab2edb2d3..4c43a0afed33 100644 --- a/shared/chat/inbox-search/index.tsx +++ b/shared/chat/inbox-search/index.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import Rover from './background' diff --git a/shared/chat/inbox/row/big-team-header.tsx b/shared/chat/inbox/row/big-team-header.tsx index b4cf9085a9b0..2cd1b8d7d430 100644 --- a/shared/chat/inbox/row/big-team-header.tsx +++ b/shared/chat/inbox/row/big-team-header.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as RowSizes from './sizes' import type * as T from '@/constants/types' diff --git a/shared/chat/inbox/row/build-team.tsx b/shared/chat/inbox/row/build-team.tsx index 7f6415928fed..822260af2b68 100644 --- a/shared/chat/inbox/row/build-team.tsx +++ b/shared/chat/inbox/row/build-team.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' diff --git a/shared/chat/new-team-dialog-container.tsx b/shared/chat/new-team-dialog-container.tsx index 0421c30d6fef..020a22d35602 100644 --- a/shared/chat/new-team-dialog-container.tsx +++ b/shared/chat/new-team-dialog-container.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import {CreateNewTeam} from '../teams/new-team' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import upperFirst from 'lodash/upperFirst' const NewTeamDialog = () => { diff --git a/shared/common-adapters/markdown/maybe-mention/team.tsx b/shared/common-adapters/markdown/maybe-mention/team.tsx index 90bd396a1ee5..b15fb1a8b7aa 100644 --- a/shared/common-adapters/markdown/maybe-mention/team.tsx +++ b/shared/common-adapters/markdown/maybe-mention/team.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as T from '@/constants/types' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import Text, {type StylesTextCrossPlatform} from '@/common-adapters/text' import {Box2} from '@/common-adapters/box' diff --git a/shared/common-adapters/name-with-icon.tsx b/shared/common-adapters/name-with-icon.tsx index fdadf76d3ba6..92c47901ab03 100644 --- a/shared/common-adapters/name-with-icon.tsx +++ b/shared/common-adapters/name-with-icon.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Styles from '@/styles' import * as C from '@/constants' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import Avatar, {type AvatarSize} from './avatar' import {Box} from './box' import ClickableBox from './clickable-box' diff --git a/shared/common-adapters/team-with-popup.tsx b/shared/common-adapters/team-with-popup.tsx index 4059c9608948..f907e5e1ca80 100644 --- a/shared/common-adapters/team-with-popup.tsx +++ b/shared/common-adapters/team-with-popup.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import {Box2} from './box' import * as Styles from '@/styles' diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 973e6c649be3..923d09d8e17a 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -27,8 +27,8 @@ import {useProvisionState} from '../provision' import {storeRegistry} from '../store-registry' import {useSettingsContactsState} from '../settings-contacts' import type * as UseSignupStateType from '@/stores/signup' -import {useTeamsState} from '../teams' -import * as TeamsUtil from '../teams/util' +import type * as UseTeamsStateType from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as TrackerUtil from '../tracker2/util' import * as UnlockFoldersUtil from '../unlock-folders/util' import * as UsersUtil from '../users/util' @@ -345,6 +345,24 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { const {useNotifState} = require('@/stores/notifications') as typeof UseNotificationsStateType useNotifState.getState().dispatch.onEngineIncomingImpl(action) + + const {useTeamsState} = require('@/stores/teams') as typeof UseTeamsStateType + useTeamsState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.chat1ChatUiChatShowManageChannels: + case EngineGen.keybase1NotifyTeamTeamMetadataUpdate: + case EngineGen.chat1NotifyChatChatWelcomeMessageLoaded: + case EngineGen.keybase1NotifyTeamTeamTreeMembershipsPartial: + case EngineGen.keybase1NotifyTeamTeamTreeMembershipsDone: + case EngineGen.keybase1NotifyTeamTeamRoleMapChanged: + case EngineGen.keybase1NotifyTeamTeamChangedByID: + case EngineGen.keybase1NotifyTeamTeamDeleted: + case EngineGen.keybase1NotifyTeamTeamExit: + case EngineGen.keybase1GregorUIPushState: + { + const {useTeamsState} = require('@/stores/teams') as typeof UseTeamsStateType + useTeamsState.getState().dispatch.onEngineIncomingImpl(action) } break case EngineGen.keybase1NotifyFeaturedBotsFeaturedBotsUpdate: @@ -432,7 +450,6 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { } default: } - TeamsUtil.onEngineIncoming(action) TrackerUtil.onEngineIncoming(action) UnlockFoldersUtil.onEngineIncoming(action) UsersUtil.onEngineIncoming(action) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 254c59bac820..aff15b2bab1b 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -27,7 +27,7 @@ import type {State as SettingsEmailState, useSettingsEmailState} from '@/constan import type {State as SettingsPasswordState, usePWState} from '@/constants/settings-password' import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/constants/settings-phone' import type {State as SignupState, useSignupState} from '@/stores/signup' -import type {State as TeamsState, useTeamsState} from '@/constants/teams' +import type {State as TeamsState, useTeamsState} from '@/stores/teams' import type {State as Tracker2State, useTrackerState} from '@/constants/tracker2' import type {State as UnlockFoldersState, useUnlockFoldersState} from '@/constants/unlock-folders' import type {State as UsersState, useUsersState} from '@/constants/users' @@ -197,7 +197,7 @@ class StoreRegistry { return useSignupState } case 'teams': { - const {useTeamsState} = require('@/constants/teams') + const {useTeamsState} = require('@/stores/teams') return useTeamsState } case 'tracker2': { diff --git a/shared/constants/teams/util.tsx b/shared/constants/teams/util.tsx index 48167c472d34..893dd99a3b79 100644 --- a/shared/constants/teams/util.tsx +++ b/shared/constants/teams/util.tsx @@ -3,26 +3,6 @@ import * as T from '../types' import {storeRegistry} from '../store-registry' import invert from 'lodash/invert' -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.chat1ChatUiChatShowManageChannels: - case EngineGen.keybase1NotifyTeamTeamMetadataUpdate: - case EngineGen.chat1NotifyChatChatWelcomeMessageLoaded: - case EngineGen.keybase1NotifyTeamTeamTreeMembershipsPartial: - case EngineGen.keybase1NotifyTeamTeamTreeMembershipsDone: - case EngineGen.keybase1NotifyTeamTeamRoleMapChanged: - case EngineGen.keybase1NotifyTeamTeamChangedByID: - case EngineGen.keybase1NotifyTeamTeamDeleted: - case EngineGen.keybase1NotifyTeamTeamExit: - case EngineGen.keybase1NotifyBadgesBadgeState: - case EngineGen.keybase1GregorUIPushState: - { - storeRegistry.getState('teams').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} export const makeRetentionPolicy = ( r?: Partial diff --git a/shared/git/new-repo.tsx b/shared/git/new-repo.tsx index bfac4cb443db..2672731dc6a7 100644 --- a/shared/git/new-repo.tsx +++ b/shared/git/new-repo.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Git from '@/stores/git' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/git/row.tsx b/shared/git/row.tsx index d9f66f5c93d2..d079cd03852f 100644 --- a/shared/git/row.tsx +++ b/shared/git/row.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Git from '@/stores/git' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/git/select-channel.tsx b/shared/git/select-channel.tsx index ff8d850895dd..a4b40c3af1af 100644 --- a/shared/git/select-channel.tsx +++ b/shared/git/select-channel.tsx @@ -1,5 +1,5 @@ import * as Git from '@/stores/git' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import {useSafeNavigation} from '@/util/safe-navigation' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index ee7d657574e8..7f944107769e 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import openURL from '@/util/open-url' import type * as T from '@/constants/types' diff --git a/shared/profile/add-to-team.tsx b/shared/profile/add-to-team.tsx index a19e220412bc..26ca7d22b19e 100644 --- a/shared/profile/add-to-team.tsx +++ b/shared/profile/add-to-team.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import {FloatingRolePicker, sendNotificationFooter} from '@/teams/role-picker' import * as Kb from '@/common-adapters' diff --git a/shared/profile/edit-avatar/hooks.tsx b/shared/profile/edit-avatar/hooks.tsx index 68e576fc94fb..9113da8924dd 100644 --- a/shared/profile/edit-avatar/hooks.tsx +++ b/shared/profile/edit-avatar/hooks.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import {useProfileState} from '@/constants/profile' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import type {Props} from '.' diff --git a/shared/profile/showcase-team-offer.tsx b/shared/profile/showcase-team-offer.tsx index 0041a0725477..0dca1149d584 100644 --- a/shared/profile/showcase-team-offer.tsx +++ b/shared/profile/showcase-team-offer.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import {useTeamsSubscribe} from '@/teams/subscriber' import {useTrackerState} from '@/constants/tracker2' diff --git a/shared/profile/user/teams/index.tsx b/shared/profile/user/teams/index.tsx index 7cbc8c427ee2..485b63dada42 100644 --- a/shared/profile/user/teams/index.tsx +++ b/shared/profile/user/teams/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/settings/chat.tsx b/shared/settings/chat.tsx index 81040dd72cfd..761d1fb80df8 100644 --- a/shared/settings/chat.tsx +++ b/shared/settings/chat.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as T from '@/constants/types' import * as React from 'react' import Group from './group' diff --git a/shared/constants/teams/index.tsx b/shared/stores/teams.tsx similarity index 99% rename from shared/constants/teams/index.tsx rename to shared/stores/teams.tsx index 30ffecf7f3a7..d79211e67392 100644 --- a/shared/constants/teams/index.tsx +++ b/shared/stores/teams.tsx @@ -1,6 +1,6 @@ -import * as S from '../strings' -import {ignorePromise, wrapErrors} from '../utils' -import * as T from '../types' +import * as S from '@/constants/strings' +import {ignorePromise, wrapErrors} from '@/constants/utils' +import * as T from '@/constants/types' import * as EngineGen from '@/actions/engine-gen-gen' import { getVisibleScreen, @@ -9,21 +9,21 @@ import { navigateUp, navUpToScreen, navToProfile, -} from '../router2/util' +} from '@/constants/router2/util' import * as Z from '@/util/zustand' import invert from 'lodash/invert' import logger from '@/logger' import openSMS from '@/util/sms' import {RPCError, logError} from '@/util/errors' -import {isMobile, isPhone} from '../platform' +import {isMobile, isPhone} from '@/constants/platform' import {mapGetEnsureValue} from '@/util/map' -import {bodyToJSON} from '../rpc-utils' +import {bodyToJSON} from '@/constants/rpc-utils' import {fixCrop} from '@/util/crop' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' -import * as Util from './util' -import {getTab} from '../router2/util' +import {storeRegistry} from '@/constants/store-registry' +import {useConfigState} from '@/constants/config' +import {useCurrentUserState} from '@/constants/current-user' +import * as Util from '@/constants/teams/util' +import {getTab} from '@/constants/router2/util' export { baseRetentionPolicies, @@ -33,7 +33,7 @@ export { teamRoleByEnum, retentionPolicyToServiceRetentionPolicy, userIsRoleInTeamWithInfo, -} from './util' +} from '@/constants/teams/util' export const teamRoleTypes = ['reader', 'writer', 'admin', 'owner'] as const diff --git a/shared/team-building/index.tsx b/shared/team-building/index.tsx index bbc6518549f4..617f88b7b935 100644 --- a/shared/team-building/index.tsx +++ b/shared/team-building/index.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as TB from '@/constants/team-building' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/team-building/list-body.tsx b/shared/team-building/list-body.tsx index 9c5c98e1005c..3074c77517a9 100644 --- a/shared/team-building/list-body.tsx +++ b/shared/team-building/list-body.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as C from '@/constants' import * as TB from '@/constants/team-building' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as Shared from './shared' import PeopleResult from './search-result/people-result' diff --git a/shared/teams/add-members-wizard/add-contacts.native.tsx b/shared/teams/add-members-wizard/add-contacts.native.tsx index 6808ecaea271..e5e430e0bea1 100644 --- a/shared/teams/add-members-wizard/add-contacts.native.tsx +++ b/shared/teams/add-members-wizard/add-contacts.native.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {pluralize} from '@/util/string' diff --git a/shared/teams/add-members-wizard/add-email.tsx b/shared/teams/add-members-wizard/add-email.tsx index 26cf7893dc31..c19e84f68547 100644 --- a/shared/teams/add-members-wizard/add-email.tsx +++ b/shared/teams/add-members-wizard/add-email.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' import * as T from '@/constants/types' diff --git a/shared/teams/add-members-wizard/add-from-where.tsx b/shared/teams/add-members-wizard/add-from-where.tsx index 08c3f171a503..8bda843d03cf 100644 --- a/shared/teams/add-members-wizard/add-from-where.tsx +++ b/shared/teams/add-members-wizard/add-from-where.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as T from '@/constants/types' import {ModalTitle} from '../common' import {useSafeNavigation} from '@/util/safe-navigation' diff --git a/shared/teams/add-members-wizard/add-phone.tsx b/shared/teams/add-members-wizard/add-phone.tsx index 9a93ef6f9c4b..abeaa50273a8 100644 --- a/shared/teams/add-members-wizard/add-phone.tsx +++ b/shared/teams/add-members-wizard/add-phone.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {ModalTitle, usePhoneNumberList} from '../common' diff --git a/shared/teams/add-members-wizard/confirm.tsx b/shared/teams/add-members-wizard/confirm.tsx index 743ef7110357..bcfbbdbfec36 100644 --- a/shared/teams/add-members-wizard/confirm.tsx +++ b/shared/teams/add-members-wizard/confirm.tsx @@ -1,8 +1,8 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {assertionToDisplay} from '@/common-adapters/usernames' diff --git a/shared/teams/channel/create-channels.tsx b/shared/teams/channel/create-channels.tsx index 2a11aa71da5b..ab94118ac4c5 100644 --- a/shared/teams/channel/create-channels.tsx +++ b/shared/teams/channel/create-channels.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {CreateChannelsModal} from '../new-team/wizard/create-channels' diff --git a/shared/teams/channel/header.tsx b/shared/teams/channel/header.tsx index ea4654017c5b..84c2416a80df 100644 --- a/shared/teams/channel/header.tsx +++ b/shared/teams/channel/header.tsx @@ -2,8 +2,8 @@ import * as T from '@/constants/types' import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import {pluralize} from '@/util/string' import {Activity, useChannelParticipants} from '../common' diff --git a/shared/teams/channel/index.tsx b/shared/teams/channel/index.tsx index a23d5d1b52ae..df5dfa2ca7b0 100644 --- a/shared/teams/channel/index.tsx +++ b/shared/teams/channel/index.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import { diff --git a/shared/teams/channel/rows.tsx b/shared/teams/channel/rows.tsx index e07037b57201..45391a990ac2 100644 --- a/shared/teams/channel/rows.tsx +++ b/shared/teams/channel/rows.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import {useProfileState} from '@/constants/profile' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/teams/channel/tabs.tsx b/shared/teams/channel/tabs.tsx index 795cfb89ab9e..bc8d5526ea3a 100644 --- a/shared/teams/channel/tabs.tsx +++ b/shared/teams/channel/tabs.tsx @@ -1,7 +1,7 @@ import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import type {Tab as TabType} from '@/common-adapters/tabs' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' export type TabKey = 'members' | 'attachments' | 'bots' | 'settings' | 'loading' diff --git a/shared/teams/common/activity.tsx b/shared/teams/common/activity.tsx index 6ebbf1f4c098..f31a80050dff 100644 --- a/shared/teams/common/activity.tsx +++ b/shared/teams/common/activity.tsx @@ -1,6 +1,6 @@ import * as React from 'react' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/teams/common/channel-hooks.tsx b/shared/teams/common/channel-hooks.tsx index 934b7100704b..a3142cbbdd6b 100644 --- a/shared/teams/common/channel-hooks.tsx +++ b/shared/teams/common/channel-hooks.tsx @@ -2,7 +2,7 @@ import * as T from '@/constants/types' import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' // Filter bots out using team role info, isolate to only when related state changes export const useChannelParticipants = ( diff --git a/shared/teams/common/selection-popup.tsx b/shared/teams/common/selection-popup.tsx index 630b995890f3..b21537699cd5 100644 --- a/shared/teams/common/selection-popup.tsx +++ b/shared/teams/common/selection-popup.tsx @@ -1,8 +1,8 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import type * as T from '@/constants/types' import {FloatingRolePicker} from '../role-picker' diff --git a/shared/teams/confirm-modals/confirm-kick-out.tsx b/shared/teams/confirm-modals/confirm-kick-out.tsx index 5a8a0d0624e1..4c9d358d20a3 100644 --- a/shared/teams/confirm-modals/confirm-kick-out.tsx +++ b/shared/teams/confirm-modals/confirm-kick-out.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' diff --git a/shared/teams/confirm-modals/confirm-remove-from-channel.tsx b/shared/teams/confirm-modals/confirm-remove-from-channel.tsx index 4c346846133f..c05aa0d0d84b 100644 --- a/shared/teams/confirm-modals/confirm-remove-from-channel.tsx +++ b/shared/teams/confirm-modals/confirm-remove-from-channel.tsx @@ -1,8 +1,8 @@ import * as T from '@/constants/types' import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' diff --git a/shared/teams/confirm-modals/delete-channel.tsx b/shared/teams/confirm-modals/delete-channel.tsx index 9ad085f55ab3..c2e44e152a52 100644 --- a/shared/teams/confirm-modals/delete-channel.tsx +++ b/shared/teams/confirm-modals/delete-channel.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import {pluralize} from '@/util/string' import {useAllChannelMetas} from '@/teams/common/channel-hooks' diff --git a/shared/teams/confirm-modals/really-leave-team/index.tsx b/shared/teams/confirm-modals/really-leave-team/index.tsx index 684726a1e8a4..9d4340be3b68 100644 --- a/shared/teams/confirm-modals/really-leave-team/index.tsx +++ b/shared/teams/confirm-modals/really-leave-team/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as C from '@/constants' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeSubmit} from '@/util/safe-submit' import type * as T from '@/constants/types' diff --git a/shared/teams/container.tsx b/shared/teams/container.tsx index 0cdf2b620141..50483c818427 100644 --- a/shared/teams/container.tsx +++ b/shared/teams/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/teams/delete-team.tsx b/shared/teams/delete-team.tsx index e0dfd2750e0f..4c69295c90ac 100644 --- a/shared/teams/delete-team.tsx +++ b/shared/teams/delete-team.tsx @@ -6,8 +6,8 @@ import * as Kb from '@/common-adapters' import {pluralize} from '@/util/string' import {useTeamDetailsSubscribe} from './subscriber' import noop from 'lodash/noop' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' type OwnProps = {teamID: T.Teams.TeamID} diff --git a/shared/teams/edit-team-description.tsx b/shared/teams/edit-team-description.tsx index 7be608185f4c..71e0934031c3 100644 --- a/shared/teams/edit-team-description.tsx +++ b/shared/teams/edit-team-description.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {ModalTitle} from './common' diff --git a/shared/teams/external-team.tsx b/shared/teams/external-team.tsx index 642461031ab6..a550fefaa9fa 100644 --- a/shared/teams/external-team.tsx +++ b/shared/teams/external-team.tsx @@ -4,7 +4,7 @@ import {useProfileState} from '@/constants/profile' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import {useTeamLinkPopup} from './common' import {pluralize} from '@/util/string' import capitalize from 'lodash/capitalize' diff --git a/shared/teams/get-options.tsx b/shared/teams/get-options.tsx index e4aca9f077a2..f0cf90c88b0f 100644 --- a/shared/teams/get-options.tsx +++ b/shared/teams/get-options.tsx @@ -1,7 +1,7 @@ import * as Kb from '@/common-adapters' import {HeaderRightActions} from './main/header' import {useSafeNavigation} from '@/util/safe-navigation' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' const useHeaderActions = () => { const nav = useSafeNavigation() diff --git a/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx b/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx index c0afab8186de..cc3aa7bba913 100644 --- a/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx +++ b/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import useContacts, {type Contact} from '../common/use-contacts.native' import {InviteByContact, type ContactRowProps} from './index.native' diff --git a/shared/teams/invite-by-email.tsx b/shared/teams/invite-by-email.tsx index eb81f145ac77..f0201964e4d5 100644 --- a/shared/teams/invite-by-email.tsx +++ b/shared/teams/invite-by-email.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import type * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import {FloatingRolePicker} from './role-picker' diff --git a/shared/teams/join-team/container.tsx b/shared/teams/join-team/container.tsx index abbdbc6f3941..7a1e2e4df322 100644 --- a/shared/teams/join-team/container.tsx +++ b/shared/teams/join-team/container.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import upperFirst from 'lodash/upperFirst' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/teams/join-team/join-from-invite.tsx b/shared/teams/join-team/join-from-invite.tsx index fc4fa2ea5d33..f87440ceac61 100644 --- a/shared/teams/join-team/join-from-invite.tsx +++ b/shared/teams/join-team/join-from-invite.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import {Success} from './container' import {useSafeNavigation} from '@/util/safe-navigation' diff --git a/shared/teams/main/index.tsx b/shared/teams/main/index.tsx index 71ee7d1b4daa..7ef9fd136b08 100644 --- a/shared/teams/main/index.tsx +++ b/shared/teams/main/index.tsx @@ -4,7 +4,7 @@ import type * as T from '@/constants/types' import Banner from './banner' import TeamsFooter from './footer' import TeamRowNew from './team-row' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' type DeletedTeam = { teamName: string diff --git a/shared/teams/main/team-row.tsx b/shared/teams/main/team-row.tsx index a2550414088d..47bc1dc0041c 100644 --- a/shared/teams/main/team-row.tsx +++ b/shared/teams/main/team-row.tsx @@ -6,8 +6,8 @@ import TeamMenu from '../team/menu-container' import {pluralize} from '@/util/string' import {Activity} from '../common' import {useSafeNavigation} from '@/util/safe-navigation' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' type Props = { firstItem: boolean diff --git a/shared/teams/new-team/index.tsx b/shared/teams/new-team/index.tsx index 864bc75f6e6d..13d7883eaa0d 100644 --- a/shared/teams/new-team/index.tsx +++ b/shared/teams/new-team/index.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import openUrl from '@/util/open-url' diff --git a/shared/teams/new-team/wizard/add-subteam-members.tsx b/shared/teams/new-team/wizard/add-subteam-members.tsx index dc439ccc5bb5..5110a8f11a46 100644 --- a/shared/teams/new-team/wizard/add-subteam-members.tsx +++ b/shared/teams/new-team/wizard/add-subteam-members.tsx @@ -1,4 +1,4 @@ -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/teams/new-team/wizard/create-channels.tsx b/shared/teams/new-team/wizard/create-channels.tsx index b2c22534ece2..dda466eb062e 100644 --- a/shared/teams/new-team/wizard/create-channels.tsx +++ b/shared/teams/new-team/wizard/create-channels.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {pluralize} from '@/util/string' diff --git a/shared/teams/new-team/wizard/create-subteams.tsx b/shared/teams/new-team/wizard/create-subteams.tsx index e45764eff76c..89a3097a83d6 100644 --- a/shared/teams/new-team/wizard/create-subteams.tsx +++ b/shared/teams/new-team/wizard/create-subteams.tsx @@ -4,7 +4,7 @@ import * as T from '@/constants/types' import {pluralize} from '@/util/string' import {ModalTitle} from '@/teams/common' import {useSafeNavigation} from '@/util/safe-navigation' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' const cleanSubteamName = (name: string) => name.replace(/[^0-9a-zA-Z_]/, '') diff --git a/shared/teams/new-team/wizard/make-big-team.tsx b/shared/teams/new-team/wizard/make-big-team.tsx index 016a8edc4b71..071a0e4420f8 100644 --- a/shared/teams/new-team/wizard/make-big-team.tsx +++ b/shared/teams/new-team/wizard/make-big-team.tsx @@ -2,7 +2,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {ModalTitle} from '@/teams/common' import {useSafeNavigation} from '@/util/safe-navigation' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' const MakeBigTeam = () => { const nav = useSafeNavigation() diff --git a/shared/teams/new-team/wizard/new-team-info.tsx b/shared/teams/new-team/wizard/new-team-info.tsx index cb9661e3b0ee..0bfb4183f529 100644 --- a/shared/teams/new-team/wizard/new-team-info.tsx +++ b/shared/teams/new-team/wizard/new-team-info.tsx @@ -3,8 +3,8 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import {ModalTitle} from '@/teams/common' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import {pluralize} from '@/util/string' import {InlineDropdown} from '@/common-adapters/dropdown' import {FloatingRolePicker} from '../../role-picker' diff --git a/shared/teams/new-team/wizard/team-purpose.tsx b/shared/teams/new-team/wizard/team-purpose.tsx index 2d75aad151e8..4fa97617bb83 100644 --- a/shared/teams/new-team/wizard/team-purpose.tsx +++ b/shared/teams/new-team/wizard/team-purpose.tsx @@ -2,7 +2,7 @@ import * as Kb from '@/common-adapters' import {ModalTitle} from '@/teams/common' import * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' const TeamPurpose = () => { const nav = useSafeNavigation() diff --git a/shared/teams/rename-team.tsx b/shared/teams/rename-team.tsx index 3b080205a545..bdcb775f658d 100644 --- a/shared/teams/rename-team.tsx +++ b/shared/teams/rename-team.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' type OwnProps = {teamname: string} diff --git a/shared/teams/subscriber.tsx b/shared/teams/subscriber.tsx index e4dd3276faef..8ea982cb3645 100644 --- a/shared/teams/subscriber.tsx +++ b/shared/teams/subscriber.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import type * as T from '@/constants/types' // NOTE: If you are in a floating box or otherwise outside the navigation diff --git a/shared/teams/team/index.tsx b/shared/teams/team/index.tsx index d4b330a2af9d..9c2ad37aa0a9 100644 --- a/shared/teams/team/index.tsx +++ b/shared/teams/team/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' diff --git a/shared/teams/team/member/add-to-channels.tsx b/shared/teams/team/member/add-to-channels.tsx index 79922967b9e1..bb7c7006f92d 100644 --- a/shared/teams/team/member/add-to-channels.tsx +++ b/shared/teams/team/member/add-to-channels.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import * as Common from '@/teams/common' diff --git a/shared/teams/team/member/edit-channel.tsx b/shared/teams/team/member/edit-channel.tsx index 95679a91a100..1f1a49e5f552 100644 --- a/shared/teams/team/member/edit-channel.tsx +++ b/shared/teams/team/member/edit-channel.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as React from 'react' import type * as T from '@/constants/types' import {ModalTitle} from '@/teams/common' diff --git a/shared/teams/team/member/index.new.tsx b/shared/teams/team/member/index.new.tsx index 3ac20ce63dfa..645f968c94b3 100644 --- a/shared/teams/team/member/index.new.tsx +++ b/shared/teams/team/member/index.new.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import {useCurrentUserState} from '@/constants/current-user' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import {useProfileState} from '@/constants/profile' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/teams/team/menu-container.tsx b/shared/teams/team/menu-container.tsx index 4e63c738378f..fdc3047a780a 100644 --- a/shared/teams/team/menu-container.tsx +++ b/shared/teams/team/menu-container.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import type * as React from 'react' import * as FS from '@/constants/fs/util' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import capitalize from 'lodash/capitalize' import * as T from '@/constants/types' import {pluralize} from '@/util/string' diff --git a/shared/teams/team/new-header.tsx b/shared/teams/team/new-header.tsx index bbdf3a4bb0aa..4bebcadaff72 100644 --- a/shared/teams/team/new-header.tsx +++ b/shared/teams/team/new-header.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import TeamMenu from './menu-container' import {pluralize} from '@/util/string' @@ -9,7 +9,7 @@ import {Activity, useActivityLevels, useTeamLinkPopup} from '../common' import type * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' import {useCurrentUserState} from '@/constants/current-user' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' const AddPeopleButton = ({teamID}: {teamID: T.Teams.TeamID}) => { const startAddMembersWizard = useTeamsState(s => s.dispatch.startAddMembersWizard) diff --git a/shared/teams/team/rows/bot-row/bot.tsx b/shared/teams/team/rows/bot-row/bot.tsx index 59e55fd216b8..81b3c88af31f 100644 --- a/shared/teams/team/rows/bot-row/bot.tsx +++ b/shared/teams/team/rows/bot-row/bot.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import BotMenu from './bot-menu' diff --git a/shared/teams/team/rows/channel-row/channel.tsx b/shared/teams/team/rows/channel-row/channel.tsx index 846b88deb7e1..3b8b31017ac0 100644 --- a/shared/teams/team/rows/channel-row/channel.tsx +++ b/shared/teams/team/rows/channel-row/channel.tsx @@ -4,8 +4,8 @@ import type * as T from '@/constants/types' import {Activity, useChannelParticipants} from '@/teams/common' import {pluralize} from '@/util/string' import {useSafeNavigation} from '@/util/safe-navigation' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' type ChannelRowProps = { conversationIDKey: T.Chat.ConversationIDKey diff --git a/shared/teams/team/rows/emoji-row/add.tsx b/shared/teams/team/rows/emoji-row/add.tsx index b4381e54f327..b48b58e984e4 100644 --- a/shared/teams/team/rows/emoji-row/add.tsx +++ b/shared/teams/team/rows/emoji-row/add.tsx @@ -1,8 +1,8 @@ import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' type OwnProps = { teamID: T.Teams.TeamID diff --git a/shared/teams/team/rows/emoji-row/item.tsx b/shared/teams/team/rows/emoji-row/item.tsx index dfc547d4cafc..e1e97c23623b 100644 --- a/shared/teams/team/rows/emoji-row/item.tsx +++ b/shared/teams/team/rows/emoji-row/item.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' import * as dateFns from 'date-fns' diff --git a/shared/teams/team/rows/empty-row.tsx b/shared/teams/team/rows/empty-row.tsx index b30917726587..7586fec837ee 100644 --- a/shared/teams/team/rows/empty-row.tsx +++ b/shared/teams/team/rows/empty-row.tsx @@ -1,7 +1,7 @@ import type * as T from '@/constants/types' import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/teams/team/rows/index.tsx b/shared/teams/team/rows/index.tsx index cef7d9413a38..6c19e4b7220b 100644 --- a/shared/teams/team/rows/index.tsx +++ b/shared/teams/team/rows/index.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as T from '@/constants/types' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' import EmptyRow from './empty-row' diff --git a/shared/teams/team/rows/invite-row/invite.tsx b/shared/teams/team/rows/invite-row/invite.tsx index 78b2c553a7c0..ff3f9958b352 100644 --- a/shared/teams/team/rows/invite-row/invite.tsx +++ b/shared/teams/team/rows/invite-row/invite.tsx @@ -2,8 +2,8 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {formatPhoneNumber} from '@/util/phone-numbers' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' export type Props = { isKeybaseUser?: boolean diff --git a/shared/teams/team/rows/invite-row/request.tsx b/shared/teams/team/rows/invite-row/request.tsx index a4342c9d8e08..434db07574e0 100644 --- a/shared/teams/team/rows/invite-row/request.tsx +++ b/shared/teams/team/rows/invite-row/request.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import {useProfileState} from '@/constants/profile' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' diff --git a/shared/teams/team/rows/member-row.tsx b/shared/teams/team/rows/member-row.tsx index 5c74bd5d754e..3598f33d6125 100644 --- a/shared/teams/team/rows/member-row.tsx +++ b/shared/teams/team/rows/member-row.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as Kb from '@/common-adapters' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as React from 'react' import type * as T from '@/constants/types' import MenuHeader from './menu-header.new' diff --git a/shared/teams/team/rows/subteam-row/add.tsx b/shared/teams/team/rows/subteam-row/add.tsx index 6e80257e3113..58102c169fa9 100644 --- a/shared/teams/team/rows/subteam-row/add.tsx +++ b/shared/teams/team/rows/subteam-row/add.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useTeamsState} from '@/constants/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' diff --git a/shared/teams/team/settings-tab/default-channels.tsx b/shared/teams/team/settings-tab/default-channels.tsx index 4bd9dbf45d56..76524135f8bc 100644 --- a/shared/teams/team/settings-tab/default-channels.tsx +++ b/shared/teams/team/settings-tab/default-channels.tsx @@ -4,8 +4,8 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import type {RPCError} from '@/util/errors' import {ChannelsWidget} from '@/teams/common' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' type Props = { teamID: T.Teams.TeamID diff --git a/shared/teams/team/settings-tab/index.tsx b/shared/teams/team/settings-tab/index.tsx index 264e7690abad..e3afd3bc9823 100644 --- a/shared/teams/team/settings-tab/index.tsx +++ b/shared/teams/team/settings-tab/index.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {FloatingRolePicker} from '@/teams/role-picker' diff --git a/shared/teams/team/settings-tab/retention/index.tsx b/shared/teams/team/settings-tab/retention/index.tsx index 3fc393dd4026..b16ef96320f0 100644 --- a/shared/teams/team/settings-tab/retention/index.tsx +++ b/shared/teams/team/settings-tab/retention/index.tsx @@ -1,8 +1,8 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import * as React from 'react' -import * as Teams from '@/constants/teams' -import {useTeamsState} from '@/constants/teams' +import * as Teams from '@/stores/teams' +import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import type {StylesCrossPlatform} from '@/styles' diff --git a/shared/teams/team/tabs.tsx b/shared/teams/team/tabs.tsx index a27c8027232c..8700d814ebb7 100644 --- a/shared/teams/team/tabs.tsx +++ b/shared/teams/team/tabs.tsx @@ -2,7 +2,7 @@ import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as C from '@/constants' import * as Chat from '@/constants/chat2' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import type {Tab as TabType} from '@/common-adapters/tabs' type TeamTabsProps = { diff --git a/shared/teams/team/team-info.tsx b/shared/teams/team/team-info.tsx index 5c1a170c27e5..4eb6002f45b9 100644 --- a/shared/teams/team/team-info.tsx +++ b/shared/teams/team/team-info.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import * as Teams from '@/constants/teams' +import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {ModalTitle} from '../common' From 69c2196f975867382a52928c489d35dc6a609d2e Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:15:09 -0500 Subject: [PATCH 20/37] WIP --- shared/constants/teams/util.tsx | 3 --- 1 file changed, 3 deletions(-) diff --git a/shared/constants/teams/util.tsx b/shared/constants/teams/util.tsx index 893dd99a3b79..ce11cc0f9c40 100644 --- a/shared/constants/teams/util.tsx +++ b/shared/constants/teams/util.tsx @@ -1,9 +1,6 @@ -import * as EngineGen from '@/actions/engine-gen-gen' import * as T from '../types' -import {storeRegistry} from '../store-registry' import invert from 'lodash/invert' - export const makeRetentionPolicy = ( r?: Partial ): T.Retention.RetentionPolicy => ({ From 7c5cf8df84addd13cc6006c41ebbadfe2bad1659 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:20:53 -0500 Subject: [PATCH 21/37] WIP --- shared/chat/blocking/block-modal.tsx | 2 +- shared/chat/conversation/bottom-banner.tsx | 2 +- .../conversation/header-area/index.native.tsx | 2 +- shared/chat/conversation/info-panel/bot.tsx | 2 +- .../chat/conversation/info-panel/members.tsx | 2 +- shared/chat/conversation/info-panel/menu.tsx | 2 +- .../input-area/suggestors/users.tsx | 2 +- .../messages/reaction-tooltip.tsx | 2 +- .../chat/conversation/messages/separator.tsx | 2 +- shared/chat/inbox-and-conversation-header.tsx | 2 +- shared/common-adapters/avatar/hooks.tsx | 2 +- shared/common-adapters/mention-container.tsx | 2 +- shared/common-adapters/name-with-icon.tsx | 2 +- shared/common-adapters/profile-card.tsx | 4 +- .../common-adapters/proof-broken-banner.tsx | 2 +- shared/common-adapters/usernames.tsx | 4 +- shared/constants/init/shared.tsx | 72 ++++++++++++++++--- shared/constants/store-registry.tsx | 12 ++-- shared/constants/tracker2/util.tsx | 36 ---------- shared/constants/unlock-folders/util.tsx | 30 -------- shared/constants/users/util.tsx | 14 ---- shared/fs/banner/reset-banner.tsx | 2 +- shared/fs/footer/proof-broken.tsx | 2 +- shared/git/row.tsx | 2 +- shared/menubar/remote-container.desktop.tsx | 2 +- shared/menubar/remote-proxy.desktop.tsx | 2 +- shared/people/todo.tsx | 2 +- shared/profile/edit-profile.tsx | 2 +- shared/profile/generic/proofs-list.tsx | 2 +- shared/profile/showcase-team-offer.tsx | 2 +- shared/profile/user/actions/index.tsx | 2 +- shared/profile/user/friend.tsx | 2 +- shared/profile/user/hooks.tsx | 2 +- shared/profile/user/teams/index.tsx | 2 +- shared/router-v2/account-switcher/index.tsx | 4 +- shared/router-v2/tab-bar.desktop.tsx | 2 +- shared/settings/contacts-joined.tsx | 2 +- .../index.tsx => stores/tracker2.tsx} | 12 ++-- .../index.tsx => stores/unlock-folders.tsx} | 4 +- .../users/index.tsx => stores/users.tsx} | 8 +-- .../search-result/people-result.tsx | 2 +- shared/teams/channel/index.tsx | 2 +- shared/teams/channel/rows.tsx | 2 +- shared/teams/team/rows/bot-row/bot.tsx | 2 +- shared/teams/team/rows/member-row.tsx | 4 +- shared/tracker2/assertion.tsx | 4 +- shared/tracker2/bio.tsx | 2 +- shared/tracker2/remote-container.desktop.tsx | 4 +- shared/tracker2/remote-proxy.desktop.tsx | 4 +- shared/unlock-folders/index.desktop.tsx | 2 +- .../remote-container.desktop.tsx | 2 +- 51 files changed, 129 insertions(+), 159 deletions(-) rename shared/{constants/tracker2/index.tsx => stores/tracker2.tsx} (98%) rename shared/{constants/unlock-folders/index.tsx => stores/unlock-folders.tsx} (95%) rename shared/{constants/users/index.tsx => stores/users.tsx} (96%) diff --git a/shared/chat/blocking/block-modal.tsx b/shared/chat/blocking/block-modal.tsx index 35e8a5270a81..284449657558 100644 --- a/shared/chat/blocking/block-modal.tsx +++ b/shared/chat/blocking/block-modal.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as Chat from '@/constants/chat2' import {useTeamsState} from '@/stores/teams' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' // Type for extra RouteProp passed to block modal sometimes when launching the // modal from specific places from the app. diff --git a/shared/chat/conversation/bottom-banner.tsx b/shared/chat/conversation/bottom-banner.tsx index 68cff5406824..be5b4fc016b2 100644 --- a/shared/chat/conversation/bottom-banner.tsx +++ b/shared/chat/conversation/bottom-banner.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import _openSMS from '@/util/sms' import {assertionToDisplay} from '@/common-adapters/usernames' import type {Props as TextProps} from '@/common-adapters/text' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' const installMessage = `I sent you encrypted messages on Keybase. You can install it here: https://keybase.io/phone-app` diff --git a/shared/chat/conversation/header-area/index.native.tsx b/shared/chat/conversation/header-area/index.native.tsx index c2b82732a4aa..76ac856624e3 100644 --- a/shared/chat/conversation/header-area/index.native.tsx +++ b/shared/chat/conversation/header-area/index.native.tsx @@ -9,7 +9,7 @@ import {Keyboard} from 'react-native' // import {DebugChatDumpContext} from '@/constants/chat2/debug' import {assertionToDisplay} from '@/common-adapters/usernames' import {useSafeAreaFrame} from 'react-native-safe-area-context' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' export const HeaderAreaRight = () => { diff --git a/shared/chat/conversation/info-panel/bot.tsx b/shared/chat/conversation/info-panel/bot.tsx index 38e993819338..d6e8b36d8ea7 100644 --- a/shared/chat/conversation/info-panel/bot.tsx +++ b/shared/chat/conversation/info-panel/bot.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' import {getFeaturedSorted, useBotsState} from '@/stores/bots' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' type AddToChannelProps = { conversationIDKey: T.Chat.ConversationIDKey diff --git a/shared/chat/conversation/info-panel/members.tsx b/shared/chat/conversation/info-panel/members.tsx index 24cec03697d2..7c20cb2ee717 100644 --- a/shared/chat/conversation/info-panel/members.tsx +++ b/shared/chat/conversation/info-panel/members.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import Participant from './participant' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' type Props = { commonSections: ReadonlyArray
diff --git a/shared/chat/conversation/info-panel/menu.tsx b/shared/chat/conversation/info-panel/menu.tsx index c5e0d222f0cb..2a7c95ce51c5 100644 --- a/shared/chat/conversation/info-panel/menu.tsx +++ b/shared/chat/conversation/info-panel/menu.tsx @@ -7,7 +7,7 @@ import * as T from '@/constants/types' import * as InfoPanelCommon from './common' import {Avatars, TeamAvatar} from '@/chat/avatars' import {TeamsSubscriberMountOnly} from '@/teams/subscriber' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' export type OwnProps = { diff --git a/shared/chat/conversation/input-area/suggestors/users.tsx b/shared/chat/conversation/input-area/suggestors/users.tsx index c130a7cb4ee5..dea63fd5f0ad 100644 --- a/shared/chat/conversation/input-area/suggestors/users.tsx +++ b/shared/chat/conversation/input-area/suggestors/users.tsx @@ -5,7 +5,7 @@ import * as T from '@/constants/types' import * as Common from './common' import * as Kb from '@/common-adapters' import * as React from 'react' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' export const transformer = ( input: { diff --git a/shared/chat/conversation/messages/reaction-tooltip.tsx b/shared/chat/conversation/messages/reaction-tooltip.tsx index 985f3edacb4f..428ec1fdd7d9 100644 --- a/shared/chat/conversation/messages/reaction-tooltip.tsx +++ b/shared/chat/conversation/messages/reaction-tooltip.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import ReactButton from './react-button' import type * as T from '@/constants/types' import {MessageContext} from './ids-context' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' const positionFallbacks = ['bottom center', 'left center'] as const diff --git a/shared/chat/conversation/messages/separator.tsx b/shared/chat/conversation/messages/separator.tsx index 2e1919bb6fb1..182a5ffb120c 100644 --- a/shared/chat/conversation/messages/separator.tsx +++ b/shared/chat/conversation/messages/separator.tsx @@ -7,7 +7,7 @@ import * as T from '@/constants/types' import {formatTimeForConversationList, formatTimeForChat} from '@/util/timestamp' import {OrangeLineContext} from '../orange-line-context' import logger from '@/logger' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useCurrentUserState} from '@/constants/current-user' // import {useChatDebugDump} from '@/constants/chat2/debug' diff --git a/shared/chat/inbox-and-conversation-header.tsx b/shared/chat/inbox-and-conversation-header.tsx index 8e6cddc344bc..b270d2a8afbf 100644 --- a/shared/chat/inbox-and-conversation-header.tsx +++ b/shared/chat/inbox-and-conversation-header.tsx @@ -7,7 +7,7 @@ import SearchRow from './inbox/search-row' import NewChatButton from './inbox/new-chat-button' import {useRoute} from '@react-navigation/native' import type {RootRouteProps} from '@/router-v2/route-params' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' import * as Teams from '@/stores/teams' diff --git a/shared/common-adapters/avatar/hooks.tsx b/shared/common-adapters/avatar/hooks.tsx index f7fd24ebbb6e..81c492363e3e 100644 --- a/shared/common-adapters/avatar/hooks.tsx +++ b/shared/common-adapters/avatar/hooks.tsx @@ -7,7 +7,7 @@ import * as AvatarZus from './store' import './avatar.css' import type {Props} from '.' import {useColorScheme} from 'react-native' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' import {navToProfile} from '@/constants/router2' diff --git a/shared/common-adapters/mention-container.tsx b/shared/common-adapters/mention-container.tsx index 107b2535da44..df61a99dffcf 100644 --- a/shared/common-adapters/mention-container.tsx +++ b/shared/common-adapters/mention-container.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Chat from '@/constants/chat2' import Mention, {type OwnProps} from './mention' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/common-adapters/name-with-icon.tsx b/shared/common-adapters/name-with-icon.tsx index 92c47901ab03..2c44ab45880f 100644 --- a/shared/common-adapters/name-with-icon.tsx +++ b/shared/common-adapters/name-with-icon.tsx @@ -13,7 +13,7 @@ import Text, { type TextTypeBold, } from './text' import ConnectedUsernames from './usernames' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' type Size = 'smaller' | 'small' | 'default' | 'big' | 'huge' diff --git a/shared/common-adapters/profile-card.tsx b/shared/common-adapters/profile-card.tsx index bb37a3692f60..4b5c1fa9b9f4 100644 --- a/shared/common-adapters/profile-card.tsx +++ b/shared/common-adapters/profile-card.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Styles from '@/styles' import * as Platforms from '@/util/platforms' -import * as Tracker from '@/constants/tracker2' +import * as Tracker from '@/stores/tracker2' import type * as T from '@/constants/types' import capitalize from 'lodash/capitalize' import Box, {Box2, Box2Measure} from './box' @@ -21,7 +21,7 @@ import WithTooltip from './with-tooltip' import DelayedMounting from './delayed-mounting' import {type default as FollowButtonType} from '../profile/user/actions/follow-button' import type ChatButtonType from '../chat/chat-button' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import type {MeasureRef} from './measure-ref' const positionFallbacks = ['top center', 'bottom center'] as const diff --git a/shared/common-adapters/proof-broken-banner.tsx b/shared/common-adapters/proof-broken-banner.tsx index 861ead336641..13bf311e732a 100644 --- a/shared/common-adapters/proof-broken-banner.tsx +++ b/shared/common-adapters/proof-broken-banner.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as React from 'react' import {Banner, BannerParagraph} from './banner' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' const Kb = {Banner} diff --git a/shared/common-adapters/usernames.tsx b/shared/common-adapters/usernames.tsx index acde8bed645a..ac58d81649a5 100644 --- a/shared/common-adapters/usernames.tsx +++ b/shared/common-adapters/usernames.tsx @@ -12,8 +12,8 @@ import Text, { import {backgroundModeIsNegative} from './text.shared' import isArray from 'lodash/isArray' import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' -import {useTrackerState} from '@/constants/tracker2' -import {useUsersState} from '@/constants/users' +import {useTrackerState} from '@/stores/tracker2' +import {useUsersState} from '@/stores/users' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 923d09d8e17a..df360f7e02b3 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -29,9 +29,9 @@ import {useSettingsContactsState} from '../settings-contacts' import type * as UseSignupStateType from '@/stores/signup' import type * as UseTeamsStateType from '@/stores/teams' import {useTeamsState} from '@/stores/teams' -import * as TrackerUtil from '../tracker2/util' -import * as UnlockFoldersUtil from '../unlock-folders/util' -import * as UsersUtil from '../users/util' +import type * as UseTracker2StateType from '@/stores/tracker2' +import type * as UseUnlockFoldersStateType from '@/stores/unlock-folders' +import type * as UseUsersStateType from '@/stores/users' import {useWhatsNewState} from '../whats-new' let _emitStartupOnLoadDaemonConnectedOnce = false @@ -110,11 +110,32 @@ export const onEngineConnected = () => { } catch (error) { logger.warn('error in registering secret ui: ', error) } - } - ignorePromise(f()) - } - TrackerUtil.onEngineConnected() - UnlockFoldersUtil.onEngineConnected() + } + ignorePromise(f()) + } + { // Tracker2 + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterIdentify3UIRpcPromise() + logger.info('Registered identify ui') + } catch (error) { + logger.warn('error in registering identify ui: ', error) + } + } + ignorePromise(f()) + } + { // UnlockFolders + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterRekeyUIRpcPromise() + logger.info('Registered rekey ui') + } catch (error) { + logger.warn('error in registering rekey ui: ') + logger.debug('error in registering rekey ui: ', error) + } + } + ignorePromise(f()) + } } export const onEngineDisconnected = () => { @@ -433,6 +454,8 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { case EngineGen.keybase1NotifyTrackingTrackingChanged: { const {isTracking, username} = action.payload.params useFollowerState.getState().dispatch.updateFollowing(username, isTracking) + const {useTracker2State} = require('@/stores/tracker2') as typeof UseTracker2StateType + useTracker2State.getState().dispatch.onEngineIncomingImpl(action) break } case EngineGen.keybase1NotifyTrackingTrackingInfo: { @@ -448,9 +471,36 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { dispatch.replace(followers, following) break } + case EngineGen.keybase1Identify3UiIdentify3Result: + case EngineGen.keybase1Identify3UiIdentify3ShowTracker: + case EngineGen.keybase1NotifyUsersUserChanged: + case EngineGen.keybase1NotifyTrackingNotifyUserBlocked: + case EngineGen.keybase1Identify3UiIdentify3UpdateRow: + case EngineGen.keybase1Identify3UiIdentify3UserReset: + case EngineGen.keybase1Identify3UiIdentify3UpdateUserCard: + case EngineGen.keybase1Identify3UiIdentify3Summary: + { + const {useTracker2State} = require('@/stores/tracker2') as typeof UseTracker2StateType + useTracker2State.getState().dispatch.onEngineIncomingImpl(action) + } + { + const {useUsersState} = require('@/stores/users') as typeof UseUsersStateType + useUsersState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.keybase1NotifyUsersIdentifyUpdate: + { + const {useUsersState} = require('@/stores/users') as typeof UseUsersStateType + useUsersState.getState().dispatch.onEngineIncomingImpl(action) + } + break + case EngineGen.keybase1RekeyUIRefresh: + case EngineGen.keybase1RekeyUIDelegateRekeyUI: + { + const {useUnlockFoldersState} = require('@/stores/unlock-folders') as typeof UseUnlockFoldersStateType + useUnlockFoldersState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } - TrackerUtil.onEngineIncoming(action) - UnlockFoldersUtil.onEngineIncoming(action) - UsersUtil.onEngineIncoming(action) } diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index aff15b2bab1b..4188828f0e4f 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -28,9 +28,9 @@ import type {State as SettingsPasswordState, usePWState} from '@/constants/setti import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/constants/settings-phone' import type {State as SignupState, useSignupState} from '@/stores/signup' import type {State as TeamsState, useTeamsState} from '@/stores/teams' -import type {State as Tracker2State, useTrackerState} from '@/constants/tracker2' -import type {State as UnlockFoldersState, useUnlockFoldersState} from '@/constants/unlock-folders' -import type {State as UsersState, useUsersState} from '@/constants/users' +import type {State as Tracker2State, useTrackerState} from '@/stores/tracker2' +import type {State as UnlockFoldersState, useUnlockFoldersState} from '@/stores/unlock-folders' +import type {State as UsersState, useUsersState} from '@/stores/users' type StoreName = | 'autoreset' @@ -201,15 +201,15 @@ class StoreRegistry { return useTeamsState } case 'tracker2': { - const {useTrackerState} = require('@/constants/tracker2') + const {useTrackerState} = require('@/stores/tracker2') return useTrackerState } case 'unlock-folders': { - const {useUnlockFoldersState} = require('@/constants/unlock-folders') + const {useUnlockFoldersState} = require('@/stores/unlock-folders') return useUnlockFoldersState } case 'users': { - const {useUsersState} = require('@/constants/users') + const {useUsersState} = require('@/stores/users') return useUsersState } default: diff --git a/shared/constants/tracker2/util.tsx b/shared/constants/tracker2/util.tsx index e6adb67ec4c6..e69de29bb2d1 100644 --- a/shared/constants/tracker2/util.tsx +++ b/shared/constants/tracker2/util.tsx @@ -1,36 +0,0 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' -import logger from '@/logger' - -export const onEngineConnected = () => { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterIdentify3UIRpcPromise() - logger.info('Registered identify ui') - } catch (error) { - logger.warn('error in registering identify ui: ', error) - } - } - ignorePromise(f()) -} - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyTrackingTrackingChanged: - case EngineGen.keybase1Identify3UiIdentify3Result: - case EngineGen.keybase1Identify3UiIdentify3ShowTracker: - case EngineGen.keybase1NotifyUsersUserChanged: - case EngineGen.keybase1NotifyTrackingNotifyUserBlocked: - case EngineGen.keybase1Identify3UiIdentify3UpdateRow: - case EngineGen.keybase1Identify3UiIdentify3UserReset: - case EngineGen.keybase1Identify3UiIdentify3UpdateUserCard: - case EngineGen.keybase1Identify3UiIdentify3Summary: - { - storeRegistry.getState('tracker2').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/unlock-folders/util.tsx b/shared/constants/unlock-folders/util.tsx index 89d12305fd44..e69de29bb2d1 100644 --- a/shared/constants/unlock-folders/util.tsx +++ b/shared/constants/unlock-folders/util.tsx @@ -1,30 +0,0 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' -import logger from '@/logger' - -export const onEngineConnected = () => { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterRekeyUIRpcPromise() - logger.info('Registered rekey ui') - } catch (error) { - logger.warn('error in registering rekey ui: ') - logger.debug('error in registering rekey ui: ', error) - } - } - ignorePromise(f()) -} - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1RekeyUIRefresh: - case EngineGen.keybase1RekeyUIDelegateRekeyUI: - { - storeRegistry.getState('unlock-folders').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/users/util.tsx b/shared/constants/users/util.tsx index cd70c647ccb5..e69de29bb2d1 100644 --- a/shared/constants/users/util.tsx +++ b/shared/constants/users/util.tsx @@ -1,14 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyUsersIdentifyUpdate: - case EngineGen.keybase1NotifyTrackingNotifyUserBlocked: - { - storeRegistry.getState('users').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/fs/banner/reset-banner.tsx b/shared/fs/banner/reset-banner.tsx index bc9fc4837b45..061e5499db3a 100644 --- a/shared/fs/banner/reset-banner.tsx +++ b/shared/fs/banner/reset-banner.tsx @@ -4,7 +4,7 @@ import * as T from '@/constants/types' import {folderNameWithoutUsers} from '@/util/kbfs' import * as Kb from '@/common-adapters' import * as RowTypes from '@/fs/browser/rows/types' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' import {useProfileState} from '@/constants/profile' diff --git a/shared/fs/footer/proof-broken.tsx b/shared/fs/footer/proof-broken.tsx index 5bba1fed4a51..852d5b5f925d 100644 --- a/shared/fs/footer/proof-broken.tsx +++ b/shared/fs/footer/proof-broken.tsx @@ -1,7 +1,7 @@ import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import * as FS from '@/stores/fs' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' type Props = {path: T.FS.Path} diff --git a/shared/git/row.tsx b/shared/git/row.tsx index d079cd03852f..9a5ad0da18be 100644 --- a/shared/git/row.tsx +++ b/shared/git/row.tsx @@ -5,7 +5,7 @@ import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as React from 'react' import openURL from '@/util/open-url' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import * as FS from '@/stores/fs' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/menubar/remote-container.desktop.tsx b/shared/menubar/remote-container.desktop.tsx index bd346723f6ce..001fc9fe53ca 100644 --- a/shared/menubar/remote-container.desktop.tsx +++ b/shared/menubar/remote-container.desktop.tsx @@ -4,7 +4,7 @@ import Menubar from './index.desktop' import {useConfigState} from '@/constants/config' import type {DeserializeProps} from './remote-serializer.desktop' import {useAvatarState} from '@/common-adapters/avatar/store' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' import {useDaemonState} from '@/constants/daemon' diff --git a/shared/menubar/remote-proxy.desktop.tsx b/shared/menubar/remote-proxy.desktop.tsx index 356a96de7294..0ca7183325c0 100644 --- a/shared/menubar/remote-proxy.desktop.tsx +++ b/shared/menubar/remote-proxy.desktop.tsx @@ -15,7 +15,7 @@ import {useColorScheme} from 'react-native' import * as FS from '@/stores/fs' import {useFSState} from '@/stores/fs' import {useFollowerState} from '@/stores/followers' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useNotifState} from '@/stores/notifications' import {useCurrentUserState} from '@/constants/current-user' import {useDaemonState} from '@/constants/daemon' diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index 7f944107769e..63d1a752cac9 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -9,7 +9,7 @@ import * as Kb from '@/common-adapters' import {useSettingsPhoneState} from '@/constants/settings-phone' import {useSettingsEmailState} from '@/constants/settings-email' import {settingsAccountTab, settingsGitTab} from '@/constants/settings/util' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {usePeopleState, todoTypes} from '@/stores/people' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/profile/edit-profile.tsx b/shared/profile/edit-profile.tsx index 61bb397bab2a..326ee790dcda 100644 --- a/shared/profile/edit-profile.tsx +++ b/shared/profile/edit-profile.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/profile/generic/proofs-list.tsx b/shared/profile/generic/proofs-list.tsx index 20c8dae21a8a..7e5deec234ce 100644 --- a/shared/profile/generic/proofs-list.tsx +++ b/shared/profile/generic/proofs-list.tsx @@ -5,7 +5,7 @@ import type * as T from '@/constants/types' import {SiteIcon} from './shared' import {makeInsertMatcher} from '@/util/string' import {useColorScheme} from 'react-native' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' const Container = () => { diff --git a/shared/profile/showcase-team-offer.tsx b/shared/profile/showcase-team-offer.tsx index 0dca1149d584..1d90c173e5f5 100644 --- a/shared/profile/showcase-team-offer.tsx +++ b/shared/profile/showcase-team-offer.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import {useTeamsSubscribe} from '@/teams/subscriber' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useCurrentUserState} from '@/constants/current-user' const Container = () => { diff --git a/shared/profile/user/actions/index.tsx b/shared/profile/user/actions/index.tsx index 58d78b0bbd1a..0ef3cce3d788 100644 --- a/shared/profile/user/actions/index.tsx +++ b/shared/profile/user/actions/index.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import FollowButton from './follow-button' import ChatButton from '@/chat/chat-button' import {useBotsState} from '@/stores/bots' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import * as FS from '@/stores/fs' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/profile/user/friend.tsx b/shared/profile/user/friend.tsx index ef0815a24d86..ad9a2191d4a2 100644 --- a/shared/profile/user/friend.tsx +++ b/shared/profile/user/friend.tsx @@ -1,6 +1,6 @@ import {useProfileState} from '@/constants/profile' import * as Kb from '@/common-adapters' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' type OwnProps = { username: string diff --git a/shared/profile/user/hooks.tsx b/shared/profile/user/hooks.tsx index 83e22a319579..bb8fa6253cb2 100644 --- a/shared/profile/user/hooks.tsx +++ b/shared/profile/user/hooks.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import type * as T from '@/constants/types' import {type BackgroundColorType} from '.' import {useColorScheme} from 'react-native' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/profile/user/teams/index.tsx b/shared/profile/user/teams/index.tsx index 485b63dada42..95b12320ca95 100644 --- a/shared/profile/user/teams/index.tsx +++ b/shared/profile/user/teams/index.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import OpenMeta from './openmeta' import {default as TeamInfo, type Props as TIProps} from './teaminfo' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useCurrentUserState} from '@/constants/current-user' type OwnProps = {username: string} diff --git a/shared/router-v2/account-switcher/index.tsx b/shared/router-v2/account-switcher/index.tsx index 7ed7d926f309..66b81ffb43a8 100644 --- a/shared/router-v2/account-switcher/index.tsx +++ b/shared/router-v2/account-switcher/index.tsx @@ -5,9 +5,9 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' import {settingsLogOutTab} from '@/constants/settings/util' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' import {useProvisionState} from '@/constants/provision' diff --git a/shared/router-v2/tab-bar.desktop.tsx b/shared/router-v2/tab-bar.desktop.tsx index 1a62a49d858a..13591ffa5b87 100644 --- a/shared/router-v2/tab-bar.desktop.tsx +++ b/shared/router-v2/tab-bar.desktop.tsx @@ -14,7 +14,7 @@ import {isLinux} from '@/constants/platform' import KB2 from '@/util/electron.desktop' import './tab-bar.css' import {settingsLogOutTab} from '@/constants/settings/util' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useFSState} from '@/stores/fs' import {useProfileState} from '@/constants/profile' import {useNotifState} from '@/stores/notifications' diff --git a/shared/settings/contacts-joined.tsx b/shared/settings/contacts-joined.tsx index 232852a67173..51e7f3998508 100644 --- a/shared/settings/contacts-joined.tsx +++ b/shared/settings/contacts-joined.tsx @@ -5,7 +5,7 @@ import {useSafeNavigation} from '@/util/safe-navigation' import * as React from 'react' import UnconnectedFollowButton from '@/profile/user/actions/follow-button' import {useSettingsContactsState} from '@/constants/settings-contacts' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useFollowerState} from '@/stores/followers' const renderItem = (_: number, item: T.RPCGen.ProcessedContact) => diff --git a/shared/constants/tracker2/index.tsx b/shared/stores/tracker2.tsx similarity index 98% rename from shared/constants/tracker2/index.tsx rename to shared/stores/tracker2.tsx index 82d96edd041e..c715a1a1b4f6 100644 --- a/shared/constants/tracker2/index.tsx +++ b/shared/stores/tracker2.tsx @@ -1,14 +1,14 @@ -import * as S from '../strings' +import * as S from '@/constants/strings' import * as EngineGen from '@/actions/engine-gen-gen' -import {generateGUIID, ignorePromise} from '../utils' +import {generateGUIID, ignorePromise} from '@/constants/utils' import * as Z from '@/util/zustand' import logger from '@/logger' -import * as T from '../types' +import * as T from '@/constants/types' import {RPCError} from '@/util/errors' import {mapGetEnsureValue} from '@/util/map' -import {navigateAppend, navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' -import {useCurrentUserState} from '../current-user' +import {navigateAppend, navigateUp} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' +import {useCurrentUserState} from '@/constants/current-user' export const noDetails: T.Tracker.Details = { assertions: new Map(), diff --git a/shared/constants/unlock-folders/index.tsx b/shared/stores/unlock-folders.tsx similarity index 95% rename from shared/constants/unlock-folders/index.tsx rename to shared/stores/unlock-folders.tsx index 9cc11c3b8352..db58f5249690 100644 --- a/shared/constants/unlock-folders/index.tsx +++ b/shared/stores/unlock-folders.tsx @@ -1,9 +1,9 @@ import * as EngineGen from '@/actions/engine-gen-gen' -import * as T from '../types' +import * as T from '@/constants/types' import * as Z from '@/util/zustand' import logger from '@/logger' import {getEngine} from '@/engine/require' -import {useConfigState, type State as ConfigStore} from '../config' +import {useConfigState, type State as ConfigStore} from '@/constants/config' type Store = T.Immutable<{ devices: ConfigStore['unlockFoldersDevices'] diff --git a/shared/constants/users/index.tsx b/shared/stores/users.tsx similarity index 96% rename from shared/constants/users/index.tsx rename to shared/stores/users.tsx index 642c3c0f3ec9..618264f110ac 100644 --- a/shared/constants/users/index.tsx +++ b/shared/stores/users.tsx @@ -1,11 +1,11 @@ import * as EngineGen from '@/actions/engine-gen-gen' import * as Z from '@/util/zustand' import logger from '@/logger' -import * as T from '../types' +import * as T from '@/constants/types' import {mapGetEnsureValue} from '@/util/map' -import {ignorePromise} from '../utils' -import {RPCError, isNetworkErr} from '../utils' -import * as S from '../strings' +import {ignorePromise} from '@/constants/utils' +import {RPCError, isNetworkErr} from '@/constants/utils' +import * as S from '@/constants/strings' type Store = T.Immutable<{ blockMap: Map diff --git a/shared/team-building/search-result/people-result.tsx b/shared/team-building/search-result/people-result.tsx index a0df7405e4d7..3c2dde2f9e1c 100644 --- a/shared/team-building/search-result/people-result.tsx +++ b/shared/team-building/search-result/people-result.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as FS from '@/stores/fs' import CommonResult, {type ResultProps} from './common-result' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' /* diff --git a/shared/teams/channel/index.tsx b/shared/teams/channel/index.tsx index df5dfa2ca7b0..e0c681b756c9 100644 --- a/shared/teams/channel/index.tsx +++ b/shared/teams/channel/index.tsx @@ -16,7 +16,7 @@ import BotRow from '../team/rows/bot-row/bot' import SettingsList from '../../chat/conversation/info-panel/settings' import EmptyRow from '../team/rows/empty-row' import {useBotsState} from '@/stores/bots' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' export type OwnProps = { teamID: T.Teams.TeamID diff --git a/shared/teams/channel/rows.tsx b/shared/teams/channel/rows.tsx index 45391a990ac2..fa62d406fc68 100644 --- a/shared/teams/channel/rows.tsx +++ b/shared/teams/channel/rows.tsx @@ -6,7 +6,7 @@ import type * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' import MenuHeader from '../team/rows/menu-header.new' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' type Props = { diff --git a/shared/teams/team/rows/bot-row/bot.tsx b/shared/teams/team/rows/bot-row/bot.tsx index 81b3c88af31f..4509c8395169 100644 --- a/shared/teams/team/rows/bot-row/bot.tsx +++ b/shared/teams/team/rows/bot-row/bot.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import BotMenu from './bot-menu' import {useBotsState} from '@/stores/bots' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' export type Props = { diff --git a/shared/teams/team/rows/member-row.tsx b/shared/teams/team/rows/member-row.tsx index 3598f33d6125..34497c152c6a 100644 --- a/shared/teams/team/rows/member-row.tsx +++ b/shared/teams/team/rows/member-row.tsx @@ -6,9 +6,9 @@ import * as React from 'react' import type * as T from '@/constants/types' import MenuHeader from './menu-header.new' import {useSafeNavigation} from '@/util/safe-navigation' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' -import {useUsersState} from '@/constants/users' +import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/constants/current-user' export type Props = { diff --git a/shared/tracker2/assertion.tsx b/shared/tracker2/assertion.tsx index 57a0014647c3..991bbe415483 100644 --- a/shared/tracker2/assertion.tsx +++ b/shared/tracker2/assertion.tsx @@ -8,8 +8,8 @@ import * as Kb from '@/common-adapters' import {SiteIcon} from '@/profile/generic/shared' import {formatTimeForAssertionPopup} from '@/util/timestamp' import {useColorScheme} from 'react-native' -import * as Tracker from '@/constants/tracker2' -import {useTrackerState} from '@/constants/tracker2' +import * as Tracker from '@/stores/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' type OwnProps = { diff --git a/shared/tracker2/bio.tsx b/shared/tracker2/bio.tsx index a8f7213169d1..e26d67af9457 100644 --- a/shared/tracker2/bio.tsx +++ b/shared/tracker2/bio.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import {useTrackerState} from '@/constants/tracker2' +import {useTrackerState} from '@/stores/tracker2' import {useFollowerState} from '@/stores/followers' type OwnProps = { diff --git a/shared/tracker2/remote-container.desktop.tsx b/shared/tracker2/remote-container.desktop.tsx index 0bf397e22914..b07a455ed273 100644 --- a/shared/tracker2/remote-container.desktop.tsx +++ b/shared/tracker2/remote-container.desktop.tsx @@ -9,8 +9,8 @@ import Tracker from './index.desktop' import type {DeserializeProps} from './remote-serializer.desktop' import KB2 from '@/util/electron.desktop' import {useAvatarState} from '@/common-adapters/avatar/store' -import {useTrackerState} from '@/constants/tracker2' -import {useUsersState} from '@/constants/users' +import {useTrackerState} from '@/stores/tracker2' +import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' import {useDarkModeState} from '@/constants/darkmode' diff --git a/shared/tracker2/remote-proxy.desktop.tsx b/shared/tracker2/remote-proxy.desktop.tsx index cebdb746423b..f476fd225b39 100644 --- a/shared/tracker2/remote-proxy.desktop.tsx +++ b/shared/tracker2/remote-proxy.desktop.tsx @@ -9,8 +9,8 @@ import {serialize, type ProxyProps} from './remote-serializer.desktop' import {intersect} from '@/util/set' import {mapFilterByKey} from '@/util/map' import {useColorScheme} from 'react-native' -import {useTrackerState} from '@/constants/tracker2' -import {useUsersState} from '@/constants/users' +import {useTrackerState} from '@/stores/tracker2' +import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/constants/current-user' diff --git a/shared/unlock-folders/index.desktop.tsx b/shared/unlock-folders/index.desktop.tsx index d8cd03f4894a..38d1bacf0883 100644 --- a/shared/unlock-folders/index.desktop.tsx +++ b/shared/unlock-folders/index.desktop.tsx @@ -4,7 +4,7 @@ import DeviceList from './device-list.desktop' import DragHeader from '../desktop/remote/drag-header.desktop' import PaperKeyInput from './paper-key-input.desktop' import Success from './success.desktop' -import type * as Constants from '@/constants/unlock-folders' +import type * as Constants from '@/stores/unlock-folders' import type {State as ConfigStore} from '@/constants/config' export type Props = { diff --git a/shared/unlock-folders/remote-container.desktop.tsx b/shared/unlock-folders/remote-container.desktop.tsx index 15446563ffc6..196e2331f6c6 100644 --- a/shared/unlock-folders/remote-container.desktop.tsx +++ b/shared/unlock-folders/remote-container.desktop.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as RemoteGen from '../actions/remote-gen' import UnlockFolders from './index.desktop' import type {DeserializeProps} from './remote-serializer.desktop' -import {useUnlockFoldersState as useUFState} from '@/constants/unlock-folders' +import {useUnlockFoldersState as useUFState} from '@/stores/unlock-folders' import {useDarkModeState} from '@/constants/darkmode' const RemoteContainer = (d: DeserializeProps) => { From 87b27895832458967cb679a40b37193ca3707028 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:24:03 -0500 Subject: [PATCH 22/37] WIP --- shared/constants/init/shared.tsx | 62 ++++++++++++++++---------------- 1 file changed, 32 insertions(+), 30 deletions(-) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index df360f7e02b3..fd441716a161 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -110,32 +110,34 @@ export const onEngineConnected = () => { } catch (error) { logger.warn('error in registering secret ui: ', error) } - } - ignorePromise(f()) - } - { // Tracker2 - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterIdentify3UIRpcPromise() - logger.info('Registered identify ui') - } catch (error) { - logger.warn('error in registering identify ui: ', error) - } - } - ignorePromise(f()) - } - { // UnlockFolders - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterRekeyUIRpcPromise() - logger.info('Registered rekey ui') - } catch (error) { - logger.warn('error in registering rekey ui: ') - logger.debug('error in registering rekey ui: ', error) - } - } - ignorePromise(f()) - } + } + ignorePromise(f()) + } + { + // Tracker2 + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterIdentify3UIRpcPromise() + logger.info('Registered identify ui') + } catch (error) { + logger.warn('error in registering identify ui: ', error) + } + } + ignorePromise(f()) + } + { + // UnlockFolders + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterRekeyUIRpcPromise() + logger.info('Registered rekey ui') + } catch (error) { + logger.warn('error in registering rekey ui: ') + logger.debug('error in registering rekey ui: ', error) + } + } + ignorePromise(f()) + } } export const onEngineDisconnected = () => { @@ -454,8 +456,8 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { case EngineGen.keybase1NotifyTrackingTrackingChanged: { const {isTracking, username} = action.payload.params useFollowerState.getState().dispatch.updateFollowing(username, isTracking) - const {useTracker2State} = require('@/stores/tracker2') as typeof UseTracker2StateType - useTracker2State.getState().dispatch.onEngineIncomingImpl(action) + const {useTrackerState} = require('@/stores/tracker2') as typeof UseTracker2StateType + useTrackerState.getState().dispatch.onEngineIncomingImpl(action) break } case EngineGen.keybase1NotifyTrackingTrackingInfo: { @@ -480,8 +482,8 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { case EngineGen.keybase1Identify3UiIdentify3UpdateUserCard: case EngineGen.keybase1Identify3UiIdentify3Summary: { - const {useTracker2State} = require('@/stores/tracker2') as typeof UseTracker2StateType - useTracker2State.getState().dispatch.onEngineIncomingImpl(action) + const {useTrackerState} = require('@/stores/tracker2') as typeof UseTracker2StateType + useTrackerState.getState().dispatch.onEngineIncomingImpl(action) } { const {useUsersState} = require('@/stores/users') as typeof UseUsersStateType From cdd7461f784efad98d892e56802b5bb87c93d278 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:28:27 -0500 Subject: [PATCH 23/37] WIP --- shared/app/global-errors/hook.tsx | 2 +- shared/app/index.native.tsx | 2 +- shared/app/out-of-date.tsx | 2 +- shared/app/runtime-stats.tsx | 2 +- shared/chat/audio/audio-recorder.native.tsx | 2 +- shared/chat/blocking/block-modal.tsx | 2 +- shared/chat/blocking/invitation-to-block.tsx | 4 +- shared/chat/chat-button.tsx | 4 +- .../attachment-fullscreen/hooks.tsx | 2 +- .../conversation/attachment-get-titles.tsx | 2 +- shared/chat/conversation/bot/confirm.tsx | 2 +- shared/chat/conversation/bot/install.tsx | 2 +- shared/chat/conversation/bot/search.tsx | 2 +- shared/chat/conversation/bottom-banner.tsx | 2 +- shared/chat/conversation/command-markdown.tsx | 2 +- shared/chat/conversation/command-status.tsx | 4 +- shared/chat/conversation/container.tsx | 2 +- shared/chat/conversation/error.tsx | 2 +- shared/chat/conversation/fwd-msg.tsx | 2 +- shared/chat/conversation/giphy/hooks.tsx | 2 +- .../conversation/header-area/index.native.tsx | 4 +- .../conversation/info-panel/add-people.tsx | 2 +- .../info-panel/add-to-channel.tsx | 2 +- .../conversation/info-panel/attachments.tsx | 2 +- shared/chat/conversation/info-panel/bot.tsx | 2 +- .../chat/conversation/info-panel/common.tsx | 2 +- .../chat/conversation/info-panel/header.tsx | 2 +- shared/chat/conversation/info-panel/index.tsx | 2 +- .../chat/conversation/info-panel/members.tsx | 2 +- shared/chat/conversation/info-panel/menu.tsx | 4 +- .../info-panel/settings/index.tsx | 4 +- .../info-panel/settings/min-writer-role.tsx | 2 +- .../info-panel/settings/notifications.tsx | 2 +- .../conversation/input-area/container.tsx | 2 +- .../input-area/location-popup.native.tsx | 6 +- .../conversation/input-area/normal2/index.tsx | 4 +- .../normal2/moremenu-popup.native.tsx | 2 +- .../normal2/platform-input.desktop.tsx | 2 +- .../normal2/platform-input.native.tsx | 4 +- .../normal2/set-explode-popup/hooks.tsx | 2 +- .../input-area/normal2/typing.tsx | 2 +- .../chat/conversation/input-area/preview.tsx | 2 +- .../input-area/suggestors/channels.tsx | 2 +- .../input-area/suggestors/commands.tsx | 2 +- .../input-area/suggestors/emoji.tsx | 2 +- .../input-area/suggestors/index.tsx | 2 +- .../input-area/suggestors/users.tsx | 2 +- shared/chat/conversation/list-area/hooks.tsx | 2 +- .../conversation/list-area/index.desktop.tsx | 4 +- .../conversation/list-area/index.native.tsx | 2 +- shared/chat/conversation/load-status.tsx | 2 +- .../messages/account-payment/container.tsx | 4 +- .../messages/account-payment/wrapper.tsx | 2 +- .../messages/attachment/audio.tsx | 2 +- .../conversation/messages/attachment/file.tsx | 4 +- .../messages/attachment/image2/use-state.tsx | 2 +- .../messages/attachment/shared.tsx | 2 +- .../messages/attachment/video/use-state.tsx | 2 +- .../conversation/messages/cards/make-team.tsx | 2 +- .../messages/cards/team-journey/container.tsx | 2 +- .../chat/conversation/messages/emoji-row.tsx | 2 +- .../messages/message-popup/attachment.tsx | 2 +- .../messages/message-popup/hooks.tsx | 6 +- .../messages/message-popup/index.tsx | 2 +- .../messages/message-popup/journeycard.tsx | 2 +- .../messages/message-popup/reactionitem.tsx | 2 +- .../messages/message-popup/text.tsx | 6 +- .../chat/conversation/messages/pin/index.tsx | 2 +- .../conversation/messages/pin/wrapper.tsx | 2 +- .../messages/placeholder/wrapper.tsx | 2 +- .../conversation/messages/react-button.tsx | 4 +- .../messages/reaction-tooltip.tsx | 2 +- .../conversation/messages/reactions-rows.tsx | 2 +- .../chat/conversation/messages/reset-user.tsx | 2 +- .../messages/retention-notice.tsx | 2 +- .../chat/conversation/messages/separator.tsx | 4 +- .../messages/set-channelname/wrapper.tsx | 2 +- .../messages/set-description/wrapper.tsx | 2 +- .../messages/special-bottom-message.tsx | 2 +- .../messages/special-top-message.tsx | 4 +- .../system-added-to-team/container.tsx | 4 +- .../messages/system-added-to-team/wrapper.tsx | 2 +- .../messages/system-change-avatar/index.tsx | 2 +- .../messages/system-change-avatar/wrapper.tsx | 2 +- .../system-change-retention/container.tsx | 4 +- .../system-change-retention/wrapper.tsx | 2 +- .../messages/system-create-team/container.tsx | 4 +- .../messages/system-create-team/wrapper.tsx | 2 +- .../messages/system-git-push/container.tsx | 4 +- .../messages/system-git-push/wrapper.tsx | 2 +- .../system-invite-accepted/container.tsx | 4 +- .../system-invite-accepted/wrapper.tsx | 2 +- .../messages/system-joined/container.tsx | 2 +- .../messages/system-joined/wrapper.tsx | 2 +- .../messages/system-left/container.tsx | 2 +- .../messages/system-left/wrapper.tsx | 2 +- .../messages/system-new-channel/container.tsx | 2 +- .../messages/system-new-channel/wrapper.tsx | 2 +- .../container.tsx | 2 +- .../messages/system-profile-reset-notice.tsx | 2 +- .../messages/system-sbs-resolve/container.tsx | 2 +- .../messages/system-sbs-resolve/wrapper.tsx | 4 +- .../system-simple-to-complex/container.tsx | 4 +- .../system-simple-to-complex/wrapper.tsx | 2 +- .../messages/system-text/wrapper.tsx | 2 +- .../system-users-added-to-conv/container.tsx | 4 +- .../system-users-added-to-conv/wrapper.tsx | 2 +- .../conversation/messages/text/bottom.tsx | 2 +- .../messages/text/coinflip/index.tsx | 2 +- .../chat/conversation/messages/text/reply.tsx | 2 +- .../text/unfurl/prompt-list/container.tsx | 2 +- .../text/unfurl/unfurl-list/generic.tsx | 2 +- .../text/unfurl/unfurl-list/giphy.tsx | 2 +- .../text/unfurl/unfurl-list/image/index.tsx | 2 +- .../text/unfurl/unfurl-list/index.tsx | 2 +- .../text/unfurl/unfurl-list/map-popup.tsx | 4 +- .../messages/text/unfurl/unfurl-list/map.tsx | 2 +- .../text/unfurl/unfurl-list/use-state.tsx | 4 +- .../conversation/messages/text/wrapper.tsx | 2 +- .../conversation/messages/wrapper/edited.tsx | 2 +- .../exploding-height-retainer/container.tsx | 2 +- .../messages/wrapper/exploding-meta.tsx | 2 +- .../wrapper/long-pressable/index.native.tsx | 2 +- .../messages/wrapper/send-indicator.tsx | 2 +- .../conversation/messages/wrapper/wrapper.tsx | 4 +- shared/chat/conversation/normal/container.tsx | 4 +- .../conversation/normal/index.desktop.tsx | 2 +- .../chat/conversation/normal/index.native.tsx | 2 +- shared/chat/conversation/pinned-message.tsx | 4 +- shared/chat/conversation/rekey/container.tsx | 4 +- shared/chat/conversation/reply-preview.tsx | 2 +- shared/chat/conversation/search.tsx | 2 +- shared/chat/delete-history-warning.tsx | 2 +- shared/chat/emoji-picker/container.tsx | 2 +- shared/chat/inbox-and-conversation-2.tsx | 2 +- shared/chat/inbox-and-conversation-header.tsx | 4 +- shared/chat/inbox-search/index.tsx | 2 +- shared/chat/inbox/container.tsx | 2 +- shared/chat/inbox/filter-row.tsx | 2 +- shared/chat/inbox/index.native.tsx | 2 +- shared/chat/inbox/new-chat-button.tsx | 2 +- shared/chat/inbox/row/big-team-channel.tsx | 2 +- shared/chat/inbox/row/big-team-header.tsx | 2 +- shared/chat/inbox/row/big-teams-divider.tsx | 2 +- shared/chat/inbox/row/opened-row-state.tsx | 2 +- .../chat/inbox/row/small-team/bottom-line.tsx | 4 +- shared/chat/inbox/row/small-team/index.tsx | 4 +- .../swipe-conv-actions/index.native.tsx | 2 +- shared/chat/inbox/row/small-team/top-line.tsx | 2 +- shared/chat/inbox/row/teams-divider.tsx | 2 +- shared/chat/inbox/search-row.tsx | 2 +- shared/chat/new-team-dialog-container.tsx | 2 +- shared/chat/payments/status/index.tsx | 4 +- shared/chat/pdf/index.desktop.tsx | 2 +- shared/chat/pdf/index.native.tsx | 4 +- shared/chat/routes.tsx | 2 +- .../selectable-big-team-channel-container.tsx | 2 +- .../chat/selectable-small-team-container.tsx | 4 +- shared/chat/send-to-chat/index.tsx | 4 +- shared/common-adapters/avatar/hooks.tsx | 2 +- shared/common-adapters/copy-text.tsx | 2 +- shared/common-adapters/markdown/channel.tsx | 2 +- .../markdown/maybe-mention/index.tsx | 2 +- .../markdown/maybe-mention/team.tsx | 2 +- shared/common-adapters/mention-container.tsx | 4 +- shared/common-adapters/mention.tsx | 2 +- shared/common-adapters/profile-card.tsx | 2 +- shared/common-adapters/reload.tsx | 2 +- shared/common-adapters/usernames.tsx | 2 +- shared/common-adapters/wave-button.tsx | 2 +- shared/constants/chat2/debug.tsx | 2 +- shared/constants/chat2/util.tsx | 61 ------------------- shared/constants/init/shared.tsx | 60 ++++++++++++++++-- .../platform-specific/kbfs-notifications.tsx | 2 +- shared/constants/store-registry.tsx | 4 +- shared/crypto/input.tsx | 2 +- shared/crypto/operations/decrypt.tsx | 2 +- shared/crypto/operations/encrypt.tsx | 2 +- shared/crypto/operations/sign.tsx | 2 +- shared/crypto/operations/verify.tsx | 2 +- shared/crypto/output.tsx | 6 +- shared/crypto/recipients.tsx | 2 +- shared/crypto/sub-nav/index.desktop.tsx | 2 +- shared/crypto/sub-nav/index.native.tsx | 2 +- shared/crypto/sub-nav/left-nav.desktop.tsx | 2 +- .../remote/use-serialize-props.desktop.tsx | 2 +- shared/desktop/renderer/main2.desktop.tsx | 2 +- shared/devices/device-revoke.tsx | 4 +- shared/fs/browser/root.tsx | 2 +- shared/fs/browser/rows/rows-container.tsx | 2 +- shared/fs/browser/rows/tlf.tsx | 2 +- .../path-item-action/menu-container.tsx | 4 +- shared/fs/common/tlf-info-line-container.tsx | 2 +- shared/fs/filepreview/view.tsx | 2 +- shared/fs/nav-header/main-banner.tsx | 2 +- shared/git/row.tsx | 2 +- shared/incoming-share/index.tsx | 2 +- shared/login/index.tsx | 2 +- shared/login/join-or-login.tsx | 2 +- shared/login/recover-password/error-modal.tsx | 2 +- shared/login/recover-password/error.tsx | 2 +- shared/login/relogin/container.tsx | 2 +- shared/menubar/chat-container.desktop.tsx | 2 +- shared/menubar/files-container.desktop.tsx | 2 +- shared/menubar/remote-container.desktop.tsx | 6 +- shared/menubar/remote-proxy.desktop.tsx | 6 +- shared/people/announcement.tsx | 2 +- shared/people/container.tsx | 2 +- shared/people/routes.tsx | 2 +- shared/people/todo.tsx | 2 +- shared/profile/edit-profile.tsx | 2 +- shared/profile/post-proof.tsx | 2 +- shared/profile/showcase-team-offer.tsx | 2 +- shared/profile/user/actions/index.tsx | 2 +- shared/profile/user/hooks.tsx | 2 +- shared/profile/user/teams/index.tsx | 2 +- shared/provision/code-page/container.tsx | 2 +- .../code-page/qr-scan/not-authorized.tsx | 2 +- shared/router-v2/account-switcher/index.tsx | 4 +- shared/router-v2/header/index.desktop.tsx | 2 +- shared/router-v2/hooks.native.tsx | 4 +- shared/router-v2/router.desktop.tsx | 4 +- shared/router-v2/router.native.tsx | 2 +- shared/router-v2/tab-bar.desktop.tsx | 4 +- shared/settings/advanced.tsx | 2 +- shared/settings/archive/modal.tsx | 2 +- shared/settings/chat.tsx | 2 +- shared/settings/delete-confirm/index.tsx | 2 +- shared/settings/display.tsx | 2 +- .../settings/feedback/container.desktop.tsx | 2 +- shared/settings/feedback/container.native.tsx | 4 +- shared/settings/manage-contacts.tsx | 2 +- shared/settings/root-phone.tsx | 2 +- shared/signup/common.tsx | 2 +- shared/signup/feedback.tsx | 2 +- .../chat2/index.tsx => stores/chat2.tsx} | 46 +++++++------- .../config/index.tsx => stores/config.tsx} | 16 ++--- .../crypto/index.tsx => stores/crypto.tsx} | 16 ++--- .../index.tsx => stores/current-user.tsx} | 2 +- shared/stores/fs.tsx | 4 +- shared/stores/git.tsx | 2 +- shared/stores/notifications.tsx | 4 +- shared/stores/people.tsx | 2 +- shared/stores/settings.tsx | 4 +- shared/stores/signup.tsx | 2 +- shared/stores/teams.tsx | 4 +- shared/stores/tracker2.tsx | 2 +- shared/stores/unlock-folders.tsx | 2 +- shared/team-building/list-body.tsx | 2 +- .../search-result/hellobot-result.tsx | 2 +- .../search-result/people-result.tsx | 4 +- .../search-result/you-result.tsx | 2 +- shared/teams/add-members-wizard/confirm.tsx | 2 +- shared/teams/channel/header.tsx | 2 +- shared/teams/channel/index.tsx | 2 +- shared/teams/channel/rows.tsx | 4 +- shared/teams/common/channel-hooks.tsx | 2 +- shared/teams/common/enable-contacts.tsx | 2 +- shared/teams/common/selection-popup.tsx | 2 +- shared/teams/container.tsx | 2 +- shared/teams/emojis/add-alias.tsx | 2 +- shared/teams/emojis/add-emoji.tsx | 2 +- shared/teams/external-team.tsx | 2 +- shared/teams/main/team-row.tsx | 2 +- .../new-team/wizard/add-subteam-members.tsx | 2 +- shared/teams/routes.tsx | 2 +- shared/teams/team/member/add-to-channels.tsx | 4 +- shared/teams/team/member/index.new.tsx | 4 +- shared/teams/team/new-header.tsx | 4 +- shared/teams/team/rows/emoji-row/item.tsx | 2 +- shared/teams/team/rows/empty-row.tsx | 4 +- shared/teams/team/rows/index.tsx | 4 +- shared/teams/team/rows/invite-row/request.tsx | 2 +- shared/teams/team/rows/member-row.tsx | 4 +- shared/teams/team/settings-tab/index.tsx | 2 +- .../team/settings-tab/retention/index.tsx | 2 +- shared/teams/team/tabs.tsx | 2 +- shared/tracker2/assertion.tsx | 4 +- shared/tracker2/remote-container.desktop.tsx | 4 +- shared/tracker2/remote-proxy.desktop.tsx | 4 +- shared/unlock-folders/device-list.desktop.tsx | 2 +- shared/unlock-folders/index.desktop.tsx | 2 +- .../unlock-folders/remote-proxy.desktop.tsx | 2 +- .../remote-serializer.desktop.tsx | 2 +- shared/wallets/really-remove-account.tsx | 2 +- shared/whats-new/container.tsx | 2 +- 286 files changed, 446 insertions(+), 457 deletions(-) rename shared/{constants/chat2/index.tsx => stores/chat2.tsx} (98%) rename shared/{constants/config/index.tsx => stores/config.tsx} (98%) rename shared/{constants/crypto/index.tsx => stores/crypto.tsx} (98%) rename shared/{constants/current-user/index.tsx => stores/current-user.tsx} (96%) diff --git a/shared/app/global-errors/hook.tsx b/shared/app/global-errors/hook.tsx index 646d872c8f90..7a92cae51285 100644 --- a/shared/app/global-errors/hook.tsx +++ b/shared/app/global-errors/hook.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import type {RPCError} from '@/util/errors' import {settingsFeedbackTab} from '@/constants/settings/util' import {useDaemonState} from '@/constants/daemon' diff --git a/shared/app/index.native.tsx b/shared/app/index.native.tsx index 9fbbeae4fbbd..37ca9ac4da1d 100644 --- a/shared/app/index.native.tsx +++ b/shared/app/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as Kb from '@/common-adapters' import * as React from 'react' import {handleAppLink} from '@/constants/deeplinks' diff --git a/shared/app/out-of-date.tsx b/shared/app/out-of-date.tsx index 3287a86e87d1..d77926f918bc 100644 --- a/shared/app/out-of-date.tsx +++ b/shared/app/out-of-date.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' import logger from '@/logger' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const styles = Kb.Styles.styleSheetCreate(() => ({ container: { diff --git a/shared/app/runtime-stats.tsx b/shared/app/runtime-stats.tsx index 55e94eee4a96..2ea975b665cc 100644 --- a/shared/app/runtime-stats.tsx +++ b/shared/app/runtime-stats.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const isIPhoneX = false as boolean // import lagRadar from 'lag-radar' diff --git a/shared/chat/audio/audio-recorder.native.tsx b/shared/chat/audio/audio-recorder.native.tsx index b68e7f68ade6..8c3a2d197c98 100644 --- a/shared/chat/audio/audio-recorder.native.tsx +++ b/shared/chat/audio/audio-recorder.native.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {Portal} from '@/common-adapters/portal.native' diff --git a/shared/chat/blocking/block-modal.tsx b/shared/chat/blocking/block-modal.tsx index 284449657558..0a9dfdd64d03 100644 --- a/shared/chat/blocking/block-modal.tsx +++ b/shared/chat/blocking/block-modal.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useTeamsState} from '@/stores/teams' import {useUsersState} from '@/stores/users' diff --git a/shared/chat/blocking/invitation-to-block.tsx b/shared/chat/blocking/invitation-to-block.tsx index e7ba0b2f0950..98d3d040fe4c 100644 --- a/shared/chat/blocking/invitation-to-block.tsx +++ b/shared/chat/blocking/invitation-to-block.tsx @@ -1,8 +1,8 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const BlockButtons = () => { const nav = useSafeNavigation() diff --git a/shared/chat/chat-button.tsx b/shared/chat/chat-button.tsx index 1524bf4e37a2..d565cffd15b4 100644 --- a/shared/chat/chat-button.tsx +++ b/shared/chat/chat-button.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Styles from '@/styles' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import WaitingButton from '@/common-adapters/waiting-button' import Icon from '@/common-adapters/icon' diff --git a/shared/chat/conversation/attachment-fullscreen/hooks.tsx b/shared/chat/conversation/attachment-fullscreen/hooks.tsx index 02fdc5218010..cd16b218c638 100644 --- a/shared/chat/conversation/attachment-fullscreen/hooks.tsx +++ b/shared/chat/conversation/attachment-fullscreen/hooks.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as T from '@/constants/types' import {maxWidth, maxHeight} from '../messages/attachment/shared' import {useFSState} from '@/stores/fs' diff --git a/shared/chat/conversation/attachment-get-titles.tsx b/shared/chat/conversation/attachment-get-titles.tsx index 317df4f73246..ee2da9c58036 100644 --- a/shared/chat/conversation/attachment-get-titles.tsx +++ b/shared/chat/conversation/attachment-get-titles.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/bot/confirm.tsx b/shared/chat/conversation/bot/confirm.tsx index 4f0c8230ebbc..6d7c001fb176 100644 --- a/shared/chat/conversation/bot/confirm.tsx +++ b/shared/chat/conversation/bot/confirm.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as T from '@/constants/types' import {useBotConversationIDKey} from './install' diff --git a/shared/chat/conversation/bot/install.tsx b/shared/chat/conversation/bot/install.tsx index c114624f7970..88c1f3a90369 100644 --- a/shared/chat/conversation/bot/install.tsx +++ b/shared/chat/conversation/bot/install.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as React from 'react' diff --git a/shared/chat/conversation/bot/search.tsx b/shared/chat/conversation/bot/search.tsx index eb7e97b220b7..ec1309ad25f6 100644 --- a/shared/chat/conversation/bot/search.tsx +++ b/shared/chat/conversation/bot/search.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import debounce from 'lodash/debounce' diff --git a/shared/chat/conversation/bottom-banner.tsx b/shared/chat/conversation/bottom-banner.tsx index be5b4fc016b2..6d5fa9af7d4e 100644 --- a/shared/chat/conversation/bottom-banner.tsx +++ b/shared/chat/conversation/bottom-banner.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import _openSMS from '@/util/sms' diff --git a/shared/chat/conversation/command-markdown.tsx b/shared/chat/conversation/command-markdown.tsx index 1f434bc4d280..10c20f1c5509 100644 --- a/shared/chat/conversation/command-markdown.tsx +++ b/shared/chat/conversation/command-markdown.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' const CommandMarkdown = () => { diff --git a/shared/chat/conversation/command-status.tsx b/shared/chat/conversation/command-status.tsx index 9a005c52a13c..d27ab60a9bf3 100644 --- a/shared/chat/conversation/command-status.tsx +++ b/shared/chat/conversation/command-status.tsx @@ -1,7 +1,7 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const empty = { actions: [], diff --git a/shared/chat/conversation/container.tsx b/shared/chat/conversation/container.tsx index 0cb2f2d21908..d892d3f39949 100644 --- a/shared/chat/conversation/container.tsx +++ b/shared/chat/conversation/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import Normal from './normal/container' import NoConversation from './no-conversation' import Error from './error' diff --git a/shared/chat/conversation/error.tsx b/shared/chat/conversation/error.tsx index c4762dc4f87a..0c9266bb235c 100644 --- a/shared/chat/conversation/error.tsx +++ b/shared/chat/conversation/error.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' const ConversationError = () => { diff --git a/shared/chat/conversation/fwd-msg.tsx b/shared/chat/conversation/fwd-msg.tsx index 53ec16deb001..265d9e69c756 100644 --- a/shared/chat/conversation/fwd-msg.tsx +++ b/shared/chat/conversation/fwd-msg.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/giphy/hooks.tsx b/shared/chat/conversation/giphy/hooks.tsx index bad968dd56aa..b2aea6c79b09 100644 --- a/shared/chat/conversation/giphy/hooks.tsx +++ b/shared/chat/conversation/giphy/hooks.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' export const useHooks = () => { const giphy = Chat.useChatContext(s => s.giphyResult) diff --git a/shared/chat/conversation/header-area/index.native.tsx b/shared/chat/conversation/header-area/index.native.tsx index 76ac856624e3..6ae6aa6e6411 100644 --- a/shared/chat/conversation/header-area/index.native.tsx +++ b/shared/chat/conversation/header-area/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' import * as Kb from '@/common-adapters' import * as React from 'react' @@ -10,7 +10,7 @@ import {Keyboard} from 'react-native' import {assertionToDisplay} from '@/common-adapters/usernames' import {useSafeAreaFrame} from 'react-native-safe-area-context' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export const HeaderAreaRight = () => { const conversationIDKey = Chat.useChatContext(s => s.id) diff --git a/shared/chat/conversation/info-panel/add-people.tsx b/shared/chat/conversation/info-panel/add-people.tsx index d205f0f75df6..724cd29ec1c1 100644 --- a/shared/chat/conversation/info-panel/add-people.tsx +++ b/shared/chat/conversation/info-panel/add-people.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useTeamsState} from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/info-panel/add-to-channel.tsx b/shared/chat/conversation/info-panel/add-to-channel.tsx index e23827118b04..2109aaae2717 100644 --- a/shared/chat/conversation/info-panel/add-to-channel.tsx +++ b/shared/chat/conversation/info-panel/add-to-channel.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/info-panel/attachments.tsx b/shared/chat/conversation/info-panel/attachments.tsx index c407c5430d4e..1deea243bb7d 100644 --- a/shared/chat/conversation/info-panel/attachments.tsx +++ b/shared/chat/conversation/info-panel/attachments.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import type {StylesTextCrossPlatform} from '@/common-adapters/text' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/info-panel/bot.tsx b/shared/chat/conversation/info-panel/bot.tsx index d6e8b36d8ea7..1152170c6d5d 100644 --- a/shared/chat/conversation/info-panel/bot.tsx +++ b/shared/chat/conversation/info-panel/bot.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/conversation/info-panel/common.tsx b/shared/chat/conversation/info-panel/common.tsx index 945a958f3741..d01c196b8579 100644 --- a/shared/chat/conversation/info-panel/common.tsx +++ b/shared/chat/conversation/info-panel/common.tsx @@ -1,4 +1,4 @@ -import type * as Chat from '@/constants/chat2' +import type * as Chat from '@/stores/chat2' import {useTeamsState} from '@/stores/teams' import * as React from 'react' import * as Styles from '@/styles' diff --git a/shared/chat/conversation/info-panel/header.tsx b/shared/chat/conversation/info-panel/header.tsx index ff048b085cb6..6d45cc0ca533 100644 --- a/shared/chat/conversation/info-panel/header.tsx +++ b/shared/chat/conversation/info-panel/header.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/info-panel/index.tsx b/shared/chat/conversation/info-panel/index.tsx index 9dfb7e2b18fa..0bf1adf3fad2 100644 --- a/shared/chat/conversation/info-panel/index.tsx +++ b/shared/chat/conversation/info-panel/index.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as React from 'react' diff --git a/shared/chat/conversation/info-panel/members.tsx b/shared/chat/conversation/info-panel/members.tsx index 7c20cb2ee717..2e6387126774 100644 --- a/shared/chat/conversation/info-panel/members.tsx +++ b/shared/chat/conversation/info-panel/members.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' import * as Teams from '@/stores/teams' import * as React from 'react' diff --git a/shared/chat/conversation/info-panel/menu.tsx b/shared/chat/conversation/info-panel/menu.tsx index 2a7c95ce51c5..0d1bd8e20c50 100644 --- a/shared/chat/conversation/info-panel/menu.tsx +++ b/shared/chat/conversation/info-panel/menu.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as React from 'react' @@ -8,7 +8,7 @@ import * as InfoPanelCommon from './common' import {Avatars, TeamAvatar} from '@/chat/avatars' import {TeamsSubscriberMountOnly} from '@/teams/subscriber' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export type OwnProps = { attachTo?: React.RefObject diff --git a/shared/chat/conversation/info-panel/settings/index.tsx b/shared/chat/conversation/info-panel/settings/index.tsx index 6e4297882778..7656d2a941d9 100644 --- a/shared/chat/conversation/info-panel/settings/index.tsx +++ b/shared/chat/conversation/info-panel/settings/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as T from '@/constants/types' @@ -7,7 +7,7 @@ import * as React from 'react' import MinWriterRole from './min-writer-role' import Notifications from './notifications' import RetentionPicker from '@/teams/team/settings-tab/retention' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type EntityType = 'adhoc' | 'small team' | 'channel' type SettingsPanelProps = {isPreview: boolean} diff --git a/shared/chat/conversation/info-panel/settings/min-writer-role.tsx b/shared/chat/conversation/info-panel/settings/min-writer-role.tsx index 7900cff41a0c..56c8a09e4566 100644 --- a/shared/chat/conversation/info-panel/settings/min-writer-role.tsx +++ b/shared/chat/conversation/info-panel/settings/min-writer-role.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as React from 'react' diff --git a/shared/chat/conversation/info-panel/settings/notifications.tsx b/shared/chat/conversation/info-panel/settings/notifications.tsx index 53bbf518206f..fdfcb3a0bc94 100644 --- a/shared/chat/conversation/info-panel/settings/notifications.tsx +++ b/shared/chat/conversation/info-panel/settings/notifications.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/input-area/container.tsx b/shared/chat/conversation/input-area/container.tsx index 7ce09e75c96b..e318566ef103 100644 --- a/shared/chat/conversation/input-area/container.tsx +++ b/shared/chat/conversation/input-area/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import Normal from './normal2' import Preview from './preview' import ThreadSearch from '../search' diff --git a/shared/chat/conversation/input-area/location-popup.native.tsx b/shared/chat/conversation/input-area/location-popup.native.tsx index 1225ddfcd0eb..1df813f11cf2 100644 --- a/shared/chat/conversation/input-area/location-popup.native.tsx +++ b/shared/chat/conversation/input-area/location-popup.native.tsx @@ -1,12 +1,12 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import logger from '@/logger' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import LocationMap from '@/chat/location-map' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {requestLocationPermission} from '@/constants/platform-specific' import * as ExpoLocation from 'expo-location' diff --git a/shared/chat/conversation/input-area/normal2/index.tsx b/shared/chat/conversation/input-area/normal2/index.tsx index 8ceea809bb21..248c3e9db0bd 100644 --- a/shared/chat/conversation/input-area/normal2/index.tsx +++ b/shared/chat/conversation/input-area/normal2/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import CommandMarkdown from '../../command-markdown' @@ -13,7 +13,7 @@ import {infoPanelWidthTablet} from '../../info-panel/common' import {assertionToDisplay} from '@/common-adapters/usernames' import {FocusContext, ScrollContext} from '@/chat/conversation/normal/context' import type {RefType as Input2Ref} from '@/common-adapters/input2' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const useHintText = (p: { isExploding: boolean diff --git a/shared/chat/conversation/input-area/normal2/moremenu-popup.native.tsx b/shared/chat/conversation/input-area/normal2/moremenu-popup.native.tsx index fc790cc73f5a..e75a2301b57f 100644 --- a/shared/chat/conversation/input-area/normal2/moremenu-popup.native.tsx +++ b/shared/chat/conversation/input-area/normal2/moremenu-popup.native.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' type Props = { diff --git a/shared/chat/conversation/input-area/normal2/platform-input.desktop.tsx b/shared/chat/conversation/input-area/normal2/platform-input.desktop.tsx index d56a9ef8bba8..5533d8515bec 100644 --- a/shared/chat/conversation/input-area/normal2/platform-input.desktop.tsx +++ b/shared/chat/conversation/input-area/normal2/platform-input.desktop.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/conversation/input-area/normal2/platform-input.native.tsx b/shared/chat/conversation/input-area/normal2/platform-input.native.tsx index 134412c3846e..496f7ebb8c5a 100644 --- a/shared/chat/conversation/input-area/normal2/platform-input.native.tsx +++ b/shared/chat/conversation/input-area/normal2/platform-input.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import AudioRecorder from '@/chat/audio/audio-recorder.native' @@ -28,7 +28,7 @@ import logger from '@/logger' import {AudioSendWrapper} from '@/chat/audio/audio-send.native' import {usePickerState} from '@/chat/emoji-picker/use-picker' import type {RefType as Input2Ref, Props as Input2Props} from '@/common-adapters/input2' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const singleLineHeight = 36 const threeLineHeight = 78 diff --git a/shared/chat/conversation/input-area/normal2/set-explode-popup/hooks.tsx b/shared/chat/conversation/input-area/normal2/set-explode-popup/hooks.tsx index 1552f0f23d43..64ae5aca987a 100644 --- a/shared/chat/conversation/input-area/normal2/set-explode-popup/hooks.tsx +++ b/shared/chat/conversation/input-area/normal2/set-explode-popup/hooks.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' import type {Props} from '.' diff --git a/shared/chat/conversation/input-area/normal2/typing.tsx b/shared/chat/conversation/input-area/normal2/typing.tsx index b9a42ecff2ee..c274f4396aae 100644 --- a/shared/chat/conversation/input-area/normal2/typing.tsx +++ b/shared/chat/conversation/input-area/normal2/typing.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/input-area/preview.tsx b/shared/chat/conversation/input-area/preview.tsx index 3f118f4469ac..64e25419c5f8 100644 --- a/shared/chat/conversation/input-area/preview.tsx +++ b/shared/chat/conversation/input-area/preview.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/input-area/suggestors/channels.tsx b/shared/chat/conversation/input-area/suggestors/channels.tsx index 350526631aca..4e0bc22ec650 100644 --- a/shared/chat/conversation/input-area/suggestors/channels.tsx +++ b/shared/chat/conversation/input-area/suggestors/channels.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Teams from '@/stores/teams' import * as Common from './common' diff --git a/shared/chat/conversation/input-area/suggestors/commands.tsx b/shared/chat/conversation/input-area/suggestors/commands.tsx index 80f9f7753c81..4cfa2041c692 100644 --- a/shared/chat/conversation/input-area/suggestors/commands.tsx +++ b/shared/chat/conversation/input-area/suggestors/commands.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Common from './common' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/input-area/suggestors/emoji.tsx b/shared/chat/conversation/input-area/suggestors/emoji.tsx index 2af8b5366e0e..df285c3eb4d2 100644 --- a/shared/chat/conversation/input-area/suggestors/emoji.tsx +++ b/shared/chat/conversation/input-area/suggestors/emoji.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Common from './common' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/conversation/input-area/suggestors/index.tsx b/shared/chat/conversation/input-area/suggestors/index.tsx index d82cd92e2019..a075d4262c9c 100644 --- a/shared/chat/conversation/input-area/suggestors/index.tsx +++ b/shared/chat/conversation/input-area/suggestors/index.tsx @@ -1,5 +1,5 @@ import * as Channels from './channels' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Commands from './commands' import * as Emoji from './emoji' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/input-area/suggestors/users.tsx b/shared/chat/conversation/input-area/suggestors/users.tsx index dea63fd5f0ad..f951b0e3536a 100644 --- a/shared/chat/conversation/input-area/suggestors/users.tsx +++ b/shared/chat/conversation/input-area/suggestors/users.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useTeamsState} from '@/stores/teams' import * as T from '@/constants/types' import * as Common from './common' diff --git a/shared/chat/conversation/list-area/hooks.tsx b/shared/chat/conversation/list-area/hooks.tsx index 6208ee8417e4..0570ca7ed8fd 100644 --- a/shared/chat/conversation/list-area/hooks.tsx +++ b/shared/chat/conversation/list-area/hooks.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import JumpToRecent from './jump-to-recent' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/list-area/index.desktop.tsx b/shared/chat/conversation/list-area/index.desktop.tsx index f26f84b9ca4d..2dd8fc5f700a 100644 --- a/shared/chat/conversation/list-area/index.desktop.tsx +++ b/shared/chat/conversation/list-area/index.desktop.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Hooks from './hooks' import * as React from 'react' @@ -17,7 +17,7 @@ import logger from '@/logger' import shallowEqual from 'shallowequal' import useResizeObserver from '@/util/use-resize-observer.desktop' import useIntersectionObserver from '@/util/use-intersection-observer' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' // Infinite scrolling list. // We group messages into a series of Waypoints. When the waypoint exits the screen we replace it with a single div instead diff --git a/shared/chat/conversation/list-area/index.native.tsx b/shared/chat/conversation/list-area/index.native.tsx index 8cfc247601a6..099c5b69734e 100644 --- a/shared/chat/conversation/list-area/index.native.tsx +++ b/shared/chat/conversation/list-area/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Hooks from './hooks' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/load-status.tsx b/shared/chat/conversation/load-status.tsx index e992dd920145..786061c50ab9 100644 --- a/shared/chat/conversation/load-status.tsx +++ b/shared/chat/conversation/load-status.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/account-payment/container.tsx b/shared/chat/conversation/messages/account-payment/container.tsx index 7aec89fb2655..e728ab2606eb 100644 --- a/shared/chat/conversation/messages/account-payment/container.tsx +++ b/shared/chat/conversation/messages/account-payment/container.tsx @@ -1,8 +1,8 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import MarkdownMemo from '@/wallets/markdown-memo' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' // Props for rendering the loading indicator const loadingProps = { diff --git a/shared/chat/conversation/messages/account-payment/wrapper.tsx b/shared/chat/conversation/messages/account-payment/wrapper.tsx index 7e2bd8bf7b79..619ed8222849 100644 --- a/shared/chat/conversation/messages/account-payment/wrapper.tsx +++ b/shared/chat/conversation/messages/account-payment/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type PaymentMessageType from './container' diff --git a/shared/chat/conversation/messages/attachment/audio.tsx b/shared/chat/conversation/messages/attachment/audio.tsx index caa3ddc2354d..1de12a908a91 100644 --- a/shared/chat/conversation/messages/attachment/audio.tsx +++ b/shared/chat/conversation/messages/attachment/audio.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {useOrdinal} from '../ids-context' diff --git a/shared/chat/conversation/messages/attachment/file.tsx b/shared/chat/conversation/messages/attachment/file.tsx index 1cbb694c3939..9ec116c82f1c 100644 --- a/shared/chat/conversation/messages/attachment/file.tsx +++ b/shared/chat/conversation/messages/attachment/file.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import * as Crypto from '@/constants/crypto' +import * as Chat from '@/stores/chat2' +import * as Crypto from '@/stores/crypto' import * as React from 'react' import {isPathSaltpack, isPathSaltpackEncrypted, isPathSaltpackSigned} from '@/util/path' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/attachment/image2/use-state.tsx b/shared/chat/conversation/messages/attachment/image2/use-state.tsx index da4c4093b538..2399086be164 100644 --- a/shared/chat/conversation/messages/attachment/image2/use-state.tsx +++ b/shared/chat/conversation/messages/attachment/image2/use-state.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useOrdinal} from '@/chat/conversation/messages/ids-context' import {maxWidth, maxHeight} from '../shared' diff --git a/shared/chat/conversation/messages/attachment/shared.tsx b/shared/chat/conversation/messages/attachment/shared.tsx index b1893784f743..d0937dde1167 100644 --- a/shared/chat/conversation/messages/attachment/shared.tsx +++ b/shared/chat/conversation/messages/attachment/shared.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/attachment/video/use-state.tsx b/shared/chat/conversation/messages/attachment/video/use-state.tsx index b02adc6d8a21..5fc3c9eaa684 100644 --- a/shared/chat/conversation/messages/attachment/video/use-state.tsx +++ b/shared/chat/conversation/messages/attachment/video/use-state.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useOrdinal} from '@/chat/conversation/messages/ids-context' import {missingMessage, maxWidth, maxHeight} from '../shared' diff --git a/shared/chat/conversation/messages/cards/make-team.tsx b/shared/chat/conversation/messages/cards/make-team.tsx index ce3ca6ea16b3..d01d46e8e954 100644 --- a/shared/chat/conversation/messages/cards/make-team.tsx +++ b/shared/chat/conversation/messages/cards/make-team.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' const MakeTeam = () => { diff --git a/shared/chat/conversation/messages/cards/team-journey/container.tsx b/shared/chat/conversation/messages/cards/team-journey/container.tsx index 94f8fdeb3143..19d47a2be434 100644 --- a/shared/chat/conversation/messages/cards/team-journey/container.tsx +++ b/shared/chat/conversation/messages/cards/team-journey/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/emoji-row.tsx b/shared/chat/conversation/messages/emoji-row.tsx index 43e13a7f324c..ffbb461d8082 100644 --- a/shared/chat/conversation/messages/emoji-row.tsx +++ b/shared/chat/conversation/messages/emoji-row.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {useOrdinal} from './ids-context' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/message-popup/attachment.tsx b/shared/chat/conversation/messages/message-popup/attachment.tsx index 9fc1b4e8acc6..19227db84c07 100644 --- a/shared/chat/conversation/messages/message-popup/attachment.tsx +++ b/shared/chat/conversation/messages/message-popup/attachment.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' import {type Position, fileUIName, type StylesCrossPlatform} from '@/styles' diff --git a/shared/chat/conversation/messages/message-popup/hooks.tsx b/shared/chat/conversation/messages/message-popup/hooks.tsx index 7bd9c7f5c81b..0bccbdb2510f 100644 --- a/shared/chat/conversation/messages/message-popup/hooks.tsx +++ b/shared/chat/conversation/messages/message-popup/hooks.tsx @@ -1,11 +1,11 @@ import * as React from 'react' import type * as T from '@/constants/types' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import {useProfileState} from '@/constants/profile' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {linkFromConvAndMessage} from '@/constants/deeplinks' import ReactionItem from './reactionitem' import MessagePopupHeader from './header' diff --git a/shared/chat/conversation/messages/message-popup/index.tsx b/shared/chat/conversation/messages/message-popup/index.tsx index 111c936d3678..3736bfdc3587 100644 --- a/shared/chat/conversation/messages/message-popup/index.tsx +++ b/shared/chat/conversation/messages/message-popup/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import AttachmentMessage from './attachment' diff --git a/shared/chat/conversation/messages/message-popup/journeycard.tsx b/shared/chat/conversation/messages/message-popup/journeycard.tsx index 560590fd8ce3..f631f84246f6 100644 --- a/shared/chat/conversation/messages/message-popup/journeycard.tsx +++ b/shared/chat/conversation/messages/message-popup/journeycard.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/chat/conversation/messages/message-popup/reactionitem.tsx b/shared/chat/conversation/messages/message-popup/reactionitem.tsx index 051dce87b10c..9c734e3f529c 100644 --- a/shared/chat/conversation/messages/message-popup/reactionitem.tsx +++ b/shared/chat/conversation/messages/message-popup/reactionitem.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' type Props = { diff --git a/shared/chat/conversation/messages/message-popup/text.tsx b/shared/chat/conversation/messages/message-popup/text.tsx index 3a8c7f28077d..ac05c2730cce 100644 --- a/shared/chat/conversation/messages/message-popup/text.tsx +++ b/shared/chat/conversation/messages/message-popup/text.tsx @@ -1,13 +1,13 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import {useConfigState} from '@/constants/config' +import * as Chat from '@/stores/chat2' +import {useConfigState} from '@/stores/config' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import type {Position, StylesCrossPlatform} from '@/styles' import {useItems, useHeader} from './hooks' import openURL from '@/util/open-url' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = { attachTo?: React.RefObject diff --git a/shared/chat/conversation/messages/pin/index.tsx b/shared/chat/conversation/messages/pin/index.tsx index 937d4cb6fb2c..7618510b7557 100644 --- a/shared/chat/conversation/messages/pin/index.tsx +++ b/shared/chat/conversation/messages/pin/index.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/pin/wrapper.tsx b/shared/chat/conversation/messages/pin/wrapper.tsx index 5cfd3cb7c7f2..67125e1e8575 100644 --- a/shared/chat/conversation/messages/pin/wrapper.tsx +++ b/shared/chat/conversation/messages/pin/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type PinType from '.' diff --git a/shared/chat/conversation/messages/placeholder/wrapper.tsx b/shared/chat/conversation/messages/placeholder/wrapper.tsx index 5cc050f9d681..45c196e3be7a 100644 --- a/shared/chat/conversation/messages/placeholder/wrapper.tsx +++ b/shared/chat/conversation/messages/placeholder/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/react-button.tsx b/shared/chat/conversation/messages/react-button.tsx index 4d9e009c7c5f..289f1870748c 100644 --- a/shared/chat/conversation/messages/react-button.tsx +++ b/shared/chat/conversation/messages/react-button.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type {StylesCrossPlatform} from '@/styles' import {useOrdinal} from './ids-context' @@ -7,7 +7,7 @@ import * as Kb from '@/common-adapters' import type {StyleOverride} from '@/common-adapters/markdown' import {colors, darkColors} from '@/styles/colors' import {useColorScheme} from 'react-native' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export type OwnProps = { className?: string diff --git a/shared/chat/conversation/messages/reaction-tooltip.tsx b/shared/chat/conversation/messages/reaction-tooltip.tsx index 428ec1fdd7d9..d196fa1180f1 100644 --- a/shared/chat/conversation/messages/reaction-tooltip.tsx +++ b/shared/chat/conversation/messages/reaction-tooltip.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import ReactButton from './react-button' diff --git a/shared/chat/conversation/messages/reactions-rows.tsx b/shared/chat/conversation/messages/reactions-rows.tsx index cde5d850f470..21d1eef42325 100644 --- a/shared/chat/conversation/messages/reactions-rows.tsx +++ b/shared/chat/conversation/messages/reactions-rows.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import EmojiRow from './emoji-row' diff --git a/shared/chat/conversation/messages/reset-user.tsx b/shared/chat/conversation/messages/reset-user.tsx index 08ae473cf8ff..cfc6f5694cd0 100644 --- a/shared/chat/conversation/messages/reset-user.tsx +++ b/shared/chat/conversation/messages/reset-user.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/retention-notice.tsx b/shared/chat/conversation/messages/retention-notice.tsx index 20815e3b8457..77327c4f58ed 100644 --- a/shared/chat/conversation/messages/retention-notice.tsx +++ b/shared/chat/conversation/messages/retention-notice.tsx @@ -1,5 +1,5 @@ import type * as T from '@/constants/types' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/conversation/messages/separator.tsx b/shared/chat/conversation/messages/separator.tsx index 182a5ffb120c..567cf91a6269 100644 --- a/shared/chat/conversation/messages/separator.tsx +++ b/shared/chat/conversation/messages/separator.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' @@ -9,7 +9,7 @@ import {OrangeLineContext} from '../orange-line-context' import logger from '@/logger' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' // import {useChatDebugDump} from '@/constants/chat2/debug' const enoughTimeBetweenMessages = (mtimestamp?: number, ptimestamp?: number): boolean => diff --git a/shared/chat/conversation/messages/set-channelname/wrapper.tsx b/shared/chat/conversation/messages/set-channelname/wrapper.tsx index e3a0c0164c7d..c507ae29e940 100644 --- a/shared/chat/conversation/messages/set-channelname/wrapper.tsx +++ b/shared/chat/conversation/messages/set-channelname/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SetChannelnameType from './container' diff --git a/shared/chat/conversation/messages/set-description/wrapper.tsx b/shared/chat/conversation/messages/set-description/wrapper.tsx index 9f8400a9e58d..0383a7edc43e 100644 --- a/shared/chat/conversation/messages/set-description/wrapper.tsx +++ b/shared/chat/conversation/messages/set-description/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SetDescriptionType from './container' diff --git a/shared/chat/conversation/messages/special-bottom-message.tsx b/shared/chat/conversation/messages/special-bottom-message.tsx index e6e45bf35bee..386a56528d86 100644 --- a/shared/chat/conversation/messages/special-bottom-message.tsx +++ b/shared/chat/conversation/messages/special-bottom-message.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import OldProfileReset from './system-old-profile-reset-notice/container' import ResetUser from './reset-user' diff --git a/shared/chat/conversation/messages/special-top-message.tsx b/shared/chat/conversation/messages/special-top-message.tsx index 77ad455838ea..902b3c7f2bf0 100644 --- a/shared/chat/conversation/messages/special-top-message.tsx +++ b/shared/chat/conversation/messages/special-top-message.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as React from 'react' @@ -11,7 +11,7 @@ import ProfileResetNotice from './system-profile-reset-notice' import RetentionNotice from './retention-notice' import {usingFlashList} from '../list-area/flashlist-config' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const ErrorMessage = () => { const createConversationError = Chat.useChatState(s => s.createConversationError) diff --git a/shared/chat/conversation/messages/system-added-to-team/container.tsx b/shared/chat/conversation/messages/system-added-to-team/container.tsx index 4a9ce7b40884..10999c12dc9f 100644 --- a/shared/chat/conversation/messages/system-added-to-team/container.tsx +++ b/shared/chat/conversation/messages/system-added-to-team/container.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' @@ -6,7 +6,7 @@ import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' import {getAddedUsernames} from '../system-users-added-to-conv/container' import {indefiniteArticle} from '@/util/string' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemAddedToTeam} diff --git a/shared/chat/conversation/messages/system-added-to-team/wrapper.tsx b/shared/chat/conversation/messages/system-added-to-team/wrapper.tsx index f90914a28f97..dcefb1626e38 100644 --- a/shared/chat/conversation/messages/system-added-to-team/wrapper.tsx +++ b/shared/chat/conversation/messages/system-added-to-team/wrapper.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemAddedToTeamType from './container' diff --git a/shared/chat/conversation/messages/system-change-avatar/index.tsx b/shared/chat/conversation/messages/system-change-avatar/index.tsx index bdf0fffdfe4b..8aa32c6b3098 100644 --- a/shared/chat/conversation/messages/system-change-avatar/index.tsx +++ b/shared/chat/conversation/messages/system-change-avatar/index.tsx @@ -1,7 +1,7 @@ import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import UserNotice from '../user-notice' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { message: T.Chat.MessageSystemChangeAvatar diff --git a/shared/chat/conversation/messages/system-change-avatar/wrapper.tsx b/shared/chat/conversation/messages/system-change-avatar/wrapper.tsx index 172ac0051c55..ed14bda12cb3 100644 --- a/shared/chat/conversation/messages/system-change-avatar/wrapper.tsx +++ b/shared/chat/conversation/messages/system-change-avatar/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemChangeAvatarType from '.' diff --git a/shared/chat/conversation/messages/system-change-retention/container.tsx b/shared/chat/conversation/messages/system-change-retention/container.tsx index 3d5162914370..d192ebd93f88 100644 --- a/shared/chat/conversation/messages/system-change-retention/container.tsx +++ b/shared/chat/conversation/messages/system-change-retention/container.tsx @@ -1,11 +1,11 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' import * as T from '@/constants/types' import * as dateFns from 'date-fns' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemChangeRetention} diff --git a/shared/chat/conversation/messages/system-change-retention/wrapper.tsx b/shared/chat/conversation/messages/system-change-retention/wrapper.tsx index 85490ad934a3..8d6d231f78ed 100644 --- a/shared/chat/conversation/messages/system-change-retention/wrapper.tsx +++ b/shared/chat/conversation/messages/system-change-retention/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemChangeRetentionType from './container' diff --git a/shared/chat/conversation/messages/system-create-team/container.tsx b/shared/chat/conversation/messages/system-create-team/container.tsx index 46f66b1d655b..b3c654e66d2f 100644 --- a/shared/chat/conversation/messages/system-create-team/container.tsx +++ b/shared/chat/conversation/messages/system-create-team/container.tsx @@ -1,11 +1,11 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' import type * as T from '@/constants/types' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemCreateTeam} diff --git a/shared/chat/conversation/messages/system-create-team/wrapper.tsx b/shared/chat/conversation/messages/system-create-team/wrapper.tsx index 4d4cd246197a..2a9216ababec 100644 --- a/shared/chat/conversation/messages/system-create-team/wrapper.tsx +++ b/shared/chat/conversation/messages/system-create-team/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemCreateTeamType from './container' diff --git a/shared/chat/conversation/messages/system-git-push/container.tsx b/shared/chat/conversation/messages/system-git-push/container.tsx index 686e7e0a2050..cd31144d737f 100644 --- a/shared/chat/conversation/messages/system-git-push/container.tsx +++ b/shared/chat/conversation/messages/system-git-push/container.tsx @@ -1,11 +1,11 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {useGitState} from '@/stores/git' import UserNotice from '../user-notice' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemGitPush} diff --git a/shared/chat/conversation/messages/system-git-push/wrapper.tsx b/shared/chat/conversation/messages/system-git-push/wrapper.tsx index aaac3ac464e6..89e05a0090f8 100644 --- a/shared/chat/conversation/messages/system-git-push/wrapper.tsx +++ b/shared/chat/conversation/messages/system-git-push/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemGitPushType from './container' diff --git a/shared/chat/conversation/messages/system-invite-accepted/container.tsx b/shared/chat/conversation/messages/system-invite-accepted/container.tsx index 0b0744749876..b2d1357a85fd 100644 --- a/shared/chat/conversation/messages/system-invite-accepted/container.tsx +++ b/shared/chat/conversation/messages/system-invite-accepted/container.tsx @@ -1,11 +1,11 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemInviteAccepted} diff --git a/shared/chat/conversation/messages/system-invite-accepted/wrapper.tsx b/shared/chat/conversation/messages/system-invite-accepted/wrapper.tsx index 118224348648..aeed739b80d4 100644 --- a/shared/chat/conversation/messages/system-invite-accepted/wrapper.tsx +++ b/shared/chat/conversation/messages/system-invite-accepted/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemInviteAcceptedType from './container' diff --git a/shared/chat/conversation/messages/system-joined/container.tsx b/shared/chat/conversation/messages/system-joined/container.tsx index 7ca9df41d333..a9dc7563c9d2 100644 --- a/shared/chat/conversation/messages/system-joined/container.tsx +++ b/shared/chat/conversation/messages/system-joined/container.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/system-joined/wrapper.tsx b/shared/chat/conversation/messages/system-joined/wrapper.tsx index 996f2dc95968..7fe46e21979f 100644 --- a/shared/chat/conversation/messages/system-joined/wrapper.tsx +++ b/shared/chat/conversation/messages/system-joined/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemJoinedType from './container' diff --git a/shared/chat/conversation/messages/system-left/container.tsx b/shared/chat/conversation/messages/system-left/container.tsx index 70ed9a1b3d74..65d0cdf61516 100644 --- a/shared/chat/conversation/messages/system-left/container.tsx +++ b/shared/chat/conversation/messages/system-left/container.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' diff --git a/shared/chat/conversation/messages/system-left/wrapper.tsx b/shared/chat/conversation/messages/system-left/wrapper.tsx index cf6f97dea1dd..53f8df6c82d2 100644 --- a/shared/chat/conversation/messages/system-left/wrapper.tsx +++ b/shared/chat/conversation/messages/system-left/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemLeftType from './container' diff --git a/shared/chat/conversation/messages/system-new-channel/container.tsx b/shared/chat/conversation/messages/system-new-channel/container.tsx index 88579029fc92..f8e1e201837d 100644 --- a/shared/chat/conversation/messages/system-new-channel/container.tsx +++ b/shared/chat/conversation/messages/system-new-channel/container.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import {useTeamsState} from '@/stores/teams' import * as React from 'react' diff --git a/shared/chat/conversation/messages/system-new-channel/wrapper.tsx b/shared/chat/conversation/messages/system-new-channel/wrapper.tsx index 27da6aaba425..be12f9f0554f 100644 --- a/shared/chat/conversation/messages/system-new-channel/wrapper.tsx +++ b/shared/chat/conversation/messages/system-new-channel/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemNewChannelType from './container' diff --git a/shared/chat/conversation/messages/system-old-profile-reset-notice/container.tsx b/shared/chat/conversation/messages/system-old-profile-reset-notice/container.tsx index 4044fd8a281b..e306630f87ad 100644 --- a/shared/chat/conversation/messages/system-old-profile-reset-notice/container.tsx +++ b/shared/chat/conversation/messages/system-old-profile-reset-notice/container.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as T from '@/constants/types' import {Text} from '@/common-adapters' import UserNotice from '../user-notice' diff --git a/shared/chat/conversation/messages/system-profile-reset-notice.tsx b/shared/chat/conversation/messages/system-profile-reset-notice.tsx index 2d7deca69d72..0a2677a6140d 100644 --- a/shared/chat/conversation/messages/system-profile-reset-notice.tsx +++ b/shared/chat/conversation/messages/system-profile-reset-notice.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from './user-notice' diff --git a/shared/chat/conversation/messages/system-sbs-resolve/container.tsx b/shared/chat/conversation/messages/system-sbs-resolve/container.tsx index 51da16607892..8346cd4d5a80 100644 --- a/shared/chat/conversation/messages/system-sbs-resolve/container.tsx +++ b/shared/chat/conversation/messages/system-sbs-resolve/container.tsx @@ -2,7 +2,7 @@ import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {e164ToDisplay} from '@/util/phone-numbers' import UserNotice from '../user-notice' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemSBSResolved} diff --git a/shared/chat/conversation/messages/system-sbs-resolve/wrapper.tsx b/shared/chat/conversation/messages/system-sbs-resolve/wrapper.tsx index 32db70666c32..bd9d9626c95a 100644 --- a/shared/chat/conversation/messages/system-sbs-resolve/wrapper.tsx +++ b/shared/chat/conversation/messages/system-sbs-resolve/wrapper.tsx @@ -1,9 +1,9 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemSBSResolvedType from './container' import type SystemJoinedType from '../system-joined/container' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const WrapperSystemInvite = React.memo(function WrapperSystemInvite(p: Props) { const {ordinal} = p diff --git a/shared/chat/conversation/messages/system-simple-to-complex/container.tsx b/shared/chat/conversation/messages/system-simple-to-complex/container.tsx index 1a72fe42901f..baa73a2f6af5 100644 --- a/shared/chat/conversation/messages/system-simple-to-complex/container.tsx +++ b/shared/chat/conversation/messages/system-simple-to-complex/container.tsx @@ -1,10 +1,10 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {useTeamsState} from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemSimpleToComplex} diff --git a/shared/chat/conversation/messages/system-simple-to-complex/wrapper.tsx b/shared/chat/conversation/messages/system-simple-to-complex/wrapper.tsx index 93d830470578..d894327e7599 100644 --- a/shared/chat/conversation/messages/system-simple-to-complex/wrapper.tsx +++ b/shared/chat/conversation/messages/system-simple-to-complex/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemSimpleToComplexType from './container' diff --git a/shared/chat/conversation/messages/system-text/wrapper.tsx b/shared/chat/conversation/messages/system-text/wrapper.tsx index 9b99bc02b180..4f2efa4555f6 100644 --- a/shared/chat/conversation/messages/system-text/wrapper.tsx +++ b/shared/chat/conversation/messages/system-text/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemTextType from './container' diff --git a/shared/chat/conversation/messages/system-users-added-to-conv/container.tsx b/shared/chat/conversation/messages/system-users-added-to-conv/container.tsx index 3d67beba56bb..1a9d48e4233d 100644 --- a/shared/chat/conversation/messages/system-users-added-to-conv/container.tsx +++ b/shared/chat/conversation/messages/system-users-added-to-conv/container.tsx @@ -1,9 +1,9 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import UserNotice from '../user-notice' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {message: T.Chat.MessageSystemUsersAddedToConversation} diff --git a/shared/chat/conversation/messages/system-users-added-to-conv/wrapper.tsx b/shared/chat/conversation/messages/system-users-added-to-conv/wrapper.tsx index 5941d8eebbcd..1fe3e0bf1c8b 100644 --- a/shared/chat/conversation/messages/system-users-added-to-conv/wrapper.tsx +++ b/shared/chat/conversation/messages/system-users-added-to-conv/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {WrapperMessage, useCommon, type Props} from '../wrapper/wrapper' import type SystemUsersAddedToConvType from './container' diff --git a/shared/chat/conversation/messages/text/bottom.tsx b/shared/chat/conversation/messages/text/bottom.tsx index 128cc464ef16..e1a26112b6ab 100644 --- a/shared/chat/conversation/messages/text/bottom.tsx +++ b/shared/chat/conversation/messages/text/bottom.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' import type CoinFlipType from './coinflip' diff --git a/shared/chat/conversation/messages/text/coinflip/index.tsx b/shared/chat/conversation/messages/text/coinflip/index.tsx index 223547f15130..45f53d2d088d 100644 --- a/shared/chat/conversation/messages/text/coinflip/index.tsx +++ b/shared/chat/conversation/messages/text/coinflip/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/text/reply.tsx b/shared/chat/conversation/messages/text/reply.tsx index 7ad7cfacd4f9..bc0d9c745128 100644 --- a/shared/chat/conversation/messages/text/reply.tsx +++ b/shared/chat/conversation/messages/text/reply.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import {useOrdinal, useIsHighlighted} from '../ids-context' diff --git a/shared/chat/conversation/messages/text/unfurl/prompt-list/container.tsx b/shared/chat/conversation/messages/text/unfurl/prompt-list/container.tsx index 240d090eab40..ea0da57b5081 100644 --- a/shared/chat/conversation/messages/text/unfurl/prompt-list/container.tsx +++ b/shared/chat/conversation/messages/text/unfurl/prompt-list/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {useOrdinal} from '@/chat/conversation/messages/ids-context' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/generic.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/generic.tsx index 444f2452a61e..51105368b6e1 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/generic.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/generic.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters/index' import * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/giphy.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/giphy.tsx index 3e97b16ef8fd..238515cda7c3 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/giphy.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/giphy.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters/index' import * as React from 'react' import UnfurlImage from './image' diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/image/index.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/image/index.tsx index a826e6dc5e04..e2a3ba2f2c5d 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/image/index.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/image/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as Kb from '@/common-adapters/index' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {maxWidth} from '@/chat/conversation/messages/attachment/shared' import {Video} from './video' import openURL from '@/util/open-url' diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/index.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/index.tsx index 1aa89030311a..65c37cb40387 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/index.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as React from 'react' import UnfurlGeneric from './generic' diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/map-popup.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/map-popup.tsx index 243034849db6..59e03f3db1c5 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/map-popup.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/map-popup.tsx @@ -1,10 +1,10 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters/index' import type * as T from '@/constants/types' import openURL from '@/util/open-url' import LocationMap from '@/chat/location-map' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' type Props = { coord: T.Chat.Coordinate diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/map.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/map.tsx index 2cf754f6891e..68ec76e60397 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/map.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/map.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters/index' import * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/chat/conversation/messages/text/unfurl/unfurl-list/use-state.tsx b/shared/chat/conversation/messages/text/unfurl/unfurl-list/use-state.tsx index 4a7fddb9d9dd..1092daf24b90 100644 --- a/shared/chat/conversation/messages/text/unfurl/unfurl-list/use-state.tsx +++ b/shared/chat/conversation/messages/text/unfurl/unfurl-list/use-state.tsx @@ -1,7 +1,7 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export const useActions = (youAreAuthor: boolean, messageID: T.Chat.MessageID, ordinal: T.Chat.Ordinal) => { const unfurlRemove = Chat.useChatContext(s => s.dispatch.unfurlRemove) diff --git a/shared/chat/conversation/messages/text/wrapper.tsx b/shared/chat/conversation/messages/text/wrapper.tsx index d3a6ed554bae..c1b077922b4b 100644 --- a/shared/chat/conversation/messages/text/wrapper.tsx +++ b/shared/chat/conversation/messages/text/wrapper.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import {useReply} from './reply' diff --git a/shared/chat/conversation/messages/wrapper/edited.tsx b/shared/chat/conversation/messages/wrapper/edited.tsx index bc39cbae643b..a3e2d0df2fbe 100644 --- a/shared/chat/conversation/messages/wrapper/edited.tsx +++ b/shared/chat/conversation/messages/wrapper/edited.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import {useIsHighlighted, useOrdinal} from '../ids-context' diff --git a/shared/chat/conversation/messages/wrapper/exploding-height-retainer/container.tsx b/shared/chat/conversation/messages/wrapper/exploding-height-retainer/container.tsx index fae3926d1218..0fc71930593c 100644 --- a/shared/chat/conversation/messages/wrapper/exploding-height-retainer/container.tsx +++ b/shared/chat/conversation/messages/wrapper/exploding-height-retainer/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import ExplodingHeightRetainer from '.' import {useOrdinal} from '../../ids-context' diff --git a/shared/chat/conversation/messages/wrapper/exploding-meta.tsx b/shared/chat/conversation/messages/wrapper/exploding-meta.tsx index c6a3a6c1bdde..fa796f6b0354 100644 --- a/shared/chat/conversation/messages/wrapper/exploding-meta.tsx +++ b/shared/chat/conversation/messages/wrapper/exploding-meta.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {useIsHighlighted, useOrdinal} from '../ids-context' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/wrapper/long-pressable/index.native.tsx b/shared/chat/conversation/messages/wrapper/long-pressable/index.native.tsx index f5d163fce1c0..72f39ea87942 100644 --- a/shared/chat/conversation/messages/wrapper/long-pressable/index.native.tsx +++ b/shared/chat/conversation/messages/wrapper/long-pressable/index.native.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import type {Props} from '.' diff --git a/shared/chat/conversation/messages/wrapper/send-indicator.tsx b/shared/chat/conversation/messages/wrapper/send-indicator.tsx index 4f5df715d762..6f197da1ed5a 100644 --- a/shared/chat/conversation/messages/wrapper/send-indicator.tsx +++ b/shared/chat/conversation/messages/wrapper/send-indicator.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useOrdinal} from '../ids-context' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/wrapper/wrapper.tsx b/shared/chat/conversation/messages/wrapper/wrapper.tsx index d1c4186278d0..e4f0a9609e36 100644 --- a/shared/chat/conversation/messages/wrapper/wrapper.tsx +++ b/shared/chat/conversation/messages/wrapper/wrapper.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import {MessageContext, useOrdinal} from '../ids-context' @@ -13,7 +13,7 @@ import SendIndicator from './send-indicator' import * as T from '@/constants/types' import capitalize from 'lodash/capitalize' import {useEdited} from './edited' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' // import {useDebugLayout} from '@/util/debug-react' export type Props = { diff --git a/shared/chat/conversation/normal/container.tsx b/shared/chat/conversation/normal/container.tsx index dbbb9157900a..dc1ee30496aa 100644 --- a/shared/chat/conversation/normal/container.tsx +++ b/shared/chat/conversation/normal/container.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import {useConfigState} from '@/constants/config' +import * as Chat from '@/stores/chat2' +import {useConfigState} from '@/stores/config' import * as React from 'react' import Normal from '.' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/normal/index.desktop.tsx b/shared/chat/conversation/normal/index.desktop.tsx index 645314cf0f43..2e5dde5320c0 100644 --- a/shared/chat/conversation/normal/index.desktop.tsx +++ b/shared/chat/conversation/normal/index.desktop.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import Banner from '../bottom-banner' diff --git a/shared/chat/conversation/normal/index.native.tsx b/shared/chat/conversation/normal/index.native.tsx index b51457ece826..bfb4263d9019 100644 --- a/shared/chat/conversation/normal/index.native.tsx +++ b/shared/chat/conversation/normal/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {PortalHost} from '@/common-adapters/portal.native' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/conversation/pinned-message.tsx b/shared/chat/conversation/pinned-message.tsx index 07ce1d1a68d4..9e18af274b21 100644 --- a/shared/chat/conversation/pinned-message.tsx +++ b/shared/chat/conversation/pinned-message.tsx @@ -1,10 +1,10 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const PinnedMessage = React.memo(function PinnedMessage() { const {conversationIDKey, teamname, pinnedMsg, replyJump, onIgnore, pinMessage} = Chat.useChatContext( diff --git a/shared/chat/conversation/rekey/container.tsx b/shared/chat/conversation/rekey/container.tsx index d4397fb0346a..ad910c500867 100644 --- a/shared/chat/conversation/rekey/container.tsx +++ b/shared/chat/conversation/rekey/container.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import * as T from '@/constants/types' import ParticipantRekey from './participant-rekey' import YouRekey from './you-rekey' diff --git a/shared/chat/conversation/reply-preview.tsx b/shared/chat/conversation/reply-preview.tsx index 4997bad338bd..b194fb2091cb 100644 --- a/shared/chat/conversation/reply-preview.tsx +++ b/shared/chat/conversation/reply-preview.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/chat/conversation/search.tsx b/shared/chat/conversation/search.tsx index 20d9d78fa081..455b96ee6743 100644 --- a/shared/chat/conversation/search.tsx +++ b/shared/chat/conversation/search.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as Styles from '@/styles' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/delete-history-warning.tsx b/shared/chat/delete-history-warning.tsx index 1e748facdc92..47ffafd71431 100644 --- a/shared/chat/delete-history-warning.tsx +++ b/shared/chat/delete-history-warning.tsx @@ -1,6 +1,6 @@ import * as Kb from '@/common-adapters' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import MaybePopup from './maybe-popup' const DeleteHistoryWarning = () => { diff --git a/shared/chat/emoji-picker/container.tsx b/shared/chat/emoji-picker/container.tsx index 0c6b391630a7..34376fe70b98 100644 --- a/shared/chat/emoji-picker/container.tsx +++ b/shared/chat/emoji-picker/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/inbox-and-conversation-2.tsx b/shared/chat/inbox-and-conversation-2.tsx index 730766b62d5b..f0a13e01420a 100644 --- a/shared/chat/inbox-and-conversation-2.tsx +++ b/shared/chat/inbox-and-conversation-2.tsx @@ -1,6 +1,6 @@ // Just for desktop and tablet, we show inbox and conversation side by side import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' diff --git a/shared/chat/inbox-and-conversation-header.tsx b/shared/chat/inbox-and-conversation-header.tsx index b270d2a8afbf..46fba91a82b5 100644 --- a/shared/chat/inbox-and-conversation-header.tsx +++ b/shared/chat/inbox-and-conversation-header.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import type {StyleOverride} from '@/common-adapters/markdown' @@ -8,7 +8,7 @@ import NewChatButton from './inbox/new-chat-button' import {useRoute} from '@react-navigation/native' import type {RootRouteProps} from '@/router-v2/route-params' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import * as Teams from '@/stores/teams' const Header = () => { diff --git a/shared/chat/inbox-search/index.tsx b/shared/chat/inbox-search/index.tsx index 4c43a0afed33..823e2b970a33 100644 --- a/shared/chat/inbox-search/index.tsx +++ b/shared/chat/inbox-search/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/chat/inbox/container.tsx b/shared/chat/inbox/container.tsx index a8f303cc416c..210348d199d1 100644 --- a/shared/chat/inbox/container.tsx +++ b/shared/chat/inbox/container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as T from '@/constants/types' import Inbox, {type Props} from '.' diff --git a/shared/chat/inbox/filter-row.tsx b/shared/chat/inbox/filter-row.tsx index 8a5651be6445..1d7214f8b4c1 100644 --- a/shared/chat/inbox/filter-row.tsx +++ b/shared/chat/inbox/filter-row.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/inbox/index.native.tsx b/shared/chat/inbox/index.native.tsx index 3a33bbcbe653..41cafa1c706e 100644 --- a/shared/chat/inbox/index.native.tsx +++ b/shared/chat/inbox/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import * as RowSizes from './row/sizes' diff --git a/shared/chat/inbox/new-chat-button.tsx b/shared/chat/inbox/new-chat-button.tsx index e6987c1ddc92..bb086547ac38 100644 --- a/shared/chat/inbox/new-chat-button.tsx +++ b/shared/chat/inbox/new-chat-button.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/inbox/row/big-team-channel.tsx b/shared/chat/inbox/row/big-team-channel.tsx index 79a4e46f06f3..e4089507b3b3 100644 --- a/shared/chat/inbox/row/big-team-channel.tsx +++ b/shared/chat/inbox/row/big-team-channel.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import * as RowSizes from './sizes' diff --git a/shared/chat/inbox/row/big-team-header.tsx b/shared/chat/inbox/row/big-team-header.tsx index 2cd1b8d7d430..0fc4172f6497 100644 --- a/shared/chat/inbox/row/big-team-header.tsx +++ b/shared/chat/inbox/row/big-team-header.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as React from 'react' diff --git a/shared/chat/inbox/row/big-teams-divider.tsx b/shared/chat/inbox/row/big-teams-divider.tsx index 35fc6ab594b1..547f2e267670 100644 --- a/shared/chat/inbox/row/big-teams-divider.tsx +++ b/shared/chat/inbox/row/big-teams-divider.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as RowSizes from './sizes' diff --git a/shared/chat/inbox/row/opened-row-state.tsx b/shared/chat/inbox/row/opened-row-state.tsx index f32a8b91ce9a..29c1d4c415ff 100644 --- a/shared/chat/inbox/row/opened-row-state.tsx +++ b/shared/chat/inbox/row/opened-row-state.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Z from '@/util/zustand' import type * as T from '@/constants/types' diff --git a/shared/chat/inbox/row/small-team/bottom-line.tsx b/shared/chat/inbox/row/small-team/bottom-line.tsx index eccb3d94d2bb..1dfbc213d35e 100644 --- a/shared/chat/inbox/row/small-team/bottom-line.tsx +++ b/shared/chat/inbox/row/small-team/bottom-line.tsx @@ -1,10 +1,10 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {SnippetContext, SnippetDecorationContext} from './contexts' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { layoutSnippet?: string diff --git a/shared/chat/inbox/row/small-team/index.tsx b/shared/chat/inbox/row/small-team/index.tsx index 869aaa3a9957..f0289b126b34 100644 --- a/shared/chat/inbox/row/small-team/index.tsx +++ b/shared/chat/inbox/row/small-team/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import {SimpleTopLine} from './top-line' @@ -9,7 +9,7 @@ import * as RowSizes from '../sizes' import * as T from '@/constants/types' import SwipeConvActions from './swipe-conv-actions' import './small-team.css' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import { IsTeamContext, ParticipantsContext, diff --git a/shared/chat/inbox/row/small-team/swipe-conv-actions/index.native.tsx b/shared/chat/inbox/row/small-team/swipe-conv-actions/index.native.tsx index 5ec1de0c2ee2..94ff76ff16f9 100644 --- a/shared/chat/inbox/row/small-team/swipe-conv-actions/index.native.tsx +++ b/shared/chat/inbox/row/small-team/swipe-conv-actions/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import * as Reanimated from 'react-native-reanimated' diff --git a/shared/chat/inbox/row/small-team/top-line.tsx b/shared/chat/inbox/row/small-team/top-line.tsx index 86825d823584..3e45c439e679 100644 --- a/shared/chat/inbox/row/small-team/top-line.tsx +++ b/shared/chat/inbox/row/small-team/top-line.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import TeamMenu from '@/chat/conversation/info-panel/menu' diff --git a/shared/chat/inbox/row/teams-divider.tsx b/shared/chat/inbox/row/teams-divider.tsx index 282156d7da76..a45090ee43b3 100644 --- a/shared/chat/inbox/row/teams-divider.tsx +++ b/shared/chat/inbox/row/teams-divider.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/chat/inbox/search-row.tsx b/shared/chat/inbox/search-row.tsx index c97a2cc786bd..ceedb67615a9 100644 --- a/shared/chat/inbox/search-row.tsx +++ b/shared/chat/inbox/search-row.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import ChatFilterRow from './filter-row' import StartNewChat from './row/start-new-chat' diff --git a/shared/chat/new-team-dialog-container.tsx b/shared/chat/new-team-dialog-container.tsx index 020a22d35602..4c4d1864c28e 100644 --- a/shared/chat/new-team-dialog-container.tsx +++ b/shared/chat/new-team-dialog-container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {CreateNewTeam} from '../teams/new-team' import {useTeamsState} from '@/stores/teams' import upperFirst from 'lodash/upperFirst' diff --git a/shared/chat/payments/status/index.tsx b/shared/chat/payments/status/index.tsx index 3fe3ec65668b..05236a073498 100644 --- a/shared/chat/payments/status/index.tsx +++ b/shared/chat/payments/status/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as Styles from '@/styles' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import PaymentStatusError from './error' import Text from '@/common-adapters/text' import {Box2} from '@/common-adapters/box' @@ -9,7 +9,7 @@ import type * as T from '@/constants/types' import type {MeasureRef} from '@/common-adapters/measure-ref' import type * as WalletTypes from '@/constants/types/wallets' import {useOrdinal} from '@/chat/conversation/messages/ids-context' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' // This is actually a dependency of common-adapters/markdown so we have to treat it like a common-adapter, no * import allowed const Kb = { diff --git a/shared/chat/pdf/index.desktop.tsx b/shared/chat/pdf/index.desktop.tsx index 4e5c2f2b2b1b..6fcee8301fc1 100644 --- a/shared/chat/pdf/index.desktop.tsx +++ b/shared/chat/pdf/index.desktop.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import type {Props} from '.' diff --git a/shared/chat/pdf/index.native.tsx b/shared/chat/pdf/index.native.tsx index 044e8691e00b..8f6253a027d2 100644 --- a/shared/chat/pdf/index.native.tsx +++ b/shared/chat/pdf/index.native.tsx @@ -1,9 +1,9 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import type {Props} from '.' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const ChatPDF = (props: Props) => { const {ordinal, url} = props diff --git a/shared/chat/routes.tsx b/shared/chat/routes.tsx index b34bfe654bdd..d9dcd49db022 100644 --- a/shared/chat/routes.tsx +++ b/shared/chat/routes.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import chatNewChat from '../team-building/page' import {headerNavigationOptions} from './conversation/header-area' import inboxGetOptions from './inbox/get-options' diff --git a/shared/chat/selectable-big-team-channel-container.tsx b/shared/chat/selectable-big-team-channel-container.tsx index 19af38e9941a..35e0b58f9614 100644 --- a/shared/chat/selectable-big-team-channel-container.tsx +++ b/shared/chat/selectable-big-team-channel-container.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import SelectableBigTeamChannel from './selectable-big-team-channel' type OwnProps = { diff --git a/shared/chat/selectable-small-team-container.tsx b/shared/chat/selectable-small-team-container.tsx index 2248c71d3a05..0a1f5f44b24a 100644 --- a/shared/chat/selectable-small-team-container.tsx +++ b/shared/chat/selectable-small-team-container.tsx @@ -1,8 +1,8 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import type {AllowedColors} from '@/common-adapters/text' import SelectableSmallTeam from './selectable-small-team' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = { filter?: string diff --git a/shared/chat/send-to-chat/index.tsx b/shared/chat/send-to-chat/index.tsx index 237b70bfd797..0b6d8b22f634 100644 --- a/shared/chat/send-to-chat/index.tsx +++ b/shared/chat/send-to-chat/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as React from 'react' import * as Kb from '@/common-adapters' @@ -8,7 +8,7 @@ import ConversationList from './conversation-list/conversation-list' import ChooseConversation from './conversation-list/choose-conversation' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { canBack?: boolean diff --git a/shared/common-adapters/avatar/hooks.tsx b/shared/common-adapters/avatar/hooks.tsx index 81c492363e3e..c8412c6be4f7 100644 --- a/shared/common-adapters/avatar/hooks.tsx +++ b/shared/common-adapters/avatar/hooks.tsx @@ -1,5 +1,5 @@ // High level avatar class. Handdles converting from usernames to urls. Deals with testing mode. -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as React from 'react' import {iconTypeToImgSet, urlsToImgSet, urlsToSrcSet, urlsToBaseSrc, type IconType} from '../icon' import * as Styles from '@/styles' diff --git a/shared/common-adapters/copy-text.tsx b/shared/common-adapters/copy-text.tsx index 7942082307fb..505513bd6efd 100644 --- a/shared/common-adapters/copy-text.tsx +++ b/shared/common-adapters/copy-text.tsx @@ -8,7 +8,7 @@ import {useTimeout} from './use-timers' import * as Styles from '@/styles' import logger from '@/logger' import type {MeasureRef} from './measure-ref' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const Kb = { Box2Measure, diff --git a/shared/common-adapters/markdown/channel.tsx b/shared/common-adapters/markdown/channel.tsx index 55a2dc3d237e..a80546942696 100644 --- a/shared/common-adapters/markdown/channel.tsx +++ b/shared/common-adapters/markdown/channel.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import type * as T from '@/constants/types' import Text, {type StylesTextCrossPlatform} from '../text' import * as React from 'react' diff --git a/shared/common-adapters/markdown/maybe-mention/index.tsx b/shared/common-adapters/markdown/maybe-mention/index.tsx index 33431631f674..86bbe6a0a396 100644 --- a/shared/common-adapters/markdown/maybe-mention/index.tsx +++ b/shared/common-adapters/markdown/maybe-mention/index.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import Text, {type StylesTextCrossPlatform} from '@/common-adapters/text' import Mention from '../../mention-container' diff --git a/shared/common-adapters/markdown/maybe-mention/team.tsx b/shared/common-adapters/markdown/maybe-mention/team.tsx index b15fb1a8b7aa..e9b7f234f06b 100644 --- a/shared/common-adapters/markdown/maybe-mention/team.tsx +++ b/shared/common-adapters/markdown/maybe-mention/team.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import {useTeamsState} from '@/stores/teams' import * as React from 'react' diff --git a/shared/common-adapters/mention-container.tsx b/shared/common-adapters/mention-container.tsx index df61a99dffcf..8c675e935840 100644 --- a/shared/common-adapters/mention-container.tsx +++ b/shared/common-adapters/mention-container.tsx @@ -1,10 +1,10 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import Mention, {type OwnProps} from './mention' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const Container = (ownProps: OwnProps) => { let {username} = ownProps diff --git a/shared/common-adapters/mention.tsx b/shared/common-adapters/mention.tsx index 468c66b4297e..973ec7212085 100644 --- a/shared/common-adapters/mention.tsx +++ b/shared/common-adapters/mention.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Styles from '@/styles' import {WithProfileCardPopup} from './profile-card' import Text from './text' diff --git a/shared/common-adapters/profile-card.tsx b/shared/common-adapters/profile-card.tsx index 4b5c1fa9b9f4..19cea7b4493d 100644 --- a/shared/common-adapters/profile-card.tsx +++ b/shared/common-adapters/profile-card.tsx @@ -14,7 +14,7 @@ import Icon from './icon' import Meta from './meta' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import ProgressIndicator from './progress-indicator' import Text from './text' import WithTooltip from './with-tooltip' diff --git a/shared/common-adapters/reload.tsx b/shared/common-adapters/reload.tsx index a3e150277db7..08fe71c05cd7 100644 --- a/shared/common-adapters/reload.tsx +++ b/shared/common-adapters/reload.tsx @@ -10,7 +10,7 @@ import Button from './button' import Icon from './icon' import type {RPCError} from '@/util/errors' import {settingsFeedbackTab} from '@/constants/settings/util' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const Kb = { Box2, diff --git a/shared/common-adapters/usernames.tsx b/shared/common-adapters/usernames.tsx index ac58d81649a5..1b0047cc96f0 100644 --- a/shared/common-adapters/usernames.tsx +++ b/shared/common-adapters/usernames.tsx @@ -16,7 +16,7 @@ import {useTrackerState} from '@/stores/tracker2' import {useUsersState} from '@/stores/users' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export type User = { username: string diff --git a/shared/common-adapters/wave-button.tsx b/shared/common-adapters/wave-button.tsx index 40a33f359a66..63a8ab05699a 100644 --- a/shared/common-adapters/wave-button.tsx +++ b/shared/common-adapters/wave-button.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {Box2, Box} from './box' import Icon from './icon' diff --git a/shared/constants/chat2/debug.tsx b/shared/constants/chat2/debug.tsx index ba94fb89a7f8..e91c336a2aca 100644 --- a/shared/constants/chat2/debug.tsx +++ b/shared/constants/chat2/debug.tsx @@ -1,5 +1,5 @@ // Debug utilities for chat -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import type * as T from '@/constants/types' import logger from '@/logger' diff --git a/shared/constants/chat2/util.tsx b/shared/constants/chat2/util.tsx index a1e5b2c74fc6..e69de29bb2d1 100644 --- a/shared/constants/chat2/util.tsx +++ b/shared/constants/chat2/util.tsx @@ -1,61 +0,0 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import * as EngineGen from '@/actions/engine-gen-gen' -import {storeRegistry} from '../store-registry' - -export const onEngineConnected = () => { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterChatUIRpcPromise() - await T.RPCGen.delegateUiCtlRegisterLogUIRpcPromise() - console.log('Registered Chat UI') - } catch (error) { - console.warn('Error in registering Chat UI:', error) - } - } - ignorePromise(f()) -} - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.chat1ChatUiChatInboxFailed: - case EngineGen.chat1NotifyChatChatSetConvSettings: - case EngineGen.chat1NotifyChatChatAttachmentUploadStart: - case EngineGen.chat1NotifyChatChatPromptUnfurl: - case EngineGen.chat1NotifyChatChatPaymentInfo: - case EngineGen.chat1NotifyChatChatRequestInfo: - case EngineGen.chat1NotifyChatChatAttachmentDownloadProgress: - case EngineGen.chat1NotifyChatChatAttachmentDownloadComplete: - case EngineGen.chat1NotifyChatChatAttachmentUploadProgress: - case EngineGen.chat1ChatUiChatCommandMarkdown: - case EngineGen.chat1ChatUiChatGiphyToggleResultWindow: - case EngineGen.chat1ChatUiChatCommandStatus: - case EngineGen.chat1ChatUiChatBotCommandsUpdateStatus: - case EngineGen.chat1ChatUiChatGiphySearchResults: - case EngineGen.chat1NotifyChatChatParticipantsInfo: - case EngineGen.chat1ChatUiChatMaybeMentionUpdate: - case EngineGen.chat1NotifyChatChatConvUpdate: - case EngineGen.chat1ChatUiChatCoinFlipStatus: - case EngineGen.chat1NotifyChatChatThreadsStale: - case EngineGen.chat1NotifyChatChatSubteamRename: - case EngineGen.chat1NotifyChatChatTLFFinalize: - case EngineGen.chat1NotifyChatChatIdentifyUpdate: - case EngineGen.chat1ChatUiChatInboxUnverified: - case EngineGen.chat1NotifyChatChatInboxSyncStarted: - case EngineGen.chat1NotifyChatChatInboxSynced: - case EngineGen.chat1ChatUiChatInboxLayout: - case EngineGen.chat1NotifyChatChatInboxStale: - case EngineGen.chat1ChatUiChatInboxConversation: - case EngineGen.chat1NotifyChatNewChatActivity: - case EngineGen.chat1NotifyChatChatTypingUpdate: - case EngineGen.chat1NotifyChatChatSetConvRetention: - case EngineGen.chat1NotifyChatChatSetTeamRetention: - case EngineGen.keybase1NotifyBadgesBadgeState: - case EngineGen.keybase1GregorUIPushState: - { - storeRegistry.getState('chat').dispatch.onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index fd441716a161..fb84d14da42e 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -8,9 +8,9 @@ import type * as UseAutoResetStateType from '@/stores/autoreset' import type * as UseDevicesStateType from '@/stores/devices' import * as AvatarUtil from '@/common-adapters/avatar/util' import type * as UseBotsStateType from '@/stores/bots' -import {useChatState} from '../chat2' -import {getSelectedConversation} from '../chat2/common' -import * as ChatUtil from '../chat2/util' +import {useChatState} from '@/stores/chat2' +import {getSelectedConversation} from '@/constants/chat2/common' +import type * as UseChatStateType from '@/stores/chat2' import {useConfigState} from '../config' import {useCurrentUserState} from '../current-user' import {useDaemonState} from '../daemon' @@ -39,7 +39,18 @@ let _devicesLoaded = false let _gitLoaded = false export const onEngineConnected = () => { - ChatUtil.onEngineConnected() + { // Chat2 + const f = async () => { + try { + await T.RPCGen.delegateUiCtlRegisterChatUIRpcPromise() + await T.RPCGen.delegateUiCtlRegisterLogUIRpcPromise() + console.log('Registered Chat UI') + } catch (error) { + console.warn('Error in registering Chat UI:', error) + } + } + ignorePromise(f()) + } useConfigState.getState().dispatch.onEngineConnected() storeRegistry.getState('daemon').dispatch.startHandshake() { @@ -371,6 +382,9 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { const {useTeamsState} = require('@/stores/teams') as typeof UseTeamsStateType useTeamsState.getState().dispatch.onEngineIncomingImpl(action) + + const {useChatState} = require('@/stores/chat2') as typeof UseChatStateType + useChatState.getState().dispatch.onEngineIncomingImpl(action) } break case EngineGen.chat1ChatUiChatShowManageChannels: @@ -446,10 +460,46 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { storeRegistry.getState('settings-email').dispatch.notifyEmailAddressEmailsChanged(list) break } + case EngineGen.chat1ChatUiChatInboxFailed: + case EngineGen.chat1NotifyChatChatSetConvSettings: + case EngineGen.chat1NotifyChatChatAttachmentUploadStart: + case EngineGen.chat1NotifyChatChatPromptUnfurl: + case EngineGen.chat1NotifyChatChatPaymentInfo: + case EngineGen.chat1NotifyChatChatRequestInfo: + case EngineGen.chat1NotifyChatChatAttachmentDownloadProgress: + case EngineGen.chat1NotifyChatChatAttachmentDownloadComplete: + case EngineGen.chat1NotifyChatChatAttachmentUploadProgress: + case EngineGen.chat1ChatUiChatCommandMarkdown: + case EngineGen.chat1ChatUiChatGiphyToggleResultWindow: + case EngineGen.chat1ChatUiChatCommandStatus: + case EngineGen.chat1ChatUiChatBotCommandsUpdateStatus: + case EngineGen.chat1ChatUiChatGiphySearchResults: + case EngineGen.chat1NotifyChatChatParticipantsInfo: + case EngineGen.chat1ChatUiChatMaybeMentionUpdate: + case EngineGen.chat1NotifyChatChatConvUpdate: + case EngineGen.chat1ChatUiChatCoinFlipStatus: + case EngineGen.chat1NotifyChatChatThreadsStale: + case EngineGen.chat1NotifyChatChatSubteamRename: + case EngineGen.chat1NotifyChatChatTLFFinalize: + case EngineGen.chat1NotifyChatChatIdentifyUpdate: + case EngineGen.chat1ChatUiChatInboxUnverified: + case EngineGen.chat1NotifyChatChatInboxSyncStarted: + case EngineGen.chat1NotifyChatChatInboxSynced: + case EngineGen.chat1ChatUiChatInboxLayout: + case EngineGen.chat1NotifyChatChatInboxStale: + case EngineGen.chat1ChatUiChatInboxConversation: + case EngineGen.chat1NotifyChatNewChatActivity: + case EngineGen.chat1NotifyChatChatTypingUpdate: + case EngineGen.chat1NotifyChatChatSetConvRetention: + case EngineGen.chat1NotifyChatChatSetTeamRetention: + { + const {useChatState} = require('@/stores/chat2') as typeof UseChatStateType + useChatState.getState().dispatch.onEngineIncomingImpl(action) + } + break default: } AvatarUtil.onEngineIncoming(action) - ChatUtil.onEngineIncoming(action) useConfigState.getState().dispatch.onEngineIncoming(action) DeepLinksUtil.onEngineIncoming(action) switch (action.type) { diff --git a/shared/constants/platform-specific/kbfs-notifications.tsx b/shared/constants/platform-specific/kbfs-notifications.tsx index 6d5b97e4a18b..1ee3f17113f6 100644 --- a/shared/constants/platform-specific/kbfs-notifications.tsx +++ b/shared/constants/platform-specific/kbfs-notifications.tsx @@ -1,5 +1,5 @@ import {pathSep} from '@/constants/platform' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import capitalize from 'lodash/capitalize' import * as T from '@/constants/types' import {parseFolderNameToUsers} from '@/util/kbfs' diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 4188828f0e4f..1b81f0472643 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -6,7 +6,7 @@ import type * as ConvoStateType from '@/constants/chat2/convostate' import type {ConvoState} from '@/constants/chat2/convostate' import type {State as AutoResetState, useAutoResetState} from '@/stores/autoreset' import type {State as BotsState, useBotsState} from '@/stores/bots' -import type {State as ChatState, useChatState} from '@/constants/chat2' +import type {State as ChatState, useChatState} from '@/stores/chat2' import type {State as DaemonState, useDaemonState} from '@/constants/daemon' import type {State as DevicesState, useDevicesState} from '@/stores/devices' import type {State as FSState, useFSState} from '@/stores/fs' @@ -125,7 +125,7 @@ class StoreRegistry { return useBotsState } case 'chat': { - const {useChatState} = require('@/constants/chat2') + const {useChatState} = require('@/stores/chat2') return useChatState } case 'daemon': { diff --git a/shared/crypto/input.tsx b/shared/crypto/input.tsx index 63039da7272d..2a04e94765a3 100644 --- a/shared/crypto/input.tsx +++ b/shared/crypto/input.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as React from 'react' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' diff --git a/shared/crypto/operations/decrypt.tsx b/shared/crypto/operations/decrypt.tsx index 4f553f9e7b06..61060317259c 100644 --- a/shared/crypto/operations/decrypt.tsx +++ b/shared/crypto/operations/decrypt.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as Kb from '@/common-adapters' import * as React from 'react' import {Input, DragAndDrop, InputActionsBar, OperationBanner} from '../input' diff --git a/shared/crypto/operations/encrypt.tsx b/shared/crypto/operations/encrypt.tsx index 856c4b40cb0c..7be3f776cec8 100644 --- a/shared/crypto/operations/encrypt.tsx +++ b/shared/crypto/operations/encrypt.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as Kb from '@/common-adapters' import * as React from 'react' import Recipients from '../recipients' diff --git a/shared/crypto/operations/sign.tsx b/shared/crypto/operations/sign.tsx index 5ec68a46802e..7b0267c7f2a5 100644 --- a/shared/crypto/operations/sign.tsx +++ b/shared/crypto/operations/sign.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as React from 'react' import * as Kb from '@/common-adapters' import openURL from '@/util/open-url' diff --git a/shared/crypto/operations/verify.tsx b/shared/crypto/operations/verify.tsx index 3b64988b45a3..56decc162d9d 100644 --- a/shared/crypto/operations/verify.tsx +++ b/shared/crypto/operations/verify.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as Kb from '@/common-adapters' import * as React from 'react' import {Input, InputActionsBar, DragAndDrop, OperationBanner} from '../input' diff --git a/shared/crypto/output.tsx b/shared/crypto/output.tsx index a1884597be7c..ca6efb87d482 100644 --- a/shared/crypto/output.tsx +++ b/shared/crypto/output.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import * as Crypto from '@/constants/crypto' +import * as Chat from '@/stores/chat2' +import * as Crypto from '@/stores/crypto' import * as Kb from '@/common-adapters' import * as Path from '@/util/path' import * as React from 'react' @@ -10,7 +10,7 @@ import {pickFiles} from '@/util/pick-files' import type HiddenString from '@/util/hidden-string' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' type OutputProps = {operation: T.Crypto.Operations} type OutputActionsBarProps = {operation: T.Crypto.Operations} diff --git a/shared/crypto/recipients.tsx b/shared/crypto/recipients.tsx index a4ad222b2a2d..a7ac327df09f 100644 --- a/shared/crypto/recipients.tsx +++ b/shared/crypto/recipients.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as Kb from '@/common-adapters' const placeholder = 'Search people' diff --git a/shared/crypto/sub-nav/index.desktop.tsx b/shared/crypto/sub-nav/index.desktop.tsx index 7cd6cdfdd883..47e4b97a6486 100644 --- a/shared/crypto/sub-nav/index.desktop.tsx +++ b/shared/crypto/sub-nav/index.desktop.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as Kb from '@/common-adapters' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as Common from '@/router-v2/common.desktop' import LeftNav from './left-nav.desktop' import { diff --git a/shared/crypto/sub-nav/index.native.tsx b/shared/crypto/sub-nav/index.native.tsx index c41261148096..f2ee824bec3b 100644 --- a/shared/crypto/sub-nav/index.native.tsx +++ b/shared/crypto/sub-nav/index.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import * as Kb from '@/common-adapters' import NavRow from './nav-row' diff --git a/shared/crypto/sub-nav/left-nav.desktop.tsx b/shared/crypto/sub-nav/left-nav.desktop.tsx index e44a26459acd..5dc1b78e412a 100644 --- a/shared/crypto/sub-nav/left-nav.desktop.tsx +++ b/shared/crypto/sub-nav/left-nav.desktop.tsx @@ -1,6 +1,6 @@ import type * as React from 'react' import * as Kb from '@/common-adapters' -import * as Crypto from '@/constants/crypto' +import * as Crypto from '@/stores/crypto' import NavRow from './nav-row' type Row = (typeof Crypto.Tabs)[number] & { diff --git a/shared/desktop/remote/use-serialize-props.desktop.tsx b/shared/desktop/remote/use-serialize-props.desktop.tsx index 4bd25aacfdf1..3327ea8f6428 100644 --- a/shared/desktop/remote/use-serialize-props.desktop.tsx +++ b/shared/desktop/remote/use-serialize-props.desktop.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import * as C from '@/constants' import KB2 from '@/util/electron.desktop' import isEqual from 'lodash/isEqual' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const {rendererNewProps} = KB2.functions diff --git a/shared/desktop/renderer/main2.desktop.tsx b/shared/desktop/renderer/main2.desktop.tsx index 03b89cecfe96..141518adb2a8 100644 --- a/shared/desktop/renderer/main2.desktop.tsx +++ b/shared/desktop/renderer/main2.desktop.tsx @@ -12,7 +12,7 @@ import {initDesktopStyles} from '@/styles/index.desktop' import {isWindows} from '@/constants/platform' import KB2 from '@/util/electron.desktop' import {ignorePromise} from '@/constants/utils' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import {usePinentryState} from '@/stores/pinentry' import * as T from '@/constants/types' import {RPCError} from '@/util/errors' diff --git a/shared/devices/device-revoke.tsx b/shared/devices/device-revoke.tsx index 71dd2af936dc..90e0850a35fe 100644 --- a/shared/devices/device-revoke.tsx +++ b/shared/devices/device-revoke.tsx @@ -1,11 +1,11 @@ import * as C from '@/constants' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import * as React from 'react' import * as T from '@/constants/types' import {settingsDevicesTab} from '@/stores/settings' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {deviceID: string} diff --git a/shared/fs/browser/root.tsx b/shared/fs/browser/root.tsx index caf3b4743a8c..1a1cef90548c 100644 --- a/shared/fs/browser/root.tsx +++ b/shared/fs/browser/root.tsx @@ -7,7 +7,7 @@ import SfmiBanner from '../banner/system-file-manager-integration-banner/contain import {WrapRow} from './rows/rows' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { destinationPickerIndex?: number diff --git a/shared/fs/browser/rows/rows-container.tsx b/shared/fs/browser/rows/rows-container.tsx index 079d1134f007..37019066d45d 100644 --- a/shared/fs/browser/rows/rows-container.tsx +++ b/shared/fs/browser/rows/rows-container.tsx @@ -6,7 +6,7 @@ import Rows, {type Props} from './rows' import {asRows as topBarAsRow} from '../../top-bar' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = { path: T.FS.Path // path to the parent folder containering the rows, diff --git a/shared/fs/browser/rows/tlf.tsx b/shared/fs/browser/rows/tlf.tsx index 90621b34fb64..1092deddbaff 100644 --- a/shared/fs/browser/rows/tlf.tsx +++ b/shared/fs/browser/rows/tlf.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import {useFsPathMetadata, TlfInfoLine, Filename} from '@/fs/common' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export type OwnProps = { destinationPickerIndex?: number diff --git a/shared/fs/common/path-item-action/menu-container.tsx b/shared/fs/common/path-item-action/menu-container.tsx index e3874afe76d1..9a7e2f751dd5 100644 --- a/shared/fs/common/path-item-action/menu-container.tsx +++ b/shared/fs/common/path-item-action/menu-container.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Kbfs from '@/fs/common/hooks' import * as React from 'react' @@ -10,7 +10,7 @@ import type {FloatingMenuProps} from './types' import {getRootLayout, getShareLayout} from './layout' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = { floatingMenuProps: FloatingMenuProps diff --git a/shared/fs/common/tlf-info-line-container.tsx b/shared/fs/common/tlf-info-line-container.tsx index aa8f257a9e9b..09803b935e53 100644 --- a/shared/fs/common/tlf-info-line-container.tsx +++ b/shared/fs/common/tlf-info-line-container.tsx @@ -2,7 +2,7 @@ import * as T from '@/constants/types' import TlfInfoLine from './tlf-info-line' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export type OwnProps = { path: T.FS.Path diff --git a/shared/fs/filepreview/view.tsx b/shared/fs/filepreview/view.tsx index db96179f7e08..aad5f4757683 100644 --- a/shared/fs/filepreview/view.tsx +++ b/shared/fs/filepreview/view.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as T from '@/constants/types' import DefaultView from './default-view' diff --git a/shared/fs/nav-header/main-banner.tsx b/shared/fs/nav-header/main-banner.tsx index af0b4e87a394..4c24a1390ca4 100644 --- a/shared/fs/nav-header/main-banner.tsx +++ b/shared/fs/nav-header/main-banner.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as FS from '@/stores/fs' import {useFSState} from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { onRetry: () => void diff --git a/shared/git/row.tsx b/shared/git/row.tsx index 9a5ad0da18be..7151506dfb61 100644 --- a/shared/git/row.tsx +++ b/shared/git/row.tsx @@ -7,7 +7,7 @@ import * as React from 'react' import openURL from '@/util/open-url' import {useTrackerState} from '@/stores/tracker2' import * as FS from '@/stores/fs' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export const NewContext = React.createContext>(new Set()) diff --git a/shared/incoming-share/index.tsx b/shared/incoming-share/index.tsx index aa272f32fe90..331def063e5f 100644 --- a/shared/incoming-share/index.tsx +++ b/shared/incoming-share/index.tsx @@ -7,7 +7,7 @@ import {MobileSendToChat} from '../chat/send-to-chat' import {settingsFeedbackTab} from '@/stores/settings' import * as FS from '@/stores/fs' import {useFSState} from '@/stores/fs' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' export const OriginalOrCompressedButton = ({incomingShareItems}: IncomingShareProps) => { const originalTotalSize = incomingShareItems.reduce((bytes, item) => bytes + (item.originalSize ?? 0), 0) diff --git a/shared/login/index.tsx b/shared/login/index.tsx index cd680fd69a09..2a7438c66031 100644 --- a/shared/login/index.tsx +++ b/shared/login/index.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import {useDaemonState} from '@/constants/daemon' const Loading = React.lazy(async () => import('./loading')) diff --git a/shared/login/join-or-login.tsx b/shared/login/join-or-login.tsx index db53e45b736d..ee69bdb4de4d 100644 --- a/shared/login/join-or-login.tsx +++ b/shared/login/join-or-login.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as Kb from '@/common-adapters' import {InfoIcon} from '@/signup/common' import {useSignupState} from '@/stores/signup' diff --git a/shared/login/recover-password/error-modal.tsx b/shared/login/recover-password/error-modal.tsx index efe62179c6c4..0f44820649be 100644 --- a/shared/login/recover-password/error-modal.tsx +++ b/shared/login/recover-password/error-modal.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import {useState as useRecoverState} from '@/constants/recover-password' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const styles = Kb.Styles.styleSheetCreate(() => ({ padding: { diff --git a/shared/login/recover-password/error.tsx b/shared/login/recover-password/error.tsx index 789cbf323102..c1a9f000880e 100644 --- a/shared/login/recover-password/error.tsx +++ b/shared/login/recover-password/error.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import type {ButtonType} from '@/common-adapters/button' import {SignupScreen} from '@/signup/common' import {useState as useRecoverState} from '@/constants/recover-password' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const ConnectedError = () => { const loggedIn = useConfigState(s => s.loggedIn) diff --git a/shared/login/relogin/container.tsx b/shared/login/relogin/container.tsx index ca30787bccfb..9bd1741e3450 100644 --- a/shared/login/relogin/container.tsx +++ b/shared/login/relogin/container.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as React from 'react' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import Login from '.' import sortBy from 'lodash/sortBy' import {useState as useRecoverState} from '@/constants/recover-password' diff --git a/shared/menubar/chat-container.desktop.tsx b/shared/menubar/chat-container.desktop.tsx index e00fdc6bc561..6bcff1bb9438 100644 --- a/shared/menubar/chat-container.desktop.tsx +++ b/shared/menubar/chat-container.desktop.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as R from '@/constants/remote' import * as RemoteGen from '../actions/remote-gen' import * as Kb from '@/common-adapters' diff --git a/shared/menubar/files-container.desktop.tsx b/shared/menubar/files-container.desktop.tsx index 773a166b515b..e1b20cc9f284 100644 --- a/shared/menubar/files-container.desktop.tsx +++ b/shared/menubar/files-container.desktop.tsx @@ -6,7 +6,7 @@ import * as FsUtil from '@/util/kbfs' import * as TimestampUtil from '@/util/timestamp' import {FilesPreview} from './files.desktop' import type {DeserializeProps} from './remote-serializer.desktop' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const FilesContainer = (p: Pick) => { const {remoteTlfUpdates} = p diff --git a/shared/menubar/remote-container.desktop.tsx b/shared/menubar/remote-container.desktop.tsx index 001fc9fe53ca..129fda71de8c 100644 --- a/shared/menubar/remote-container.desktop.tsx +++ b/shared/menubar/remote-container.desktop.tsx @@ -1,12 +1,12 @@ import * as React from 'react' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import Menubar from './index.desktop' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import type {DeserializeProps} from './remote-serializer.desktop' import {useAvatarState} from '@/common-adapters/avatar/store' import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '@/constants/daemon' import {useDarkModeState} from '@/constants/darkmode' diff --git a/shared/menubar/remote-proxy.desktop.tsx b/shared/menubar/remote-proxy.desktop.tsx index 0ca7183325c0..d5f3d343e5b6 100644 --- a/shared/menubar/remote-proxy.desktop.tsx +++ b/shared/menubar/remote-proxy.desktop.tsx @@ -1,7 +1,7 @@ // A mirror of the remote menubar windows. import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import {useConfigState} from '@/constants/config' +import * as Chat from '@/stores/chat2' +import {useConfigState} from '@/stores/config' import * as T from '@/constants/types' import * as React from 'react' import KB2 from '@/util/electron.desktop' @@ -17,7 +17,7 @@ import {useFSState} from '@/stores/fs' import {useFollowerState} from '@/stores/followers' import {useUsersState} from '@/stores/users' import {useNotifState} from '@/stores/notifications' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '@/constants/daemon' import {useDarkModeState} from '@/constants/darkmode' diff --git a/shared/people/announcement.tsx b/shared/people/announcement.tsx index 00f360c95fe3..8e44e7145ec9 100644 --- a/shared/people/announcement.tsx +++ b/shared/people/announcement.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import openURL from '@/util/open-url' import * as Kb from '@/common-adapters' diff --git a/shared/people/container.tsx b/shared/people/container.tsx index 1c97cebe18d3..a1690a728896 100644 --- a/shared/people/container.tsx +++ b/shared/people/container.tsx @@ -5,7 +5,7 @@ import People from '.' import {useSignupState} from '@/stores/signup' import {useProfileState} from '@/constants/profile' import {usePeopleState, getPeopleDataWaitingKey} from '@/stores/people' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const waitToRefresh = 1000 * 60 * 5 diff --git a/shared/people/routes.tsx b/shared/people/routes.tsx index 1a73b36b39b9..f6c42a6f7051 100644 --- a/shared/people/routes.tsx +++ b/shared/people/routes.tsx @@ -3,7 +3,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import peopleTeamBuilder from '../team-building/page' import ProfileSearch from '../profile/search' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const HeaderAvatar = () => { const myUsername = useCurrentUserState(s => s.username) diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index 63d1a752cac9..d69b09886fe1 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -12,7 +12,7 @@ import {settingsAccountTab, settingsGitTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {usePeopleState, todoTypes} from '@/stores/people' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type TodoOwnProps = { badged: boolean diff --git a/shared/profile/edit-profile.tsx b/shared/profile/edit-profile.tsx index 326ee790dcda..8559024e31c8 100644 --- a/shared/profile/edit-profile.tsx +++ b/shared/profile/edit-profile.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const Container = () => { const username = useCurrentUserState(s => s.username) diff --git a/shared/profile/post-proof.tsx b/shared/profile/post-proof.tsx index ddcc5b7e3b1c..37fb56c5b665 100644 --- a/shared/profile/post-proof.tsx +++ b/shared/profile/post-proof.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import {subtitle} from '@/util/platforms' import openUrl from '@/util/open-url' import Modal from './modal' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const Container = () => { const platform = useProfileState(s => s.platform) diff --git a/shared/profile/showcase-team-offer.tsx b/shared/profile/showcase-team-offer.tsx index 1d90c173e5f5..12c43db82598 100644 --- a/shared/profile/showcase-team-offer.tsx +++ b/shared/profile/showcase-team-offer.tsx @@ -4,7 +4,7 @@ import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import {useTeamsSubscribe} from '@/teams/subscriber' import {useTrackerState} from '@/stores/tracker2' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const Container = () => { const waiting = C.useWaitingState(s => s.counts) diff --git a/shared/profile/user/actions/index.tsx b/shared/profile/user/actions/index.tsx index 0ef3cce3d788..ff79f621c55e 100644 --- a/shared/profile/user/actions/index.tsx +++ b/shared/profile/user/actions/index.tsx @@ -8,7 +8,7 @@ import {useBotsState} from '@/stores/bots' import {useTrackerState} from '@/stores/tracker2' import * as FS from '@/stores/fs' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {username: string} diff --git a/shared/profile/user/hooks.tsx b/shared/profile/user/hooks.tsx index bb8fa6253cb2..520cc3dae804 100644 --- a/shared/profile/user/hooks.tsx +++ b/shared/profile/user/hooks.tsx @@ -5,7 +5,7 @@ import {useColorScheme} from 'react-native' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const headerBackgroundColorType = ( state: T.Tracker.DetailsState, diff --git a/shared/profile/user/teams/index.tsx b/shared/profile/user/teams/index.tsx index 95b12320ca95..f78cfca43e24 100644 --- a/shared/profile/user/teams/index.tsx +++ b/shared/profile/user/teams/index.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import OpenMeta from './openmeta' import {default as TeamInfo, type Props as TIProps} from './teaminfo' import {useTrackerState} from '@/stores/tracker2' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = {username: string} diff --git a/shared/provision/code-page/container.tsx b/shared/provision/code-page/container.tsx index 6b0e80c52254..9c4d0e26d2ed 100644 --- a/shared/provision/code-page/container.tsx +++ b/shared/provision/code-page/container.tsx @@ -6,7 +6,7 @@ import QRImage from './qr-image' import QRScan from './qr-scan' import Troubleshooting from '../troubleshooting' import type * as T from '@/constants/types' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {type Device, useProvisionState} from '@/constants/provision' const CodePageContainer = () => { diff --git a/shared/provision/code-page/qr-scan/not-authorized.tsx b/shared/provision/code-page/qr-scan/not-authorized.tsx index ee5774db4a22..35f641e2827a 100644 --- a/shared/provision/code-page/qr-scan/not-authorized.tsx +++ b/shared/provision/code-page/qr-scan/not-authorized.tsx @@ -1,5 +1,5 @@ import * as Kb from '@/common-adapters' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const QRScanNotAuthorized = () => { const onOpenSettings = useConfigState(s => s.dispatch.dynamic.openAppSettings) diff --git a/shared/router-v2/account-switcher/index.tsx b/shared/router-v2/account-switcher/index.tsx index 66b81ffb43a8..4ff98df6a83e 100644 --- a/shared/router-v2/account-switcher/index.tsx +++ b/shared/router-v2/account-switcher/index.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import './account-switcher.css' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' @@ -8,7 +8,7 @@ import {settingsLogOutTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useProvisionState} from '@/constants/provision' const prepareAccountRows = ( diff --git a/shared/router-v2/header/index.desktop.tsx b/shared/router-v2/header/index.desktop.tsx index 2a46eb9be1c3..892c4fbde2a4 100644 --- a/shared/router-v2/header/index.desktop.tsx +++ b/shared/router-v2/header/index.desktop.tsx @@ -6,7 +6,7 @@ import {IconWithPopupDesktop as WhatsNewIconWithPopup} from '@/whats-new/icon' import * as ReactIs from 'react-is' import KB2 from '@/util/electron.desktop' import shallowEqual from 'shallowequal' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const {closeWindow, minimizeWindow, toggleMaximizeWindow} = KB2.functions diff --git a/shared/router-v2/hooks.native.tsx b/shared/router-v2/hooks.native.tsx index bce95fef44e4..ade3784a1414 100644 --- a/shared/router-v2/hooks.native.tsx +++ b/shared/router-v2/hooks.native.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import {useConfigState} from '@/constants/config' +import * as Chat from '@/stores/chat2' +import {useConfigState} from '@/stores/config' import * as Tabs from '@/constants/tabs' import * as React from 'react' import {handleAppLink} from '@/constants/deeplinks' diff --git a/shared/router-v2/router.desktop.tsx b/shared/router-v2/router.desktop.tsx index 3173b32abf55..025c049ab445 100644 --- a/shared/router-v2/router.desktop.tsx +++ b/shared/router-v2/router.desktop.tsx @@ -1,6 +1,6 @@ import * as Common from './common.desktop' import * as C from '@/constants' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as Kb from '@/common-adapters' import * as React from 'react' import * as Shared from './router.shared' @@ -15,7 +15,7 @@ import {createNativeStackNavigator} from '@react-navigation/native-stack' import {modalRoutes, routes, loggedOutRoutes, tabRoots} from './routes' import {registerDebugClear} from '@/util/debug' import type {RootParamList} from '@/router-v2/route-params' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '@/constants/daemon' import type {NativeStackNavigationOptions} from '@react-navigation/native-stack' import './router.css' diff --git a/shared/router-v2/router.native.tsx b/shared/router-v2/router.native.tsx index f807285c2920..a5e3339fd990 100644 --- a/shared/router-v2/router.native.tsx +++ b/shared/router-v2/router.native.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Constants from '@/constants/router2' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import {useDarkModeState} from '@/constants/darkmode' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/router-v2/tab-bar.desktop.tsx b/shared/router-v2/tab-bar.desktop.tsx index 13591ffa5b87..02fac7c03183 100644 --- a/shared/router-v2/tab-bar.desktop.tsx +++ b/shared/router-v2/tab-bar.desktop.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as Kbfs from '@/fs/common' import * as Platforms from '@/constants/platform' import * as T from '@/constants/types' @@ -18,7 +18,7 @@ import {useTrackerState} from '@/stores/tracker2' import {useFSState} from '@/stores/fs' import {useProfileState} from '@/constants/profile' import {useNotifState} from '@/stores/notifications' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useProvisionState} from '@/constants/provision' const {hideWindow, ctlQuit} = KB2.functions diff --git a/shared/settings/advanced.tsx b/shared/settings/advanced.tsx index a19b5e870d9e..b5a0027f546d 100644 --- a/shared/settings/advanced.tsx +++ b/shared/settings/advanced.tsx @@ -6,7 +6,7 @@ import {ProxySettings} from './proxy' import {useSettingsState, traceInProgressKey, processorProfileInProgressKey} from '@/stores/settings' import {usePWState} from '@/constants/settings-password' import {useFSState} from '@/stores/fs' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' let initialUseNativeFrame: boolean | undefined diff --git a/shared/settings/archive/modal.tsx b/shared/settings/archive/modal.tsx index dc236ceadc17..fad4d4c0141b 100644 --- a/shared/settings/archive/modal.tsx +++ b/shared/settings/archive/modal.tsx @@ -6,7 +6,7 @@ import {pickSave} from '@/util/pick-files' import * as FsCommon from '@/fs/common' import {useArchiveState} from '@/stores/archive' import {settingsArchiveTab} from '@/stores/settings' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {getConvoState} from '@/constants/chat2/convostate' type Props = diff --git a/shared/settings/chat.tsx b/shared/settings/chat.tsx index 761d1fb80df8..ae611ccaabb6 100644 --- a/shared/settings/chat.tsx +++ b/shared/settings/chat.tsx @@ -7,7 +7,7 @@ import Group from './group' import {useSettingsChatState as useSettingsChatState} from '@/constants/settings-chat' import {useSettingsNotifState} from '@/constants/settings-notifications' import {useSettingsState} from '@/stores/settings' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const emptyList = new Array() diff --git a/shared/settings/delete-confirm/index.tsx b/shared/settings/delete-confirm/index.tsx index e87a8cdc0d20..a72539e35601 100644 --- a/shared/settings/delete-confirm/index.tsx +++ b/shared/settings/delete-confirm/index.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' import {usePWState} from '@/constants/settings-password' import {useSettingsState} from '@/stores/settings' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type CheckboxesProps = { checkData: boolean diff --git a/shared/settings/display.tsx b/shared/settings/display.tsx index b95ba9a6e786..4dd48300dd40 100644 --- a/shared/settings/display.tsx +++ b/shared/settings/display.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import logger from '@/logger' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as DarkMode from '@/constants/darkmode' const Display = () => { diff --git a/shared/settings/feedback/container.desktop.tsx b/shared/settings/feedback/container.desktop.tsx index 83933ea0ad0d..5ebef2dcdd73 100644 --- a/shared/settings/feedback/container.desktop.tsx +++ b/shared/settings/feedback/container.desktop.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import Feedback from '.' import type {Props} from './container' import {useSendFeedback} from './shared' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const Container = (ownProps: Props) => { const {sendFeedback, error} = useSendFeedback() diff --git a/shared/settings/feedback/container.native.tsx b/shared/settings/feedback/container.native.tsx index b88db320114e..45a5ca45867c 100644 --- a/shared/settings/feedback/container.native.tsx +++ b/shared/settings/feedback/container.native.tsx @@ -1,5 +1,5 @@ -import {useConfigState} from '@/constants/config' -import {useCurrentUserState} from '@/constants/current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import * as Kb from '@/common-adapters' import * as React from 'react' import Feedback from '.' diff --git a/shared/settings/manage-contacts.tsx b/shared/settings/manage-contacts.tsx index 58c78aa8070b..864eedc4842c 100644 --- a/shared/settings/manage-contacts.tsx +++ b/shared/settings/manage-contacts.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import {SettingsSection} from './account' import {useSettingsContactsState} from '@/constants/settings-contacts' import {settingsFeedbackTab} from '@/stores/settings' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const enabledDescription = 'Your phone contacts are being synced on this device.' const disabledDescription = 'Import your phone contacts and start encrypted chats with your friends.' diff --git a/shared/settings/root-phone.tsx b/shared/settings/root-phone.tsx index 168f01bca1df..668f0a4ef3ef 100644 --- a/shared/settings/root-phone.tsx +++ b/shared/settings/root-phone.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/signup/common.tsx b/shared/signup/common.tsx index 60286f6c65e2..19603764cd7e 100644 --- a/shared/signup/common.tsx +++ b/shared/signup/common.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import {type Props as ButtonProps} from '@/common-adapters/button' import openURL from '@/util/open-url' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' type InfoIconProps = { invisible?: boolean diff --git a/shared/signup/feedback.tsx b/shared/signup/feedback.tsx index 51c2ac8ace23..1bc404e8c6a3 100644 --- a/shared/signup/feedback.tsx +++ b/shared/signup/feedback.tsx @@ -4,7 +4,7 @@ import * as React from 'react' import FeedbackForm from '../settings/feedback/index' import {SignupScreen, errorBanner} from './common' import {useSendFeedback} from '../settings/feedback/shared' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const SignupFeedback = () => { const {error: sendError, sendFeedback: onSendFeedback} = useSendFeedback() diff --git a/shared/constants/chat2/index.tsx b/shared/stores/chat2.tsx similarity index 98% rename from shared/constants/chat2/index.tsx rename to shared/stores/chat2.tsx index 79cc8a00fedf..b650042476fc 100644 --- a/shared/constants/chat2/index.tsx +++ b/shared/stores/chat2.tsx @@ -1,27 +1,27 @@ -import * as T from '../types' -import {ignorePromise, timeoutPromise, type ViewPropsToPageProps} from '../utils' -import * as Tabs from '../tabs' +import * as T from '@/constants/types' +import {ignorePromise, timeoutPromise, type ViewPropsToPageProps} from '@/constants/utils' +import * as Tabs from '@/constants/tabs' import * as EngineGen from '@/actions/engine-gen-gen' -import type * as ConfigConstants from '../config' -import * as Message from './message' -import * as Router2 from '../router2' -import * as TeamConstants from '../teams/util' +import type * as ConfigConstants from '@/stores/config' +import * as Message from '@/constants/chat2/message' +import * as Router2 from '@/constants/router2' +import * as TeamConstants from '@/constants/teams/util' import logger from '@/logger' import {RPCError} from '@/util/errors' -import * as Meta from './meta' -import {isMobile, isPhone} from '../platform' +import * as Meta from '@/constants/chat2/meta' +import {isMobile, isPhone} from '@/constants/platform' import * as Z from '@/util/zustand' -import * as Common from './common' -import {clearChatStores, chatStores} from './convostate' +import * as Common from '@/constants/chat2/common' +import {clearChatStores, chatStores} from '@/constants/chat2/convostate' import {uint8ArrayToString} from 'uint8array-extras' import isEqual from 'lodash/isEqual' -import {bodyToJSON} from '../rpc-utils' -import {navigateAppend, navUpToScreen, switchTab} from '../router2/util' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' -import {useWaitingState} from '../waiting' -import * as S from '../strings' +import {bodyToJSON} from '@/constants/rpc-utils' +import {navigateAppend, navUpToScreen, switchTab} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' +import {useWaitingState} from '@/constants/waiting' +import * as S from '@/constants/strings' const defaultTopReacjis = [ {name: ':+1:'}, @@ -1966,7 +1966,7 @@ export const useChatState = Z.createZustand((set, get) => { } }) -import {type ChatProviderProps, ProviderScreen} from './convostate' +import {type ChatProviderProps, ProviderScreen} from '@/constants/chat2/convostate' import type {GetOptionsRet} from '@/constants/types/router2' export function makeChatScreen>( @@ -1992,9 +1992,9 @@ export function makeChatScreen>( } } -export * from './convostate' -export * from './common' -export * from './meta' +export * from '@/constants/chat2/convostate' +export * from '@/constants/chat2/common' +export * from '@/constants/chat2/meta' export * from './message' export { @@ -2003,4 +2003,4 @@ export { pendingErrorConversationIDKey, isValidConversationIDKey, dummyConversationIDKey, -} from '../types/chat2/common' +} from '@/constants/types/chat2/common' diff --git a/shared/constants/config/index.tsx b/shared/stores/config.tsx similarity index 98% rename from shared/constants/config/index.tsx rename to shared/stores/config.tsx index 9d52e0338fc9..d1a2498cbe20 100644 --- a/shared/constants/config/index.tsx +++ b/shared/stores/config.tsx @@ -1,18 +1,18 @@ -import * as T from '../types' -import {ignorePromise, timeoutPromise} from '../utils' -import {waitingKeyConfigLogin} from '../strings' +import * as T from '@/constants/types' +import {ignorePromise, timeoutPromise} from '@/constants/utils' +import {waitingKeyConfigLogin} from '@/constants/strings' import * as EngineGen from '@/actions/engine-gen-gen' import * as Stats from '@/engine/stats' import * as Z from '@/util/zustand' -import {noConversationIDKey} from '../types/chat2/common' +import {noConversationIDKey} from '@/constants/types/chat2/common' import isEqual from 'lodash/isEqual' import logger from '@/logger' -import type {Tab} from '../tabs' +import type {Tab} from '@/constants/tabs' import {RPCError, convertToError, isEOFError, isErrorTransient, niceError} from '@/util/errors' -import {defaultUseNativeFrame, isMobile} from '../platform' +import {defaultUseNativeFrame, isMobile} from '@/constants/platform' import {type CommonResponseHandler} from '@/engine/types' -import {invalidPasswordErrorString} from './util' -import {navigateAppend} from '../router2/util' +import {invalidPasswordErrorString} from '@/constants/config/util' +import {navigateAppend} from '@/constants/router2/util' type Store = T.Immutable<{ active: boolean diff --git a/shared/constants/crypto/index.tsx b/shared/stores/crypto.tsx similarity index 98% rename from shared/constants/crypto/index.tsx rename to shared/stores/crypto.tsx index 1d0a1de56944..881fb2f59a11 100644 --- a/shared/constants/crypto/index.tsx +++ b/shared/stores/crypto.tsx @@ -1,15 +1,15 @@ import * as Z from '@/util/zustand' -import {ignorePromise} from '../utils' -import {isMobile} from '../platform' -import {waitingKeyCrypto} from '../strings' +import {ignorePromise} from '@/constants/utils' +import {isMobile} from '@/constants/platform' +import {waitingKeyCrypto} from '@/constants/strings' import HiddenString from '@/util/hidden-string' import logger from '@/logger' -import * as T from '../types' +import * as T from '@/constants/types' import {RPCError} from '@/util/errors' -import {navigateAppend} from '../router2/util' -import {useCurrentUserState} from '../current-user' -import {Operations} from './util' -export * from './util' +import {navigateAppend} from '@/constants/router2/util' +import {useCurrentUserState} from '@/stores/current-user' +import {Operations} from '@/constants/crypto/util' +export * from '@/constants/crypto/util' type CommonStore = { bytesComplete: number diff --git a/shared/constants/current-user/index.tsx b/shared/stores/current-user.tsx similarity index 96% rename from shared/constants/current-user/index.tsx rename to shared/stores/current-user.tsx index 76b8a2caa8be..aaba7e2cc2cd 100644 --- a/shared/constants/current-user/index.tsx +++ b/shared/stores/current-user.tsx @@ -1,4 +1,4 @@ -import type * as T from '../types' +import type * as T from '@/constants/types' import * as Z from '@/util/zustand' // This store has no dependencies on other stores and is safe to import directly from other stores. diff --git a/shared/stores/fs.tsx b/shared/stores/fs.tsx index a2763376442e..ace4730a19c4 100644 --- a/shared/stores/fs.tsx +++ b/shared/stores/fs.tsx @@ -13,8 +13,8 @@ import isObject from 'lodash/isObject' import isEqual from 'lodash/isEqual' import {navigateAppend, navigateUp} from '@/constants/router2/util' import {storeRegistry} from '@/constants/store-registry' -import {useConfigState} from '@/constants/config' -import {useCurrentUserState} from '@/constants/current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import * as Util from '@/constants/fs/util' export * from '@/constants/fs/util' diff --git a/shared/stores/git.tsx b/shared/stores/git.tsx index f1b8ce2b39f8..9ea6dbc1d2c6 100644 --- a/shared/stores/git.tsx +++ b/shared/stores/git.tsx @@ -6,7 +6,7 @@ import * as dateFns from 'date-fns' import * as Z from '@/util/zustand' import debounce from 'lodash/debounce' import {navigateAppend} from '@/constants/router2/util' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const parseRepos = (results: ReadonlyArray) => { const errors: Array = [] diff --git a/shared/stores/notifications.tsx b/shared/stores/notifications.tsx index eeaa186b75d8..3fcbeab6cb8c 100644 --- a/shared/stores/notifications.tsx +++ b/shared/stores/notifications.tsx @@ -5,8 +5,8 @@ import {isMobile} from '@/constants/platform' import isEqual from 'lodash/isEqual' import * as Tabs from '@/constants/tabs' import {storeRegistry} from '@/constants/store-registry' -import {useConfigState} from '@/constants/config' -import {useCurrentUserState} from '@/constants/current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' export type BadgeType = 'regular' | 'update' | 'error' | 'uploading' export type NotificationKeys = 'kbfsUploading' | 'outOfSpace' diff --git a/shared/stores/people.tsx b/shared/stores/people.tsx index c3a6cda910af..27a6a2746e2d 100644 --- a/shared/stores/people.tsx +++ b/shared/stores/people.tsx @@ -9,7 +9,7 @@ import type {IconType} from '@/common-adapters/icon.constants-gen' // do NOT pul import {isMobile} from '@/constants/platform' import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' import debounce from 'lodash/debounce' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import {useFollowerState} from '@/stores/followers' import {RPCError, isNetworkErr} from '@/constants/utils' diff --git a/shared/stores/settings.tsx b/shared/stores/settings.tsx index 03545e1f668b..fe18f64b2736 100644 --- a/shared/stores/settings.tsx +++ b/shared/stores/settings.tsx @@ -9,8 +9,8 @@ import * as Tabs from '@/constants/tabs' import logger from '@/logger' import {clearModals, navigateAppend, switchTab} from '@/constants/router2/util' import {storeRegistry} from '@/constants/store-registry' -import {useConfigState} from '@/constants/config' -import {useCurrentUserState} from '@/constants/current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import {useWaitingState} from '@/constants/waiting' import {processorProfileInProgressKey, traceInProgressKey} from '@/constants/settings/util' diff --git a/shared/stores/signup.tsx b/shared/stores/signup.tsx index f885e51bdd0f..2a0058d0f5cf 100644 --- a/shared/stores/signup.tsx +++ b/shared/stores/signup.tsx @@ -10,7 +10,7 @@ import {RPCError} from '@/util/errors' import {isValidEmail, isValidName, isValidUsername} from '@/util/simple-validators' import {navigateAppend, navigateUp} from '@/constants/router2/util' import {storeRegistry} from '@/constants/store-registry' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' type Store = T.Immutable<{ devicename: string diff --git a/shared/stores/teams.tsx b/shared/stores/teams.tsx index d79211e67392..27fbb2f9fac0 100644 --- a/shared/stores/teams.tsx +++ b/shared/stores/teams.tsx @@ -20,8 +20,8 @@ import {mapGetEnsureValue} from '@/util/map' import {bodyToJSON} from '@/constants/rpc-utils' import {fixCrop} from '@/util/crop' import {storeRegistry} from '@/constants/store-registry' -import {useConfigState} from '@/constants/config' -import {useCurrentUserState} from '@/constants/current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import * as Util from '@/constants/teams/util' import {getTab} from '@/constants/router2/util' diff --git a/shared/stores/tracker2.tsx b/shared/stores/tracker2.tsx index c715a1a1b4f6..1fa1152e9c29 100644 --- a/shared/stores/tracker2.tsx +++ b/shared/stores/tracker2.tsx @@ -8,7 +8,7 @@ import {RPCError} from '@/util/errors' import {mapGetEnsureValue} from '@/util/map' import {navigateAppend, navigateUp} from '@/constants/router2/util' import {storeRegistry} from '@/constants/store-registry' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export const noDetails: T.Tracker.Details = { assertions: new Map(), diff --git a/shared/stores/unlock-folders.tsx b/shared/stores/unlock-folders.tsx index db58f5249690..d8fa1d8dd573 100644 --- a/shared/stores/unlock-folders.tsx +++ b/shared/stores/unlock-folders.tsx @@ -3,7 +3,7 @@ import * as T from '@/constants/types' import * as Z from '@/util/zustand' import logger from '@/logger' import {getEngine} from '@/engine/require' -import {useConfigState, type State as ConfigStore} from '@/constants/config' +import {useConfigState, type State as ConfigStore} from '@/stores/config' type Store = T.Immutable<{ devices: ConfigStore['unlockFoldersDevices'] diff --git a/shared/team-building/list-body.tsx b/shared/team-building/list-body.tsx index 3074c77517a9..b56284ba92b4 100644 --- a/shared/team-building/list-body.tsx +++ b/shared/team-building/list-body.tsx @@ -16,7 +16,7 @@ import {formatAnyPhoneNumbers} from '@/util/phone-numbers' import {useRoute} from '@react-navigation/native' import {useSettingsContactsState} from '@/constants/settings-contacts' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' // import {useAnimatedScrollHandler} from '@/common-adapters/reanimated' import {useColorScheme} from 'react-native' diff --git a/shared/team-building/search-result/hellobot-result.tsx b/shared/team-building/search-result/hellobot-result.tsx index 029e730955d1..4ba191ddc868 100644 --- a/shared/team-building/search-result/hellobot-result.tsx +++ b/shared/team-building/search-result/hellobot-result.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {useTBContext} from '@/constants/team-building' import * as Kb from '@/common-adapters' diff --git a/shared/team-building/search-result/people-result.tsx b/shared/team-building/search-result/people-result.tsx index 3c2dde2f9e1c..7292f26ffae4 100644 --- a/shared/team-building/search-result/people-result.tsx +++ b/shared/team-building/search-result/people-result.tsx @@ -1,12 +1,12 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as FS from '@/stores/fs' import CommonResult, {type ResultProps} from './common-result' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' /* * This component is intended to be a drop-in replacement for UserResult. diff --git a/shared/team-building/search-result/you-result.tsx b/shared/team-building/search-result/you-result.tsx index 0e98651cd20a..3ce11d515026 100644 --- a/shared/team-building/search-result/you-result.tsx +++ b/shared/team-building/search-result/you-result.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import {useTBContext} from '@/constants/team-building' import * as Kb from '@/common-adapters' diff --git a/shared/teams/add-members-wizard/confirm.tsx b/shared/teams/add-members-wizard/confirm.tsx index bcfbbdbfec36..6c4fab1bef42 100644 --- a/shared/teams/add-members-wizard/confirm.tsx +++ b/shared/teams/add-members-wizard/confirm.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import {useTeamsState} from '@/stores/teams' diff --git a/shared/teams/channel/header.tsx b/shared/teams/channel/header.tsx index 84c2416a80df..16a840f36f2e 100644 --- a/shared/teams/channel/header.tsx +++ b/shared/teams/channel/header.tsx @@ -1,6 +1,6 @@ import * as T from '@/constants/types' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import {useTeamsState} from '@/stores/teams' diff --git a/shared/teams/channel/index.tsx b/shared/teams/channel/index.tsx index e0c681b756c9..0af5d5e9274d 100644 --- a/shared/teams/channel/index.tsx +++ b/shared/teams/channel/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' diff --git a/shared/teams/channel/rows.tsx b/shared/teams/channel/rows.tsx index fa62d406fc68..4ce779671cd8 100644 --- a/shared/teams/channel/rows.tsx +++ b/shared/teams/channel/rows.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' @@ -7,7 +7,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import MenuHeader from '../team/rows/menu-header.new' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { conversationIDKey: T.Chat.ConversationIDKey diff --git a/shared/teams/common/channel-hooks.tsx b/shared/teams/common/channel-hooks.tsx index a3142cbbdd6b..7736f46a4e49 100644 --- a/shared/teams/common/channel-hooks.tsx +++ b/shared/teams/common/channel-hooks.tsx @@ -1,6 +1,6 @@ import * as T from '@/constants/types' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' diff --git a/shared/teams/common/enable-contacts.tsx b/shared/teams/common/enable-contacts.tsx index 133d5cb95967..829078c08933 100644 --- a/shared/teams/common/enable-contacts.tsx +++ b/shared/teams/common/enable-contacts.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as Kb from '@/common-adapters' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' /** * Popup explaining that Keybase doesn't have contact permissions with a link to diff --git a/shared/teams/common/selection-popup.tsx b/shared/teams/common/selection-popup.tsx index b21537699cd5..a30fc04dd584 100644 --- a/shared/teams/common/selection-popup.tsx +++ b/shared/teams/common/selection-popup.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import {useTeamsState} from '@/stores/teams' diff --git a/shared/teams/container.tsx b/shared/teams/container.tsx index 50483c818427..e298f8692896 100644 --- a/shared/teams/container.tsx +++ b/shared/teams/container.tsx @@ -9,7 +9,7 @@ import openURL from '@/util/open-url' import {useTeamsSubscribe} from './subscriber' import {useActivityLevels} from './common' import {useSafeNavigation} from '@/util/safe-navigation' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const orderTeams = ( teams: ReadonlyMap, diff --git a/shared/teams/emojis/add-alias.tsx b/shared/teams/emojis/add-alias.tsx index cfbf1a23f600..728b3e93a2a4 100644 --- a/shared/teams/emojis/add-alias.tsx +++ b/shared/teams/emojis/add-alias.tsx @@ -1,6 +1,6 @@ import * as T from '@/constants/types' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import {EmojiPickerDesktop} from '@/chat/emoji-picker/container' diff --git a/shared/teams/emojis/add-emoji.tsx b/shared/teams/emojis/add-emoji.tsx index b1f9a3343e17..81c4e896a1f7 100644 --- a/shared/teams/emojis/add-emoji.tsx +++ b/shared/teams/emojis/add-emoji.tsx @@ -1,6 +1,6 @@ import * as T from '@/constants/types' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Kb from '@/common-adapters' import {AliasInput, Modal} from './common' diff --git a/shared/teams/external-team.tsx b/shared/teams/external-team.tsx index a550fefaa9fa..8d245ab0a3b3 100644 --- a/shared/teams/external-team.tsx +++ b/shared/teams/external-team.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import {useProfileState} from '@/constants/profile' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/teams/main/team-row.tsx b/shared/teams/main/team-row.tsx index 47bc1dc0041c..524f5e399dca 100644 --- a/shared/teams/main/team-row.tsx +++ b/shared/teams/main/team-row.tsx @@ -1,4 +1,4 @@ -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as React from 'react' import type * as T from '@/constants/types' diff --git a/shared/teams/new-team/wizard/add-subteam-members.tsx b/shared/teams/new-team/wizard/add-subteam-members.tsx index 5110a8f11a46..6d9484b18811 100644 --- a/shared/teams/new-team/wizard/add-subteam-members.tsx +++ b/shared/teams/new-team/wizard/add-subteam-members.tsx @@ -6,7 +6,7 @@ import {ModalTitle} from '@/teams/common' import {pluralize} from '@/util/string' import {useTeamDetailsSubscribe} from '@/teams/subscriber' import {useSafeNavigation} from '@/util/safe-navigation' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const AddSubteamMembers = () => { const nav = useSafeNavigation() diff --git a/shared/teams/routes.tsx b/shared/teams/routes.tsx index 5692f5f15451..3d57aef29f3a 100644 --- a/shared/teams/routes.tsx +++ b/shared/teams/routes.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import contactRestricted from '../team-building/contact-restricted.page' import teamsTeamBuilder from '../team-building/page' import teamsRootGetOptions from './get-options' diff --git a/shared/teams/team/member/add-to-channels.tsx b/shared/teams/team/member/add-to-channels.tsx index bb7c7006f92d..3e3035cb798e 100644 --- a/shared/teams/team/member/add-to-channels.tsx +++ b/shared/teams/team/member/add-to-channels.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Teams from '@/stores/teams' import * as React from 'react' @@ -8,7 +8,7 @@ import * as Common from '@/teams/common' import {pluralize} from '@/util/string' import {useAllChannelMetas} from '@/teams/common/channel-hooks' import {useSafeNavigation} from '@/util/safe-navigation' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { teamID: T.Teams.TeamID diff --git a/shared/teams/team/member/index.new.tsx b/shared/teams/team/member/index.new.tsx index 645f968c94b3..591f38dac230 100644 --- a/shared/teams/team/member/index.new.tsx +++ b/shared/teams/team/member/index.new.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' -import {useCurrentUserState} from '@/constants/current-user' +import * as Chat from '@/stores/chat2' +import {useCurrentUserState} from '@/stores/current-user' import * as Teams from '@/stores/teams' import {useProfileState} from '@/constants/profile' import * as Kb from '@/common-adapters' diff --git a/shared/teams/team/new-header.tsx b/shared/teams/team/new-header.tsx index 4bebcadaff72..b5f05946e03b 100644 --- a/shared/teams/team/new-header.tsx +++ b/shared/teams/team/new-header.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' @@ -8,7 +8,7 @@ import {pluralize} from '@/util/string' import {Activity, useActivityLevels, useTeamLinkPopup} from '../common' import type * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useTeamsState} from '@/stores/teams' const AddPeopleButton = ({teamID}: {teamID: T.Teams.TeamID}) => { diff --git a/shared/teams/team/rows/emoji-row/item.tsx b/shared/teams/team/rows/emoji-row/item.tsx index e1e97c23623b..41c72d14f68b 100644 --- a/shared/teams/team/rows/emoji-row/item.tsx +++ b/shared/teams/team/rows/emoji-row/item.tsx @@ -8,7 +8,7 @@ import {RPCToEmojiData} from '@/common-adapters/emoji' import EmojiMenu from './emoji-menu' import {useEmojiState} from '@/teams/emojis/use-emoji' import {useSafeNavigation} from '@/util/safe-navigation' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type OwnProps = { conversationIDKey: T.Chat.ConversationIDKey diff --git a/shared/teams/team/rows/empty-row.tsx b/shared/teams/team/rows/empty-row.tsx index 7586fec837ee..df3f9f02eaaa 100644 --- a/shared/teams/team/rows/empty-row.tsx +++ b/shared/teams/team/rows/empty-row.tsx @@ -1,10 +1,10 @@ import type * as T from '@/constants/types' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Props = { type: 'channelsEmpty' | 'channelsFew' | 'members' | 'subteams' diff --git a/shared/teams/team/rows/index.tsx b/shared/teams/team/rows/index.tsx index 6c19e4b7220b..ddfe2b0808fa 100644 --- a/shared/teams/team/rows/index.tsx +++ b/shared/teams/team/rows/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as T from '@/constants/types' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' @@ -14,7 +14,7 @@ import {RequestRow, InviteRow} from './invite-row' import {SubteamAddRow, SubteamInfoRow, SubteamTeamRow} from './subteam-row' import {getOrderedMemberArray, sortInvites, getOrderedBotsArray} from './helpers' import {useEmojiState} from '../../emojis/use-emoji' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' type Requests = Omit, 'firstItem' | 'teamID'> diff --git a/shared/teams/team/rows/invite-row/request.tsx b/shared/teams/team/rows/invite-row/request.tsx index 434db07574e0..ca4b7bee8beb 100644 --- a/shared/teams/team/rows/invite-row/request.tsx +++ b/shared/teams/team/rows/invite-row/request.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import {useProfileState} from '@/constants/profile' import type * as T from '@/constants/types' diff --git a/shared/teams/team/rows/member-row.tsx b/shared/teams/team/rows/member-row.tsx index 34497c152c6a..2b163c88e1f1 100644 --- a/shared/teams/team/rows/member-row.tsx +++ b/shared/teams/team/rows/member-row.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Kb from '@/common-adapters' import * as Teams from '@/stores/teams' import * as React from 'react' @@ -9,7 +9,7 @@ import {useSafeNavigation} from '@/util/safe-navigation' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/constants/profile' import {useUsersState} from '@/stores/users' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' export type Props = { firstItem: boolean diff --git a/shared/teams/team/settings-tab/index.tsx b/shared/teams/team/settings-tab/index.tsx index e3afd3bc9823..5b83a2071295 100644 --- a/shared/teams/team/settings-tab/index.tsx +++ b/shared/teams/team/settings-tab/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' diff --git a/shared/teams/team/settings-tab/retention/index.tsx b/shared/teams/team/settings-tab/retention/index.tsx index b16ef96320f0..0c539384b43c 100644 --- a/shared/teams/team/settings-tab/retention/index.tsx +++ b/shared/teams/team/settings-tab/retention/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as React from 'react' import * as Teams from '@/stores/teams' import {useTeamsState} from '@/stores/teams' diff --git a/shared/teams/team/tabs.tsx b/shared/teams/team/tabs.tsx index 8700d814ebb7..a2fcf15ecd24 100644 --- a/shared/teams/team/tabs.tsx +++ b/shared/teams/team/tabs.tsx @@ -1,7 +1,7 @@ import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import * as C from '@/constants' -import * as Chat from '@/constants/chat2' +import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import type {Tab as TabType} from '@/common-adapters/tabs' diff --git a/shared/tracker2/assertion.tsx b/shared/tracker2/assertion.tsx index 991bbe415483..a3a1cc41a7de 100644 --- a/shared/tracker2/assertion.tsx +++ b/shared/tracker2/assertion.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as C from '@/constants' -import {useConfigState} from '@/constants/config' -import {useCurrentUserState} from '@/constants/current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import type * as T from '@/constants/types' import openUrl from '@/util/open-url' import * as Kb from '@/common-adapters' diff --git a/shared/tracker2/remote-container.desktop.tsx b/shared/tracker2/remote-container.desktop.tsx index b07a455ed273..ba1d3556bc29 100644 --- a/shared/tracker2/remote-container.desktop.tsx +++ b/shared/tracker2/remote-container.desktop.tsx @@ -1,7 +1,7 @@ // Inside tracker we use an embedded Avatar which is connected. import * as React from 'react' import * as C from '@/constants' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as R from '@/constants/remote' import * as RemoteGen from '../actions/remote-gen' import type * as T from '@/constants/types' @@ -12,7 +12,7 @@ import {useAvatarState} from '@/common-adapters/avatar/store' import {useTrackerState} from '@/stores/tracker2' import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' import {useDarkModeState} from '@/constants/darkmode' const {closeWindow} = KB2.functions diff --git a/shared/tracker2/remote-proxy.desktop.tsx b/shared/tracker2/remote-proxy.desktop.tsx index f476fd225b39..0cb25baaab0f 100644 --- a/shared/tracker2/remote-proxy.desktop.tsx +++ b/shared/tracker2/remote-proxy.desktop.tsx @@ -1,7 +1,7 @@ // A mirror of the remote tracker windows. import * as C from '@/constants' import {useAvatarState} from '@/common-adapters/avatar/store' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' import * as React from 'react' import useSerializeProps from '../desktop/remote/use-serialize-props.desktop' import useBrowserWindow from '../desktop/remote/use-browser-window.desktop' @@ -12,7 +12,7 @@ import {useColorScheme} from 'react-native' import {useTrackerState} from '@/stores/tracker2' import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' -import {useCurrentUserState} from '@/constants/current-user' +import {useCurrentUserState} from '@/stores/current-user' const MAX_TRACKERS = 5 const windowOpts = {hasShadow: false, height: 470, transparent: true, width: 320} diff --git a/shared/unlock-folders/device-list.desktop.tsx b/shared/unlock-folders/device-list.desktop.tsx index 9a2456b13680..ab64aeb86072 100644 --- a/shared/unlock-folders/device-list.desktop.tsx +++ b/shared/unlock-folders/device-list.desktop.tsx @@ -1,5 +1,5 @@ import * as Kb from '@/common-adapters' -import type {State as ConfigStore} from '@/constants/config' +import type {State as ConfigStore} from '@/stores/config' export type Props = { devices: ConfigStore['unlockFoldersDevices'] diff --git a/shared/unlock-folders/index.desktop.tsx b/shared/unlock-folders/index.desktop.tsx index 38d1bacf0883..af45ee616ebd 100644 --- a/shared/unlock-folders/index.desktop.tsx +++ b/shared/unlock-folders/index.desktop.tsx @@ -5,7 +5,7 @@ import DragHeader from '../desktop/remote/drag-header.desktop' import PaperKeyInput from './paper-key-input.desktop' import Success from './success.desktop' import type * as Constants from '@/stores/unlock-folders' -import type {State as ConfigStore} from '@/constants/config' +import type {State as ConfigStore} from '@/stores/config' export type Props = { phase: Constants.State['phase'] diff --git a/shared/unlock-folders/remote-proxy.desktop.tsx b/shared/unlock-folders/remote-proxy.desktop.tsx index 34ae7ba99c1d..ebe89bf3d4b7 100644 --- a/shared/unlock-folders/remote-proxy.desktop.tsx +++ b/shared/unlock-folders/remote-proxy.desktop.tsx @@ -4,7 +4,7 @@ import useBrowserWindow from '../desktop/remote/use-browser-window.desktop' import useSerializeProps from '../desktop/remote/use-serialize-props.desktop' import {serialize, type ProxyProps} from './remote-serializer.desktop' import {useColorScheme} from 'react-native' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const windowOpts = {height: 300, width: 500} diff --git a/shared/unlock-folders/remote-serializer.desktop.tsx b/shared/unlock-folders/remote-serializer.desktop.tsx index 0370a4c3a86c..b46524dc672d 100644 --- a/shared/unlock-folders/remote-serializer.desktop.tsx +++ b/shared/unlock-folders/remote-serializer.desktop.tsx @@ -1,5 +1,5 @@ import * as T from '@/constants/types' -import type * as ConfigConstants from '@/constants/config' +import type * as ConfigConstants from '@/stores/config' import {produce} from 'immer' export type ProxyProps = { diff --git a/shared/wallets/really-remove-account.tsx b/shared/wallets/really-remove-account.tsx index e72a8cf90bba..1e356ab1b640 100644 --- a/shared/wallets/really-remove-account.tsx +++ b/shared/wallets/really-remove-account.tsx @@ -5,7 +5,7 @@ import * as React from 'react' import WalletPopup from './wallet-popup' import * as Wallets from '@/constants/wallets' import {useState as useWalletsState} from '@/constants/wallets' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' type OwnProps = {accountID: string} diff --git a/shared/whats-new/container.tsx b/shared/whats-new/container.tsx index 605376435ff3..7fa47ff09947 100644 --- a/shared/whats-new/container.tsx +++ b/shared/whats-new/container.tsx @@ -4,7 +4,7 @@ import {currentVersion} from '@/constants/whats-new' import {Current, Last, LastLast} from './versions' import WhatsNew from '.' import {useWhatsNewState as useWNState} from '@/constants/whats-new' -import {useConfigState} from '@/constants/config' +import {useConfigState} from '@/stores/config' const WhatsNewContainer = () => { const _onNavigateExternal = (url: string) => { From 4f6caf5532e420e85dcb2c8d80f98f031546568c Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:35:44 -0500 Subject: [PATCH 24/37] WIP --- shared/constants/chat2/common.tsx | 2 +- shared/constants/chat2/convostate.tsx | 4 +- shared/constants/chat2/meta.tsx | 10 +- shared/constants/deeplinks/index.tsx | 136 +++++++++--------- shared/constants/fs/index.tsx | 4 +- .../fs/platform-specific.desktop.tsx | 2 +- shared/constants/init/index.desktop.tsx | 6 +- shared/constants/init/index.native.tsx | 6 +- shared/constants/init/shared.tsx | 7 +- .../platform-specific/push.native.tsx | 2 +- shared/constants/profile/index.tsx | 10 +- shared/constants/push.native.tsx | 4 +- shared/constants/recover-password/index.tsx | 6 +- shared/constants/settings-chat/index.tsx | 2 +- shared/constants/settings-contacts.native.tsx | 4 +- shared/constants/team-building/index.tsx | 2 +- shared/constants/wallets/index.tsx | 2 +- shared/stores/chat2.tsx | 2 +- 18 files changed, 102 insertions(+), 109 deletions(-) diff --git a/shared/constants/chat2/common.tsx b/shared/constants/chat2/common.tsx index 8c63c456b387..8a64d900c885 100644 --- a/shared/constants/chat2/common.tsx +++ b/shared/constants/chat2/common.tsx @@ -1,7 +1,7 @@ import * as T from '../types' import {isMobile, isTablet} from '../platform' import * as Router2 from '../router2' -import {useConfigState} from '../config' +import {useConfigState} from '@/stores/config' export const explodingModeGregorKeyPrefix = 'exploding:' diff --git a/shared/constants/chat2/convostate.tsx b/shared/constants/chat2/convostate.tsx index fe96a91842d7..a1c4d33dd1df 100644 --- a/shared/constants/chat2/convostate.tsx +++ b/shared/constants/chat2/convostate.tsx @@ -47,8 +47,8 @@ import {enumKeys, ignorePromise, shallowEqual} from '../utils' import * as Strings from '@/constants/strings' import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' const {darwinCopyToChatTempUploadFile} = KB2.functions diff --git a/shared/constants/chat2/meta.tsx b/shared/constants/chat2/meta.tsx index 243060f08637..93b889627441 100644 --- a/shared/constants/chat2/meta.tsx +++ b/shared/constants/chat2/meta.tsx @@ -5,7 +5,7 @@ import * as Teams from '../teams/util' import * as Message from './message' import {base64ToUint8Array, uint8ArrayToHex} from 'uint8array-extras' import {storeRegistry} from '../store-registry' -import {useCurrentUserState} from '../current-user' +import {useCurrentUserState} from '@/stores/current-user' const conversationMemberStatusToMembershipType = (m: T.RPCChat.ConversationMemberStatus) => { switch (m) { @@ -41,9 +41,9 @@ export const unverifiedInboxUIItemToConversationMeta = ( // We only treat implicit adhoc teams as having resetParticipants const resetParticipants: Set = new Set( i.localMetadata && - (i.membersType === T.RPCChat.ConversationMembersType.impteamnative || - i.membersType === T.RPCChat.ConversationMembersType.impteamupgrade) && - i.localMetadata.resetParticipants + (i.membersType === T.RPCChat.ConversationMembersType.impteamnative || + i.membersType === T.RPCChat.ConversationMembersType.impteamupgrade) && + i.localMetadata.resetParticipants ? i.localMetadata.resetParticipants : [] ) @@ -237,7 +237,7 @@ export const inboxUIItemToConversationMeta = ( const resetParticipants = new Set( (i.membersType === T.RPCChat.ConversationMembersType.impteamnative || i.membersType === T.RPCChat.ConversationMembersType.impteamupgrade) && - i.resetParticipants + i.resetParticipants ? i.resetParticipants : [] ) diff --git a/shared/constants/deeplinks/index.tsx b/shared/constants/deeplinks/index.tsx index a81ec61f4f5f..405b5c517fba 100644 --- a/shared/constants/deeplinks/index.tsx +++ b/shared/constants/deeplinks/index.tsx @@ -8,8 +8,8 @@ import logger from '@/logger' import * as T from '@/constants/types' import {navigateAppend, switchTab} from '../router2/util' import {storeRegistry} from '../store-registry' -import {useCryptoState} from '../crypto' -import {useConfigState} from '../config' +import {useCryptoState} from '@/stores/crypto' +import {useConfigState} from '@/stores/config' const prefix = 'keybase://' export const linkFromConvAndMessage = (conv: string, messageID: number) => @@ -38,77 +38,77 @@ const validTeamnamePart = (s: string): boolean => { } const validTeamname = (s: string) => s.split('.').every(validTeamnamePart) - const handleShowUserProfileLink = (username: string) => { - switchTab(Tabs.peopleTab) - storeRegistry.getState('profile').dispatch.showUserProfile(username) - } +const handleShowUserProfileLink = (username: string) => { + switchTab(Tabs.peopleTab) + storeRegistry.getState('profile').dispatch.showUserProfile(username) +} - const isKeybaseIoUrl = (url: URL) => { - const {protocol} = url - if (protocol !== 'http:' && protocol !== 'https:') return false - if (url.username || url.password) return false - const {hostname} = url - if (hostname !== 'keybase.io' && hostname !== 'www.keybase.io') return false - const {port} = url - if (port) { - if (protocol === 'http:' && port !== '80') return false - if (protocol === 'https:' && port !== '443') return false - } - return true +const isKeybaseIoUrl = (url: URL) => { + const {protocol} = url + if (protocol !== 'http:' && protocol !== 'https:') return false + if (url.username || url.password) return false + const {hostname} = url + if (hostname !== 'keybase.io' && hostname !== 'www.keybase.io') return false + const {port} = url + if (port) { + if (protocol === 'http:' && port !== '80') return false + if (protocol === 'https:' && port !== '443') return false } + return true +} - const urlToUsername = (url: URL) => { - if (!isKeybaseIoUrl(url)) { - return null - } - // Adapted username regexp (see libkb/checkers.go) with a leading /, an - // optional trailing / and a dash for custom links. - const match = url.pathname.match(/^\/((?:[a-zA-Z0-9][a-zA-Z0-9_-]?)+)\/?$/) - if (!match) { - return null - } - const usernameMatch = match[1] - if (!usernameMatch || usernameMatch.length < 2 || usernameMatch.length > 16) { - return null - } - // Ignore query string and hash parameters. - return usernameMatch.toLowerCase() +const urlToUsername = (url: URL) => { + if (!isKeybaseIoUrl(url)) { + return null } - - const urlToTeamDeepLink = (url: URL) => { - if (!isKeybaseIoUrl(url)) { - return null - } - // Similar regexp to username but allow `.` for subteams - const match = url.pathname.match(/^\/team\/((?:[a-zA-Z0-9][a-zA-Z0-9_.-]?)+)\/?$/) - if (!match) { - return null - } - const teamName = match[1] - if (!teamName || teamName.length < 2 || teamName.length > 255) { - return null - } - // `url.query` has a wrong type in @types/url-parse. It's a `string` in the - // code, but @types claim it's a {[k: string]: string | undefined}. - const queryString = url.query as unknown as string - // URLSearchParams is not available in react-native. See if any of recognized - // query parameters is passed using regular expressions. - const action = (['add_or_invite', 'manage_settings'] satisfies readonly TeamPageAction[]).find( - x => queryString.search(`[?&]applink=${x}([?&].+)?$`) !== -1 - ) - return {action, teamName} + // Adapted username regexp (see libkb/checkers.go) with a leading /, an + // optional trailing / and a dash for custom links. + const match = url.pathname.match(/^\/((?:[a-zA-Z0-9][a-zA-Z0-9_-]?)+)\/?$/) + if (!match) { + return null + } + const usernameMatch = match[1] + if (!usernameMatch || usernameMatch.length < 2 || usernameMatch.length > 16) { + return null } + // Ignore query string and hash parameters. + return usernameMatch.toLowerCase() +} - const handleTeamPageLink = (teamname: string, action?: TeamPageAction) => { - storeRegistry - .getState('teams') - .dispatch.showTeamByName( - teamname, - action === 'manage_settings' ? 'settings' : undefined, - action === 'join' ? true : undefined, - action === 'add_or_invite' ? true : undefined - ) +const urlToTeamDeepLink = (url: URL) => { + if (!isKeybaseIoUrl(url)) { + return null + } + // Similar regexp to username but allow `.` for subteams + const match = url.pathname.match(/^\/team\/((?:[a-zA-Z0-9][a-zA-Z0-9_.-]?)+)\/?$/) + if (!match) { + return null } + const teamName = match[1] + if (!teamName || teamName.length < 2 || teamName.length > 255) { + return null + } + // `url.query` has a wrong type in @types/url-parse. It's a `string` in the + // code, but @types claim it's a {[k: string]: string | undefined}. + const queryString = url.query as unknown as string + // URLSearchParams is not available in react-native. See if any of recognized + // query parameters is passed using regular expressions. + const action = (['add_or_invite', 'manage_settings'] satisfies readonly TeamPageAction[]).find( + x => queryString.search(`[?&]applink=${x}([?&].+)?$`) !== -1 + ) + return {action, teamName} +} + +const handleTeamPageLink = (teamname: string, action?: TeamPageAction) => { + storeRegistry + .getState('teams') + .dispatch.showTeamByName( + teamname, + action === 'manage_settings' ? 'settings' : undefined, + action === 'join' ? true : undefined, + action === 'add_or_invite' ? true : undefined + ) +} export const handleAppLink = (link: string) => { if (link.startsWith('keybase://')) { @@ -147,9 +147,7 @@ export const handleKeybaseLink = (link: string) => { switch (parts[0]) { case 'profile': if (parts[1] === 'new-proof' && (parts.length === 3 || parts.length === 4)) { - parts.length === 4 && - parts[3] && - storeRegistry.getState('profile').dispatch.showUserProfile(parts[3]) + parts.length === 4 && parts[3] && storeRegistry.getState('profile').dispatch.showUserProfile(parts[3]) storeRegistry.getState('profile').dispatch.addProof(parts[2]!, 'appLink') return } else if (parts[1] === 'show' && parts.length === 3) { diff --git a/shared/constants/fs/index.tsx b/shared/constants/fs/index.tsx index f3d94d5b13f5..0a81ec057c9b 100644 --- a/shared/constants/fs/index.tsx +++ b/shared/constants/fs/index.tsx @@ -13,8 +13,8 @@ import isObject from 'lodash/isObject' import isEqual from 'lodash/isEqual' import {navigateAppend, navigateUp} from '../router2/util' import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import * as Util from './util' export * from './util' diff --git a/shared/constants/fs/platform-specific.desktop.tsx b/shared/constants/fs/platform-specific.desktop.tsx index 71bee000e649..26ff8a81e597 100644 --- a/shared/constants/fs/platform-specific.desktop.tsx +++ b/shared/constants/fs/platform-specific.desktop.tsx @@ -9,7 +9,7 @@ import KB2 from '@/util/electron.desktop' import {uint8ArrayToHex} from 'uint8array-extras' import {useFSState} from '.' import {navigateAppend} from '../router2/util' -import {useConfigState} from '../config' +import {useConfigState} from '@/stores/config' const {openPathInFinder, openURL, getPathType, selectFilesToUploadDialog} = KB2.functions const {darwinCopyToKBFSTempUploadFile, relaunchApp, uninstallKBFSDialog, uninstallDokanDialog} = KB2.functions diff --git a/shared/constants/init/index.desktop.tsx b/shared/constants/init/index.desktop.tsx index 90e9d5834292..435f8f4c3263 100644 --- a/shared/constants/init/index.desktop.tsx +++ b/shared/constants/init/index.desktop.tsx @@ -1,8 +1,8 @@ // links all the stores together, stores never import this -import * as Chat from '../chat2' +import * as Chat from '@/stores/chat2' import {ignorePromise} from '../utils' -import {useConfigState} from '../config' -import * as ConfigConstants from '../config' +import {useConfigState} from '@/stores/config' +import * as ConfigConstants from '@/stores/config' import {useDaemonState} from '../daemon' import {useFSState} from '../fs' import {useProfileState} from '../profile' diff --git a/shared/constants/init/index.native.tsx b/shared/constants/init/index.native.tsx index 39a02773ae59..c856ceb02612 100644 --- a/shared/constants/init/index.native.tsx +++ b/shared/constants/init/index.native.tsx @@ -1,8 +1,8 @@ // links all the stores together, stores never import this import {ignorePromise, neverThrowPromiseFunc, timeoutPromise} from '../utils' -import {useChatState} from '../chat2' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' +import {useChatState} from '@/stores/chat2' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '../daemon' import {useDarkModeState} from '../darkmode' import {useFSState} from '../fs' diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index fb84d14da42e..7d311dc1da98 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -11,8 +11,8 @@ import type * as UseBotsStateType from '@/stores/bots' import {useChatState} from '@/stores/chat2' import {getSelectedConversation} from '@/constants/chat2/common' import type * as UseChatStateType from '@/stores/chat2' -import {useConfigState} from '../config' -import {useCurrentUserState} from '../current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '../daemon' import {useDarkModeState} from '../darkmode' import * as DeepLinksUtil from '../deeplinks/util' @@ -39,7 +39,8 @@ let _devicesLoaded = false let _gitLoaded = false export const onEngineConnected = () => { - { // Chat2 + { + // Chat2 const f = async () => { try { await T.RPCGen.delegateUiCtlRegisterChatUIRpcPromise() diff --git a/shared/constants/platform-specific/push.native.tsx b/shared/constants/platform-specific/push.native.tsx index 25f3ed270787..a2653fe10d5d 100644 --- a/shared/constants/platform-specific/push.native.tsx +++ b/shared/constants/platform-specific/push.native.tsx @@ -10,7 +10,7 @@ import { removeAllPendingNotificationRequests, } from 'react-native-kb' import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' +import {useConfigState} from '@/stores/config' import {useLogoutState} from '../logout' type DataCommon = { diff --git a/shared/constants/profile/index.tsx b/shared/constants/profile/index.tsx index d99952fa3cdb..ffc4e6c8fc84 100644 --- a/shared/constants/profile/index.tsx +++ b/shared/constants/profile/index.tsx @@ -9,7 +9,7 @@ import {RPCError} from '@/util/errors' import {fixCrop} from '@/util/crop' import {clearModals, navigateAppend, navigateUp} from '../router2/util' import {storeRegistry} from '../store-registry' -import {useCurrentUserState} from '../current-user' +import {useCurrentUserState} from '@/stores/current-user' import {navToProfile} from '../router2/util' type ProveGenericParams = { @@ -599,9 +599,7 @@ export const useProfileState = Z.createZustand((set, get) => { }) const f = async () => { await T.RPCGen.proveCheckProofRpcPromise({sigID}, S.waitingKeyProfile) - storeRegistry - .getState('tracker2') - .dispatch.showUser(useCurrentUserState.getState().username, false) + storeRegistry.getState('tracker2').dispatch.showUser(useCurrentUserState.getState().username, false) } ignorePromise(f()) }, @@ -649,9 +647,7 @@ export const useProfileState = Z.createZustand((set, get) => { }, submitRevokeProof: proofId => { const f = async () => { - const you = storeRegistry - .getState('tracker2') - .getDetails(useCurrentUserState.getState().username) + const you = storeRegistry.getState('tracker2').getDetails(useCurrentUserState.getState().username) if (!you.assertions) return const proof = [...you.assertions.values()].find(a => a.sigID === proofId) if (!proof) return diff --git a/shared/constants/push.native.tsx b/shared/constants/push.native.tsx index 9e7995bfade6..253f5ae4cba2 100644 --- a/shared/constants/push.native.tsx +++ b/shared/constants/push.native.tsx @@ -3,8 +3,8 @@ import * as S from './strings' import {ignorePromise, neverThrowPromiseFunc, timeoutPromise} from './utils' import {navigateAppend, navUpToScreen, switchTab} from './router2/util' import {storeRegistry} from './store-registry' -import {useConfigState} from './config' -import {useCurrentUserState} from './current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import {useLogoutState} from './logout' import {useWaitingState} from './waiting' import * as Z from '@/util/zustand' diff --git a/shared/constants/recover-password/index.tsx b/shared/constants/recover-password/index.tsx index 8a642f8b9487..8346cd19876b 100644 --- a/shared/constants/recover-password/index.tsx +++ b/shared/constants/recover-password/index.tsx @@ -8,7 +8,7 @@ import {type Device} from '../provision' import {rpcDeviceToDevice} from '../rpc-utils' import {clearModals, navigateAppend, navigateUp} from '../router2/util' import {storeRegistry} from '../store-registry' -import {useConfigState} from '../config' +import {useConfigState} from '@/stores/config' type Store = T.Immutable<{ devices: Array @@ -225,9 +225,7 @@ export const useState = Z.createZustand((set, get) => { s.error = msg }) navigateAppend( - useConfigState.getState().loggedIn - ? 'recoverPasswordErrorModal' - : 'recoverPasswordError', + useConfigState.getState().loggedIn ? 'recoverPasswordErrorModal' : 'recoverPasswordError', true ) } diff --git a/shared/constants/settings-chat/index.tsx b/shared/constants/settings-chat/index.tsx index 615ba7a1981f..50cdeb918da0 100644 --- a/shared/constants/settings-chat/index.tsx +++ b/shared/constants/settings-chat/index.tsx @@ -2,7 +2,7 @@ import * as T from '../types' import {ignorePromise} from '../utils' import * as S from '../strings' import * as Z from '@/util/zustand' -import {useConfigState} from '../config' +import {useConfigState} from '@/stores/config' export type ChatUnfurlState = { unfurlMode?: T.RPCChat.UnfurlMode diff --git a/shared/constants/settings-contacts.native.tsx b/shared/constants/settings-contacts.native.tsx index 971a5bfdfab5..972a30151b52 100644 --- a/shared/constants/settings-contacts.native.tsx +++ b/shared/constants/settings-contacts.native.tsx @@ -11,8 +11,8 @@ import {getDefaultCountryCode} from 'react-native-kb' import {getE164} from './settings-phone' import {pluralize} from '@/util/string' import {navigateAppend} from './router2/util' -import {useConfigState} from './config' -import {useCurrentUserState} from './current-user' +import {useConfigState} from '@/stores/config' +import {useCurrentUserState} from '@/stores/current-user' import {useWaitingState} from './waiting' const importContactsConfigKey = (username: string) => `ui.importContacts.${username}` diff --git a/shared/constants/team-building/index.tsx b/shared/constants/team-building/index.tsx index ddef3357d5dc..ed0c5e633f0e 100644 --- a/shared/constants/team-building/index.tsx +++ b/shared/constants/team-building/index.tsx @@ -14,7 +14,7 @@ import {registerDebugClear} from '@/util/debug' import {searchWaitingKey} from './utils' import {navigateUp} from '../router2/util' import {storeRegistry} from '../store-registry' -import {useCryptoState} from '../crypto' +import {useCryptoState} from '@/stores/crypto' export {allServices, selfToUser, searchWaitingKey} from './utils' type Store = T.Immutable<{ diff --git a/shared/constants/wallets/index.tsx b/shared/constants/wallets/index.tsx index 3843d7919ea1..afd7a7acb144 100644 --- a/shared/constants/wallets/index.tsx +++ b/shared/constants/wallets/index.tsx @@ -2,7 +2,7 @@ import * as T from '../types' import {ignorePromise} from '../utils' import * as Z from '@/util/zustand' import {loadAccountsWaitingKey} from './utils' -import {useConfigState} from '../config' +import {useConfigState} from '@/stores/config' export {loadAccountsWaitingKey} from './utils' diff --git a/shared/stores/chat2.tsx b/shared/stores/chat2.tsx index b650042476fc..d61cc829079b 100644 --- a/shared/stores/chat2.tsx +++ b/shared/stores/chat2.tsx @@ -1995,7 +1995,7 @@ export function makeChatScreen>( export * from '@/constants/chat2/convostate' export * from '@/constants/chat2/common' export * from '@/constants/chat2/meta' -export * from './message' +export * from '@/constants/chat2/message' export { noConversationIDKey, From 23d7921ce5fa7c5c2ed99f8a8fe1004b502febd4 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:39:34 -0500 Subject: [PATCH 25/37] WIP --- shared/app/global-errors/hook.tsx | 2 +- shared/app/index.native.tsx | 2 +- shared/app/main.desktop.tsx | 2 +- shared/chat/blocking/invitation-to-block.tsx | 2 +- .../chat/conversation/header-area/index.native.tsx | 2 +- shared/chat/conversation/info-panel/members.tsx | 2 +- .../messages/message-popup/exploding-header.tsx | 2 +- .../conversation/messages/message-popup/header.tsx | 2 +- .../conversation/messages/message-popup/hooks.tsx | 2 +- shared/chat/conversation/messages/reset-user.tsx | 2 +- shared/chat/conversation/messages/separator.tsx | 2 +- shared/chat/conversation/rekey/container.tsx | 2 +- shared/common-adapters/mention-container.tsx | 2 +- shared/common-adapters/name-with-icon.tsx | 2 +- shared/common-adapters/profile-card.tsx | 2 +- shared/common-adapters/proof-broken-banner.tsx | 2 +- shared/common-adapters/usernames.tsx | 2 +- shared/constants/init/index.desktop.tsx | 2 +- shared/constants/init/index.native.tsx | 2 +- shared/constants/init/shared.tsx | 4 ++-- shared/constants/store-registry.tsx | 4 ++-- shared/desktop/renderer/main.desktop.tsx | 2 +- shared/desktop/renderer/main2.desktop.tsx | 2 +- shared/fs/banner/reset-banner.tsx | 2 +- shared/login/index.tsx | 2 +- shared/login/loading.tsx | 2 +- shared/menubar/files-container.desktop.tsx | 2 +- shared/menubar/remote-container.desktop.tsx | 4 ++-- shared/menubar/remote-proxy.desktop.tsx | 4 ++-- shared/people/container.tsx | 2 +- shared/people/todo.tsx | 2 +- shared/pinentry/remote-container.desktop.tsx | 2 +- shared/profile/confirm-or-pending.tsx | 2 +- shared/profile/edit-avatar/hooks.tsx | 2 +- shared/profile/edit-profile.tsx | 2 +- shared/profile/generic/enter-username.tsx | 2 +- shared/profile/generic/proofs-list.tsx | 2 +- shared/profile/generic/result.tsx | 2 +- shared/profile/pgp/finished/index.desktop.tsx | 2 +- shared/profile/pgp/generate/index.desktop.tsx | 2 +- shared/profile/pgp/info/index.desktop.tsx | 2 +- shared/profile/post-proof.tsx | 2 +- shared/profile/prove-enter-username.tsx | 2 +- shared/profile/prove-website-choice.tsx | 2 +- shared/profile/revoke.tsx | 2 +- shared/profile/user/friend.tsx | 2 +- shared/profile/user/hooks.tsx | 2 +- shared/router-v2/account-switcher/index.tsx | 2 +- shared/router-v2/router.desktop.tsx | 2 +- shared/router-v2/router.native.tsx | 4 ++-- shared/router-v2/router.shared.tsx | 2 +- shared/router-v2/tab-bar.desktop.tsx | 2 +- shared/settings/display.tsx | 2 +- shared/settings/invites/index.desktop.tsx | 2 +- shared/settings/logout.tsx | 2 +- .../daemon/index.tsx => stores/daemon.tsx} | 6 +++--- .../darkmode/index.tsx => stores/darkmode.tsx} | 4 ++-- .../logout/index.tsx => stores/logout.tsx} | 8 ++++---- .../profile/index.tsx => stores/profile.tsx} | 12 ++++++------ shared/styles/colors.tsx | 2 +- shared/styles/index.native.tsx | 2 +- shared/styles/style-sheet-proxy.tsx | 2 +- shared/teams/channel/rows.tsx | 2 +- shared/teams/external-team.tsx | 2 +- shared/teams/team/member/index.new.tsx | 2 +- shared/teams/team/rows/bot-row/bot.tsx | 2 +- shared/teams/team/rows/invite-row/request.tsx | 2 +- shared/teams/team/rows/member-row.tsx | 2 +- shared/tracker2/assertion.tsx | 2 +- shared/tracker2/remote-container.desktop.tsx | 2 +- shared/unlock-folders/remote-container.desktop.tsx | 2 +- 71 files changed, 87 insertions(+), 87 deletions(-) rename shared/{constants/daemon/index.tsx => stores/daemon.tsx} (98%) rename shared/{constants/darkmode/index.tsx => stores/darkmode.tsx} (97%) rename shared/{constants/logout/index.tsx => stores/logout.tsx} (93%) rename shared/{constants/profile/index.tsx => stores/profile.tsx} (98%) diff --git a/shared/app/global-errors/hook.tsx b/shared/app/global-errors/hook.tsx index 7a92cae51285..f35ad7056a9c 100644 --- a/shared/app/global-errors/hook.tsx +++ b/shared/app/global-errors/hook.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import {useConfigState} from '@/stores/config' import type {RPCError} from '@/util/errors' import {settingsFeedbackTab} from '@/constants/settings/util' -import {useDaemonState} from '@/constants/daemon' +import {useDaemonState} from '@/stores/daemon' export type Size = 'Closed' | 'Small' | 'Big' diff --git a/shared/app/index.native.tsx b/shared/app/index.native.tsx index 37ca9ac4da1d..2a1c1337b56d 100644 --- a/shared/app/index.native.tsx +++ b/shared/app/index.native.tsx @@ -18,7 +18,7 @@ import ServiceDecoration from '@/common-adapters/markdown/service-decoration' import {useUnmountAll} from '@/util/debug-react' import {darkModeSupported, guiConfig} from 'react-native-kb' import {install} from 'react-native-kb' -import * as DarkMode from '@/constants/darkmode' +import * as DarkMode from '@/stores/darkmode' import {initPlatformListener, onEngineConnected, onEngineDisconnected, onEngineIncoming} from '@/constants/init/index.native' enableFreeze(true) diff --git a/shared/app/main.desktop.tsx b/shared/app/main.desktop.tsx index 16ef0670516d..12bd8e36da36 100644 --- a/shared/app/main.desktop.tsx +++ b/shared/app/main.desktop.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import Router from '@/router-v2/router' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' import ResetModal from '../login/reset/modal' import GlobalError from './global-errors' import OutOfDate from './out-of-date' diff --git a/shared/chat/blocking/invitation-to-block.tsx b/shared/chat/blocking/invitation-to-block.tsx index 98d3d040fe4c..9e124e37d688 100644 --- a/shared/chat/blocking/invitation-to-block.tsx +++ b/shared/chat/blocking/invitation-to-block.tsx @@ -1,5 +1,5 @@ import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/chat/conversation/header-area/index.native.tsx b/shared/chat/conversation/header-area/index.native.tsx index 6ae6aa6e6411..ceaaff316fdd 100644 --- a/shared/chat/conversation/header-area/index.native.tsx +++ b/shared/chat/conversation/header-area/index.native.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import * as React from 'react' import type {HeaderBackButtonProps} from '@react-navigation/elements' diff --git a/shared/chat/conversation/info-panel/members.tsx b/shared/chat/conversation/info-panel/members.tsx index 2e6387126774..72b3a4405985 100644 --- a/shared/chat/conversation/info-panel/members.tsx +++ b/shared/chat/conversation/info-panel/members.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Teams from '@/stores/teams' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/chat/conversation/messages/message-popup/exploding-header.tsx b/shared/chat/conversation/messages/message-popup/exploding-header.tsx index e390b96f7879..7d691f4b30b8 100644 --- a/shared/chat/conversation/messages/message-popup/exploding-header.tsx +++ b/shared/chat/conversation/messages/message-popup/exploding-header.tsx @@ -1,5 +1,5 @@ import * as React from 'react' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import {formatTimeForPopup, formatTimeForRevoked, msToDHMS} from '@/util/timestamp' import {addTicker, removeTicker} from '@/util/second-timer' diff --git a/shared/chat/conversation/messages/message-popup/header.tsx b/shared/chat/conversation/messages/message-popup/header.tsx index d0221144273a..d57e76ad84f5 100644 --- a/shared/chat/conversation/messages/message-popup/header.tsx +++ b/shared/chat/conversation/messages/message-popup/header.tsx @@ -1,6 +1,6 @@ import * as Kb from '@/common-adapters' import * as React from 'react' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {formatTimeForPopup, formatTimeForRevoked} from '@/util/timestamp' import type * as T from '@/constants/types' diff --git a/shared/chat/conversation/messages/message-popup/hooks.tsx b/shared/chat/conversation/messages/message-popup/hooks.tsx index 0bccbdb2510f..5a55ddf164ab 100644 --- a/shared/chat/conversation/messages/message-popup/hooks.tsx +++ b/shared/chat/conversation/messages/message-popup/hooks.tsx @@ -4,7 +4,7 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' import {useConfigState} from '@/stores/config' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useCurrentUserState} from '@/stores/current-user' import {linkFromConvAndMessage} from '@/constants/deeplinks' import ReactionItem from './reactionitem' diff --git a/shared/chat/conversation/messages/reset-user.tsx b/shared/chat/conversation/messages/reset-user.tsx index cfc6f5694cd0..5ef6bde4ba85 100644 --- a/shared/chat/conversation/messages/reset-user.tsx +++ b/shared/chat/conversation/messages/reset-user.tsx @@ -1,5 +1,5 @@ import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' const ResetUser = () => { diff --git a/shared/chat/conversation/messages/separator.tsx b/shared/chat/conversation/messages/separator.tsx index 567cf91a6269..877beff3ad3a 100644 --- a/shared/chat/conversation/messages/separator.tsx +++ b/shared/chat/conversation/messages/separator.tsx @@ -8,7 +8,7 @@ import {formatTimeForConversationList, formatTimeForChat} from '@/util/timestamp import {OrangeLineContext} from '../orange-line-context' import logger from '@/logger' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useCurrentUserState} from '@/stores/current-user' // import {useChatDebugDump} from '@/constants/chat2/debug' diff --git a/shared/chat/conversation/rekey/container.tsx b/shared/chat/conversation/rekey/container.tsx index ad910c500867..8cc2428b7f7b 100644 --- a/shared/chat/conversation/rekey/container.tsx +++ b/shared/chat/conversation/rekey/container.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useCurrentUserState} from '@/stores/current-user' import * as T from '@/constants/types' import ParticipantRekey from './participant-rekey' diff --git a/shared/common-adapters/mention-container.tsx b/shared/common-adapters/mention-container.tsx index 8c675e935840..f7044658c04c 100644 --- a/shared/common-adapters/mention-container.tsx +++ b/shared/common-adapters/mention-container.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' import Mention, {type OwnProps} from './mention' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/common-adapters/name-with-icon.tsx b/shared/common-adapters/name-with-icon.tsx index 2c44ab45880f..07c7f2c4f3c7 100644 --- a/shared/common-adapters/name-with-icon.tsx +++ b/shared/common-adapters/name-with-icon.tsx @@ -14,7 +14,7 @@ import Text, { } from './text' import ConnectedUsernames from './usernames' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' type Size = 'smaller' | 'small' | 'default' | 'big' | 'huge' diff --git a/shared/common-adapters/profile-card.tsx b/shared/common-adapters/profile-card.tsx index 19cea7b4493d..a053acccd437 100644 --- a/shared/common-adapters/profile-card.tsx +++ b/shared/common-adapters/profile-card.tsx @@ -12,7 +12,7 @@ import {_setWithProfileCardPopup} from './usernames' import FloatingMenu from './floating-menu' import Icon from './icon' import Meta from './meta' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' import ProgressIndicator from './progress-indicator' diff --git a/shared/common-adapters/proof-broken-banner.tsx b/shared/common-adapters/proof-broken-banner.tsx index 13bf311e732a..e1ecfd0cb296 100644 --- a/shared/common-adapters/proof-broken-banner.tsx +++ b/shared/common-adapters/proof-broken-banner.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import {Banner, BannerParagraph} from './banner' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' const Kb = {Banner} type Props = {users?: Array} diff --git a/shared/common-adapters/usernames.tsx b/shared/common-adapters/usernames.tsx index 1b0047cc96f0..570f91b6abab 100644 --- a/shared/common-adapters/usernames.tsx +++ b/shared/common-adapters/usernames.tsx @@ -14,7 +14,7 @@ import isArray from 'lodash/isArray' import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' import {useTrackerState} from '@/stores/tracker2' import {useUsersState} from '@/stores/users' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/constants/init/index.desktop.tsx b/shared/constants/init/index.desktop.tsx index 435f8f4c3263..89ba3681193b 100644 --- a/shared/constants/init/index.desktop.tsx +++ b/shared/constants/init/index.desktop.tsx @@ -5,7 +5,7 @@ import {useConfigState} from '@/stores/config' import * as ConfigConstants from '@/stores/config' import {useDaemonState} from '../daemon' import {useFSState} from '../fs' -import {useProfileState} from '../profile' +import {useProfileState} from '@/stores/profile' import {useRouterState} from '../router2' import * as EngineGen from '@/actions/engine-gen-gen' import * as T from '../types' diff --git a/shared/constants/init/index.native.tsx b/shared/constants/init/index.native.tsx index c856ceb02612..c88c34c87e2c 100644 --- a/shared/constants/init/index.native.tsx +++ b/shared/constants/init/index.native.tsx @@ -6,7 +6,7 @@ import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '../daemon' import {useDarkModeState} from '../darkmode' import {useFSState} from '../fs' -import {useProfileState} from '../profile' +import {useProfileState} from '@/stores/profile' import {useRouterState} from '../router2' import {useSettingsContactsState} from '../settings-contacts' import * as T from '../types' diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 7d311dc1da98..375b77c6d8ba 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -13,8 +13,8 @@ import {getSelectedConversation} from '@/constants/chat2/common' import type * as UseChatStateType from '@/stores/chat2' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useDaemonState} from '../daemon' -import {useDarkModeState} from '../darkmode' +import {useDaemonState} from '@/stores/daemon' +import {useDarkModeState} from '@/stores/darkmode' import * as DeepLinksUtil from '../deeplinks/util' import {useFollowerState} from '@/stores/followers' import isEqual from 'lodash/isEqual' diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 1b81f0472643..4da9db30cb6b 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -7,13 +7,13 @@ import type {ConvoState} from '@/constants/chat2/convostate' import type {State as AutoResetState, useAutoResetState} from '@/stores/autoreset' import type {State as BotsState, useBotsState} from '@/stores/bots' import type {State as ChatState, useChatState} from '@/stores/chat2' -import type {State as DaemonState, useDaemonState} from '@/constants/daemon' +import type {State as DaemonState, useDaemonState} from '@/stores/daemon' import type {State as DevicesState, useDevicesState} from '@/stores/devices' import type {State as FSState, useFSState} from '@/stores/fs' import type {State as GitState, useGitState} from '@/stores/git' import type {State as NotificationsState, useNotifState} from '@/stores/notifications' import type {State as PeopleState, usePeopleState} from '@/stores/people' -import type {State as ProfileState, useProfileState} from '@/constants/profile' +import type {State as ProfileState, useProfileState} from '@/stores/profile' import type {State as ProvisionState, useProvisionState} from '@/constants/provision' import type {State as PushState, usePushState} from '@/constants/push' import type { diff --git a/shared/desktop/renderer/main.desktop.tsx b/shared/desktop/renderer/main.desktop.tsx index 640693e7a1bd..f216bfdfa816 100644 --- a/shared/desktop/renderer/main.desktop.tsx +++ b/shared/desktop/renderer/main.desktop.tsx @@ -3,7 +3,7 @@ import './globals.desktop' import {isDarwin, isWindows} from '@/constants/platform' import '@/util/why-did-you-render' import KB2, {waitOnKB2Loaded} from '@/util/electron.desktop' -import * as DarkMode from '@/constants/darkmode' +import * as DarkMode from '@/stores/darkmode' waitOnKB2Loaded(() => { const {setSystemSupported, setSystemDarkMode} = DarkMode.useDarkModeState.getState().dispatch diff --git a/shared/desktop/renderer/main2.desktop.tsx b/shared/desktop/renderer/main2.desktop.tsx index 141518adb2a8..9a4faab9139f 100644 --- a/shared/desktop/renderer/main2.desktop.tsx +++ b/shared/desktop/renderer/main2.desktop.tsx @@ -25,7 +25,7 @@ import {debugWarning} from '@/util/debug-warning' import type {default as NewMainType} from '../../app/main.desktop' import {setServiceDecoration} from '@/common-adapters/markdown/react' import ServiceDecoration from '@/common-adapters/markdown/service-decoration' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' import {initPlatformListener, onEngineIncoming} from '@/constants/init/index.desktop' setServiceDecoration(ServiceDecoration) diff --git a/shared/fs/banner/reset-banner.tsx b/shared/fs/banner/reset-banner.tsx index 061e5499db3a..ab2366b4175d 100644 --- a/shared/fs/banner/reset-banner.tsx +++ b/shared/fs/banner/reset-banner.tsx @@ -7,7 +7,7 @@ import * as RowTypes from '@/fs/browser/rows/types' import {useTrackerState} from '@/stores/tracker2' import {useFSState} from '@/stores/fs' import * as FS from '@/stores/fs' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' type OwnProps = {path: T.FS.Path} diff --git a/shared/login/index.tsx b/shared/login/index.tsx index 2a7438c66031..1c052d3559d0 100644 --- a/shared/login/index.tsx +++ b/shared/login/index.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import {useConfigState} from '@/stores/config' -import {useDaemonState} from '@/constants/daemon' +import {useDaemonState} from '@/stores/daemon' const Loading = React.lazy(async () => import('./loading')) const Relogin = React.lazy(async () => import('./relogin/container')) diff --git a/shared/login/loading.tsx b/shared/login/loading.tsx index 7d48b3dec130..41237f127c88 100644 --- a/shared/login/loading.tsx +++ b/shared/login/loading.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' -import {useDaemonState} from '@/constants/daemon' +import {useDaemonState} from '@/stores/daemon' const SplashContainer = () => { const failedReason = useDaemonState(s => s.handshakeFailedReason) diff --git a/shared/menubar/files-container.desktop.tsx b/shared/menubar/files-container.desktop.tsx index e1b20cc9f284..aea7e75c0361 100644 --- a/shared/menubar/files-container.desktop.tsx +++ b/shared/menubar/files-container.desktop.tsx @@ -1,4 +1,4 @@ -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as R from '@/constants/remote' import * as T from '@/constants/types' import * as RemoteGen from '../actions/remote-gen' diff --git a/shared/menubar/remote-container.desktop.tsx b/shared/menubar/remote-container.desktop.tsx index 129fda71de8c..ed5a78d8ee00 100644 --- a/shared/menubar/remote-container.desktop.tsx +++ b/shared/menubar/remote-container.desktop.tsx @@ -7,8 +7,8 @@ import {useAvatarState} from '@/common-adapters/avatar/store' import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' -import {useDaemonState} from '@/constants/daemon' -import {useDarkModeState} from '@/constants/darkmode' +import {useDaemonState} from '@/stores/daemon' +import {useDarkModeState} from '@/stores/darkmode' const RemoteContainer = (d: DeserializeProps) => { const {avatarRefreshCounter, badgeMap, daemonHandshakeState, darkMode, diskSpaceStatus, endEstimate} = d diff --git a/shared/menubar/remote-proxy.desktop.tsx b/shared/menubar/remote-proxy.desktop.tsx index d5f3d343e5b6..4e79d95e0e4e 100644 --- a/shared/menubar/remote-proxy.desktop.tsx +++ b/shared/menubar/remote-proxy.desktop.tsx @@ -18,8 +18,8 @@ import {useFollowerState} from '@/stores/followers' import {useUsersState} from '@/stores/users' import {useNotifState} from '@/stores/notifications' import {useCurrentUserState} from '@/stores/current-user' -import {useDaemonState} from '@/constants/daemon' -import {useDarkModeState} from '@/constants/darkmode' +import {useDaemonState} from '@/stores/daemon' +import {useDarkModeState} from '@/stores/darkmode' const {showTray} = KB2.functions diff --git a/shared/people/container.tsx b/shared/people/container.tsx index a1690a728896..3016d4fe3cce 100644 --- a/shared/people/container.tsx +++ b/shared/people/container.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import People from '.' import {useSignupState} from '@/stores/signup' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {usePeopleState, getPeopleDataWaitingKey} from '@/stores/people' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index d69b09886fe1..3d1fd9cb1a6e 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -10,7 +10,7 @@ import {useSettingsPhoneState} from '@/constants/settings-phone' import {useSettingsEmailState} from '@/constants/settings-email' import {settingsAccountTab, settingsGitTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {usePeopleState, todoTypes} from '@/stores/people' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/pinentry/remote-container.desktop.tsx b/shared/pinentry/remote-container.desktop.tsx index 97f0967a1e16..316f528a9e14 100644 --- a/shared/pinentry/remote-container.desktop.tsx +++ b/shared/pinentry/remote-container.desktop.tsx @@ -3,7 +3,7 @@ import * as RemoteGen from '../actions/remote-gen' import * as R from '@/constants/remote' import Pinentry from './index.desktop' import type {DeserializeProps} from './remote-serializer.desktop' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' const RemoteContainer = (d: DeserializeProps) => { const {darkMode, ...rest} = d diff --git a/shared/profile/confirm-or-pending.tsx b/shared/profile/confirm-or-pending.tsx index e0a49954bb5a..f33f9325224e 100644 --- a/shared/profile/confirm-or-pending.tsx +++ b/shared/profile/confirm-or-pending.tsx @@ -1,4 +1,4 @@ -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {subtitle} from '@/util/platforms' diff --git a/shared/profile/edit-avatar/hooks.tsx b/shared/profile/edit-avatar/hooks.tsx index 9113da8924dd..2455064629a1 100644 --- a/shared/profile/edit-avatar/hooks.tsx +++ b/shared/profile/edit-avatar/hooks.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/profile/edit-profile.tsx b/shared/profile/edit-profile.tsx index 8559024e31c8..c153a4866cf4 100644 --- a/shared/profile/edit-profile.tsx +++ b/shared/profile/edit-profile.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useCurrentUserState} from '@/stores/current-user' const Container = () => { diff --git a/shared/profile/generic/enter-username.tsx b/shared/profile/generic/enter-username.tsx index 41fee450433c..550411e67338 100644 --- a/shared/profile/generic/enter-username.tsx +++ b/shared/profile/generic/enter-username.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import openURL from '@/util/open-url' import * as React from 'react' import * as Kb from '@/common-adapters' diff --git a/shared/profile/generic/proofs-list.tsx b/shared/profile/generic/proofs-list.tsx index 7e5deec234ce..ffbfa6fe9f16 100644 --- a/shared/profile/generic/proofs-list.tsx +++ b/shared/profile/generic/proofs-list.tsx @@ -6,7 +6,7 @@ import {SiteIcon} from './shared' import {makeInsertMatcher} from '@/util/string' import {useColorScheme} from 'react-native' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' const Container = () => { const _proofSuggestions = useTrackerState(s => s.proofSuggestions) diff --git a/shared/profile/generic/result.tsx b/shared/profile/generic/result.tsx index db0e0b49a419..765700b8b568 100644 --- a/shared/profile/generic/result.tsx +++ b/shared/profile/generic/result.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import {SiteIcon} from './shared' diff --git a/shared/profile/pgp/finished/index.desktop.tsx b/shared/profile/pgp/finished/index.desktop.tsx index 89e7f6c192cb..22e9341df3e8 100644 --- a/shared/profile/pgp/finished/index.desktop.tsx +++ b/shared/profile/pgp/finished/index.desktop.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as React from 'react' import * as Kb from '@/common-adapters' import Modal from '@/profile/modal' diff --git a/shared/profile/pgp/generate/index.desktop.tsx b/shared/profile/pgp/generate/index.desktop.tsx index ed1be8203b1a..b144be1e0b6b 100644 --- a/shared/profile/pgp/generate/index.desktop.tsx +++ b/shared/profile/pgp/generate/index.desktop.tsx @@ -1,6 +1,6 @@ import * as Kb from '@/common-adapters' import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import Modal from '@/profile/modal' export default function Generate() { diff --git a/shared/profile/pgp/info/index.desktop.tsx b/shared/profile/pgp/info/index.desktop.tsx index af9859070160..8da249f27ec5 100644 --- a/shared/profile/pgp/info/index.desktop.tsx +++ b/shared/profile/pgp/info/index.desktop.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import Modal from '@/profile/modal' diff --git a/shared/profile/post-proof.tsx b/shared/profile/post-proof.tsx index 37fb56c5b665..7f52f1b555be 100644 --- a/shared/profile/post-proof.tsx +++ b/shared/profile/post-proof.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as React from 'react' import * as Kb from '@/common-adapters' import {subtitle} from '@/util/platforms' diff --git a/shared/profile/prove-enter-username.tsx b/shared/profile/prove-enter-username.tsx index f64207564d86..5bd8cc0d1398 100644 --- a/shared/profile/prove-enter-username.tsx +++ b/shared/profile/prove-enter-username.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as React from 'react' import * as Kb from '@/common-adapters' import Modal from './modal' diff --git a/shared/profile/prove-website-choice.tsx b/shared/profile/prove-website-choice.tsx index 7eabba0143a9..ff6e664c9f14 100644 --- a/shared/profile/prove-website-choice.tsx +++ b/shared/profile/prove-website-choice.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import Modal from './modal' diff --git a/shared/profile/revoke.tsx b/shared/profile/revoke.tsx index 5fa5097c28f8..aa34864f41ae 100644 --- a/shared/profile/revoke.tsx +++ b/shared/profile/revoke.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import capitalize from 'lodash/capitalize' import {subtitle as platformSubtitle} from '@/util/platforms' diff --git a/shared/profile/user/friend.tsx b/shared/profile/user/friend.tsx index ad9a2191d4a2..462965aaa940 100644 --- a/shared/profile/user/friend.tsx +++ b/shared/profile/user/friend.tsx @@ -1,4 +1,4 @@ -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import {useUsersState} from '@/stores/users' diff --git a/shared/profile/user/hooks.tsx b/shared/profile/user/hooks.tsx index 520cc3dae804..b3848ac98bbd 100644 --- a/shared/profile/user/hooks.tsx +++ b/shared/profile/user/hooks.tsx @@ -3,7 +3,7 @@ import type * as T from '@/constants/types' import {type BackgroundColorType} from '.' import {useColorScheme} from 'react-native' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/router-v2/account-switcher/index.tsx b/shared/router-v2/account-switcher/index.tsx index 4ff98df6a83e..cad9658bf1b8 100644 --- a/shared/router-v2/account-switcher/index.tsx +++ b/shared/router-v2/account-switcher/index.tsx @@ -6,7 +6,7 @@ import * as React from 'react' import type * as T from '@/constants/types' import {settingsLogOutTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/stores/current-user' import {useProvisionState} from '@/constants/provision' diff --git a/shared/router-v2/router.desktop.tsx b/shared/router-v2/router.desktop.tsx index 025c049ab445..51816647e878 100644 --- a/shared/router-v2/router.desktop.tsx +++ b/shared/router-v2/router.desktop.tsx @@ -16,7 +16,7 @@ import {modalRoutes, routes, loggedOutRoutes, tabRoots} from './routes' import {registerDebugClear} from '@/util/debug' import type {RootParamList} from '@/router-v2/route-params' import {useCurrentUserState} from '@/stores/current-user' -import {useDaemonState} from '@/constants/daemon' +import {useDaemonState} from '@/stores/daemon' import type {NativeStackNavigationOptions} from '@react-navigation/native-stack' import './router.css' diff --git a/shared/router-v2/router.native.tsx b/shared/router-v2/router.native.tsx index a5e3339fd990..28a7d05bb5eb 100644 --- a/shared/router-v2/router.native.tsx +++ b/shared/router-v2/router.native.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Constants from '@/constants/router2' import {useConfigState} from '@/stores/config' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' import * as Kb from '@/common-adapters' import * as React from 'react' import * as Shared from './router.shared' @@ -20,7 +20,7 @@ import * as Hooks from './hooks.native' import * as TabBar from './tab-bar.native' import type {RootParamList} from '@/router-v2/route-params' import {useColorScheme} from 'react-native' -import {useDaemonState} from '@/constants/daemon' +import {useDaemonState} from '@/stores/daemon' if (module.hot) { module.hot.accept('', () => {}) diff --git a/shared/router-v2/router.shared.tsx b/shared/router-v2/router.shared.tsx index a163de1ca0e3..e0bb7847af68 100644 --- a/shared/router-v2/router.shared.tsx +++ b/shared/router-v2/router.shared.tsx @@ -5,7 +5,7 @@ import {Splash} from '../login/loading' import type {Theme} from '@react-navigation/native' import {colors, darkColors, themed} from '@/styles/colors' import {useFSState} from '@/stores/fs' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' export const SimpleLoading = React.memo(function SimpleLoading() { return ( diff --git a/shared/router-v2/tab-bar.desktop.tsx b/shared/router-v2/tab-bar.desktop.tsx index 02fac7c03183..1649b65ac0ef 100644 --- a/shared/router-v2/tab-bar.desktop.tsx +++ b/shared/router-v2/tab-bar.desktop.tsx @@ -16,7 +16,7 @@ import './tab-bar.css' import {settingsLogOutTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' import {useFSState} from '@/stores/fs' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useNotifState} from '@/stores/notifications' import {useCurrentUserState} from '@/stores/current-user' import {useProvisionState} from '@/constants/provision' diff --git a/shared/settings/display.tsx b/shared/settings/display.tsx index 4dd48300dd40..f7ab52aafed4 100644 --- a/shared/settings/display.tsx +++ b/shared/settings/display.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import logger from '@/logger' import {useConfigState} from '@/stores/config' -import * as DarkMode from '@/constants/darkmode' +import * as DarkMode from '@/stores/darkmode' const Display = () => { const allowAnimatedEmojis = useConfigState(s => s.allowAnimatedEmojis) diff --git a/shared/settings/invites/index.desktop.tsx b/shared/settings/invites/index.desktop.tsx index 0636b633ea3b..c46bf9fefdd2 100644 --- a/shared/settings/invites/index.desktop.tsx +++ b/shared/settings/invites/index.desktop.tsx @@ -4,7 +4,7 @@ import * as React from 'react' import SubHeading from '../subheading' import * as dateFns from 'date-fns' import * as C from '@/constants' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useState as useSettingsInvitesState} from '@/constants/settings-invites' // Like intersperse but takes a function to define the separator diff --git a/shared/settings/logout.tsx b/shared/settings/logout.tsx index e16bce574a43..ce846ef17ed8 100644 --- a/shared/settings/logout.tsx +++ b/shared/settings/logout.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import {UpdatePassword} from './password' import {usePWState} from '@/constants/settings-password' import {useSettingsState} from '@/stores/settings' -import {useLogoutState} from '@/constants/logout' +import {useLogoutState} from '@/stores/logout' const LogoutContainer = () => { const {checkPassword, checkPasswordIsCorrect, resetCheckPassword} = useSettingsState( diff --git a/shared/constants/daemon/index.tsx b/shared/stores/daemon.tsx similarity index 98% rename from shared/constants/daemon/index.tsx rename to shared/stores/daemon.tsx index f87e335f757b..340fcd3949e5 100644 --- a/shared/constants/daemon/index.tsx +++ b/shared/stores/daemon.tsx @@ -1,8 +1,8 @@ import logger from '@/logger' -import {ignorePromise} from '../utils' -import * as T from '../types' +import {ignorePromise} from '@/constants/utils' +import * as T from '@/constants/types' import * as Z from '@/util/zustand' -import {maxHandshakeTries} from '../values' +import {maxHandshakeTries} from '@/constants/values' // Load accounts, this call can be slow so we attempt to continue w/o waiting if we determine we're logged in // normally this wouldn't be worth it but this is startup diff --git a/shared/constants/darkmode/index.tsx b/shared/stores/darkmode.tsx similarity index 97% rename from shared/constants/darkmode/index.tsx rename to shared/stores/darkmode.tsx index fa4d7a445ed1..c616904f1e4e 100644 --- a/shared/constants/darkmode/index.tsx +++ b/shared/stores/darkmode.tsx @@ -1,7 +1,7 @@ -import * as T from '../types' +import * as T from '@/constants/types' import * as Z from '@/util/zustand' import {Appearance} from 'react-native' -import {isMobile} from '../platform' +import {isMobile} from '@/constants/platform' export type DarkModePreference = 'system' | 'alwaysDark' | 'alwaysLight' diff --git a/shared/constants/logout/index.tsx b/shared/stores/logout.tsx similarity index 93% rename from shared/constants/logout/index.tsx rename to shared/stores/logout.tsx index bcf8c637a648..1f4983b4fa0d 100644 --- a/shared/constants/logout/index.tsx +++ b/shared/stores/logout.tsx @@ -1,12 +1,12 @@ import logger from '@/logger' -import {ignorePromise, timeoutPromise} from '../utils' +import {ignorePromise, timeoutPromise} from '@/constants/utils' import * as T from '@/constants/types' // normally util.container but it re-exports from us so break the cycle import * as Z from '@/util/zustand' import {settingsPasswordTab} from '@/constants/settings/util' -import {navigateAppend} from '../router2/util' -import {isMobile} from '../platform' -import * as Tabs from '../tabs' +import {navigateAppend} from '@/constants/router2/util' +import {isMobile} from '@/constants/platform' +import * as Tabs from '@/constants/tabs' // This store has no dependencies on other stores and is safe to import directly from other stores. type Store = T.Immutable<{ diff --git a/shared/constants/profile/index.tsx b/shared/stores/profile.tsx similarity index 98% rename from shared/constants/profile/index.tsx rename to shared/stores/profile.tsx index ffc4e6c8fc84..8d1f42ea1fef 100644 --- a/shared/constants/profile/index.tsx +++ b/shared/stores/profile.tsx @@ -1,16 +1,16 @@ -import * as T from '../types' -import {generateGUIID, ignorePromise, wrapErrors} from '../utils' -import * as S from '../strings' +import * as T from '@/constants/types' +import {generateGUIID, ignorePromise, wrapErrors} from '@/constants/utils' +import * as S from '@/constants/strings' import * as Validators from '@/util/simple-validators' import * as Z from '@/util/zustand' import logger from '@/logger' import openURL from '@/util/open-url' import {RPCError} from '@/util/errors' import {fixCrop} from '@/util/crop' -import {clearModals, navigateAppend, navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' +import {clearModals, navigateAppend, navigateUp} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' import {useCurrentUserState} from '@/stores/current-user' -import {navToProfile} from '../router2/util' +import {navToProfile} from '@/constants/router2/util' type ProveGenericParams = { logoBlack: T.Tracker.SiteIconSet diff --git a/shared/styles/colors.tsx b/shared/styles/colors.tsx index f84ad80c59b3..76c0da24acae 100644 --- a/shared/styles/colors.tsx +++ b/shared/styles/colors.tsx @@ -1,5 +1,5 @@ // the _on_white are precomputed colors so we can do less blending on mobile -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' import {isIOS, isAndroid} from '@/constants/platform' import type {DynamicColorIOS as DynamicColorIOSType} from 'react-native' import type {Opaque} from '@/constants/types/ts' diff --git a/shared/styles/index.native.tsx b/shared/styles/index.native.tsx index 0fc8b52b108c..a15e6e2db217 100644 --- a/shared/styles/index.native.tsx +++ b/shared/styles/index.native.tsx @@ -2,7 +2,7 @@ import * as Shared from './shared' import {colors as lightColors} from './colors' import styleSheetCreateProxy, {type MapToStyles} from './style-sheet-proxy' import {StyleSheet, Dimensions} from 'react-native' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' import {isIOS, isTablet} from '@/constants/platform' const font = isIOS diff --git a/shared/styles/style-sheet-proxy.tsx b/shared/styles/style-sheet-proxy.tsx index 37cb8404f801..a6d33b090b3b 100644 --- a/shared/styles/style-sheet-proxy.tsx +++ b/shared/styles/style-sheet-proxy.tsx @@ -1,4 +1,4 @@ -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' import type {StylesCrossPlatform} from '.' // Support a closure to enable simple dark mode. diff --git a/shared/teams/channel/rows.tsx b/shared/teams/channel/rows.tsx index 4ce779671cd8..5c77b0f6a518 100644 --- a/shared/teams/channel/rows.tsx +++ b/shared/teams/channel/rows.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Teams from '@/stores/teams' import type * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/teams/external-team.tsx b/shared/teams/external-team.tsx index 8d245ab0a3b3..9fd9da9f4f66 100644 --- a/shared/teams/external-team.tsx +++ b/shared/teams/external-team.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' diff --git a/shared/teams/team/member/index.new.tsx b/shared/teams/team/member/index.new.tsx index 591f38dac230..c5bcd10e5aa9 100644 --- a/shared/teams/team/member/index.new.tsx +++ b/shared/teams/team/member/index.new.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Chat from '@/stores/chat2' import {useCurrentUserState} from '@/stores/current-user' import * as Teams from '@/stores/teams' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as React from 'react' diff --git a/shared/teams/team/rows/bot-row/bot.tsx b/shared/teams/team/rows/bot-row/bot.tsx index 4509c8395169..4724d6429e39 100644 --- a/shared/teams/team/rows/bot-row/bot.tsx +++ b/shared/teams/team/rows/bot-row/bot.tsx @@ -6,7 +6,7 @@ import type * as T from '@/constants/types' import BotMenu from './bot-menu' import {useBotsState} from '@/stores/bots' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' export type Props = { botAlias: string diff --git a/shared/teams/team/rows/invite-row/request.tsx b/shared/teams/team/rows/invite-row/request.tsx index ca4b7bee8beb..36be8c8e829c 100644 --- a/shared/teams/team/rows/invite-row/request.tsx +++ b/shared/teams/team/rows/invite-row/request.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import * as C from '@/constants' import * as Chat from '@/stores/chat2' import * as Teams from '@/stores/teams' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import {FloatingRolePicker, sendNotificationFooter} from '@/teams/role-picker' diff --git a/shared/teams/team/rows/member-row.tsx b/shared/teams/team/rows/member-row.tsx index 2b163c88e1f1..7fc8920b2a01 100644 --- a/shared/teams/team/rows/member-row.tsx +++ b/shared/teams/team/rows/member-row.tsx @@ -7,7 +7,7 @@ import type * as T from '@/constants/types' import MenuHeader from './menu-header.new' import {useSafeNavigation} from '@/util/safe-navigation' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/tracker2/assertion.tsx b/shared/tracker2/assertion.tsx index a3a1cc41a7de..41a35459911b 100644 --- a/shared/tracker2/assertion.tsx +++ b/shared/tracker2/assertion.tsx @@ -10,7 +10,7 @@ import {formatTimeForAssertionPopup} from '@/util/timestamp' import {useColorScheme} from 'react-native' import * as Tracker from '@/stores/tracker2' import {useTrackerState} from '@/stores/tracker2' -import {useProfileState} from '@/constants/profile' +import {useProfileState} from '@/stores/profile' type OwnProps = { isSuggestion?: boolean diff --git a/shared/tracker2/remote-container.desktop.tsx b/shared/tracker2/remote-container.desktop.tsx index ba1d3556bc29..4433a19c09b2 100644 --- a/shared/tracker2/remote-container.desktop.tsx +++ b/shared/tracker2/remote-container.desktop.tsx @@ -13,7 +13,7 @@ import {useTrackerState} from '@/stores/tracker2' import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' const {closeWindow} = KB2.functions diff --git a/shared/unlock-folders/remote-container.desktop.tsx b/shared/unlock-folders/remote-container.desktop.tsx index 196e2331f6c6..18db5590d794 100644 --- a/shared/unlock-folders/remote-container.desktop.tsx +++ b/shared/unlock-folders/remote-container.desktop.tsx @@ -4,7 +4,7 @@ import * as RemoteGen from '../actions/remote-gen' import UnlockFolders from './index.desktop' import type {DeserializeProps} from './remote-serializer.desktop' import {useUnlockFoldersState as useUFState} from '@/stores/unlock-folders' -import {useDarkModeState} from '@/constants/darkmode' +import {useDarkModeState} from '@/stores/darkmode' const RemoteContainer = (d: DeserializeProps) => { const {darkMode, devices, waiting, paperKeyError: _error} = d From 5cd1e97605e8c39c6b096a3c3ced689f2749bd08 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:43:52 -0500 Subject: [PATCH 26/37] WIP --- shared/constants/init/index.desktop.tsx | 18 ++++++++--------- shared/constants/init/index.native.tsx | 18 ++++++++--------- .../platform-specific/push.native.tsx | 2 +- shared/constants/push.native.tsx | 20 +++++++++---------- shared/constants/settings-password/index.tsx | 10 +++++----- 5 files changed, 34 insertions(+), 34 deletions(-) diff --git a/shared/constants/init/index.desktop.tsx b/shared/constants/init/index.desktop.tsx index 89ba3681193b..1284e6624e1f 100644 --- a/shared/constants/init/index.desktop.tsx +++ b/shared/constants/init/index.desktop.tsx @@ -1,24 +1,24 @@ // links all the stores together, stores never import this import * as Chat from '@/stores/chat2' -import {ignorePromise} from '../utils' +import {ignorePromise} from '@/constants/utils' import {useConfigState} from '@/stores/config' import * as ConfigConstants from '@/stores/config' -import {useDaemonState} from '../daemon' -import {useFSState} from '../fs' +import {useDaemonState} from '@/stores/daemon' +import {useFSState} from '@/constants/fs' import {useProfileState} from '@/stores/profile' -import {useRouterState} from '../router2' +import {useRouterState} from '@/constants/router2' import * as EngineGen from '@/actions/engine-gen-gen' -import * as T from '../types' -import InputMonitor from '../platform-specific/input-monitor.desktop' +import * as T from '@/constants/types' +import InputMonitor from '@/constants/platform-specific/input-monitor.desktop' import KB2 from '@/util/electron.desktop' import logger from '@/logger' import type {RPCError} from '@/util/errors' import {getEngine} from '@/engine' -import {isLinux, isWindows} from '../platform.desktop' -import {kbfsNotification} from '../platform-specific/kbfs-notifications' +import {isLinux, isWindows} from '@/constants/platform.desktop' +import {kbfsNotification} from '@/constants/platform-specific/kbfs-notifications' import {skipAppFocusActions} from '@/local-debug.desktop' import NotifyPopup from '@/util/notify-popup' -import {noKBFSFailReason} from '../config/util' +import {noKBFSFailReason} from '@/constants/config/util' import {initSharedSubscriptions, _onEngineIncoming} from './shared' import {wrapErrors} from '@/util/debug' diff --git a/shared/constants/init/index.native.tsx b/shared/constants/init/index.native.tsx index c88c34c87e2c..61456ddba6fc 100644 --- a/shared/constants/init/index.native.tsx +++ b/shared/constants/init/index.native.tsx @@ -3,25 +3,25 @@ import {ignorePromise, neverThrowPromiseFunc, timeoutPromise} from '../utils' import {useChatState} from '@/stores/chat2' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useDaemonState} from '../daemon' -import {useDarkModeState} from '../darkmode' -import {useFSState} from '../fs' +import {useDaemonState} from '@/stores/daemon' +import {useDarkModeState} from '@/stores/darkmode' +import {useFSState} from '@/constants/fs' import {useProfileState} from '@/stores/profile' -import {useRouterState} from '../router2' -import {useSettingsContactsState} from '../settings-contacts' -import * as T from '../types' +import {useRouterState} from '@/constants/router2' +import {useSettingsContactsState} from '@/constants/settings-contacts' +import * as T from '@/constants/types' import * as Clipboard from 'expo-clipboard' import * as EngineGen from '@/actions/engine-gen-gen' import * as ExpoLocation from 'expo-location' import * as ExpoTaskManager from 'expo-task-manager' -import * as Tabs from '../tabs' +import * as Tabs from '@/constants/tabs' import * as NetInfo from '@react-native-community/netinfo' import NotifyPopup from '@/util/notify-popup' import logger from '@/logger' import {Alert, Linking} from 'react-native' -import {isAndroid} from '../platform.native' +import {isAndroid} from '@/constants/platform.native' import {wrapErrors} from '@/util/debug' -import {getTab, getVisiblePath, logState} from '../router2' +import {getTab, getVisiblePath, logState} from '@/constants/router2' import {launchImageLibraryAsync} from '@/util/expo-image-picker.native' import {setupAudioMode} from '@/util/audio.native' import { diff --git a/shared/constants/platform-specific/push.native.tsx b/shared/constants/platform-specific/push.native.tsx index a2653fe10d5d..60d5fb4df93b 100644 --- a/shared/constants/platform-specific/push.native.tsx +++ b/shared/constants/platform-specific/push.native.tsx @@ -11,7 +11,7 @@ import { } from 'react-native-kb' import {storeRegistry} from '../store-registry' import {useConfigState} from '@/stores/config' -import {useLogoutState} from '../logout' +import {useLogoutState} from '@/stores/logout' type DataCommon = { userInteraction: boolean diff --git a/shared/constants/push.native.tsx b/shared/constants/push.native.tsx index 253f5ae4cba2..8ad849dbc456 100644 --- a/shared/constants/push.native.tsx +++ b/shared/constants/push.native.tsx @@ -1,24 +1,24 @@ -import * as Tabs from './tabs' -import * as S from './strings' -import {ignorePromise, neverThrowPromiseFunc, timeoutPromise} from './utils' -import {navigateAppend, navUpToScreen, switchTab} from './router2/util' -import {storeRegistry} from './store-registry' +import * as Tabs from '@/constants/tabs' +import * as S from '@/constants/strings' +import {ignorePromise, neverThrowPromiseFunc, timeoutPromise} from '@/constants/utils' +import {navigateAppend, navUpToScreen, switchTab} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useLogoutState} from './logout' -import {useWaitingState} from './waiting' +import {useLogoutState} from '@/stores/logout' +import {useWaitingState} from '@/constants/waiting' import * as Z from '@/util/zustand' import logger from '@/logger' -import * as T from './types' +import * as T from '@/constants/types' import {isDevApplePushToken} from '@/local-debug' -import {isIOS} from './platform' +import {isIOS} from '@/constants/platform' import { iosGetHasShownPushPrompt, checkPushPermissions, requestPushPermissions, removeAllPendingNotificationRequests, } from 'react-native-kb' -import {type Store, type State} from './push' +import {type Store, type State} from '@/constants/push' export const tokenType = isIOS ? (isDevApplePushToken ? 'appledev' : 'apple') : 'androidplay' diff --git a/shared/constants/settings-password/index.tsx b/shared/constants/settings-password/index.tsx index 40123b264cd8..138097633658 100644 --- a/shared/constants/settings-password/index.tsx +++ b/shared/constants/settings-password/index.tsx @@ -1,11 +1,11 @@ import * as Z from '@/util/zustand' -import {ignorePromise} from '../utils' -import {waitingKeySettingsGeneric} from '../strings' +import {ignorePromise} from '@/constants/utils' +import {waitingKeySettingsGeneric} from '@/constants/strings' import logger from '@/logger' import {RPCError} from '@/util/errors' -import * as T from '../types' -import {navigateUp} from '../router2/util' -import {useLogoutState} from '../logout' +import * as T from '@/constants/types' +import {navigateUp} from '@/constants/router2/util' +import {useLogoutState} from '@/stores/logout' type Store = T.Immutable<{ error: string From d7583c34ff785c17fa70141d93332aa9c91ed241 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:45:58 -0500 Subject: [PATCH 27/37] WIP --- shared/constants/store-registry.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 4da9db30cb6b..7ff319624e6f 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -129,7 +129,7 @@ class StoreRegistry { return useChatState } case 'daemon': { - const {useDaemonState} = require('@/constants/daemon') + const {useDaemonState} = require('@/stores/daemon') return useDaemonState } case 'devices': { @@ -153,7 +153,7 @@ class StoreRegistry { return usePeopleState } case 'profile': { - const {useProfileState} = require('@/constants/profile') + const {useProfileState} = require('@/stores/profile') return useProfileState } case 'provision': { From 539f08db17e257dcdbe3d23359f3c8d13c9199b1 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:48:40 -0500 Subject: [PATCH 28/37] WIP --- shared/common-adapters/avatar/hooks.tsx | 2 +- shared/constants/init/index.desktop.tsx | 2 +- shared/constants/init/index.native.tsx | 4 ++-- shared/constants/init/shared.tsx | 2 +- shared/constants/store-registry.tsx | 12 ++++++------ shared/devices/add-device.tsx | 2 +- shared/devices/device-icon.tsx | 2 +- shared/login/join-or-login.tsx | 2 +- shared/login/recover-password/device-selector.tsx | 2 +- shared/login/recover-password/error-modal.tsx | 2 +- shared/login/recover-password/error.tsx | 2 +- shared/login/recover-password/explain-device.tsx | 2 +- shared/login/recover-password/paper-key.tsx | 2 +- shared/login/recover-password/password.tsx | 2 +- .../login/recover-password/prompt-reset-shared.tsx | 2 +- shared/login/relogin/container.tsx | 4 ++-- shared/login/reset/confirm.tsx | 2 +- shared/provision/code-page/container.tsx | 2 +- shared/provision/code-page/qr-scan/hooks.tsx | 2 +- shared/provision/error.tsx | 2 +- shared/provision/forgot-username.tsx | 2 +- shared/provision/paper-key.tsx | 2 +- shared/provision/password.tsx | 4 ++-- shared/provision/select-other-device-connected.tsx | 2 +- shared/provision/select-other-device.tsx | 2 +- shared/provision/set-public-name.tsx | 2 +- shared/provision/troubleshooting.tsx | 2 +- shared/provision/username-or-email.tsx | 2 +- shared/router-v2/account-switcher/index.tsx | 2 +- shared/router-v2/common.native.tsx | 2 +- shared/router-v2/router.native.tsx | 2 +- shared/router-v2/tab-bar.desktop.tsx | 2 +- shared/settings/chat.tsx | 2 +- shared/signup/device-name.tsx | 2 +- shared/signup/username.tsx | 2 +- shared/stores/chat2.tsx | 2 +- .../provision/index.tsx => stores/provision.tsx} | 14 +++++++------- .../index.tsx => stores/recover-password.tsx} | 14 +++++++------- .../router2/index.tsx => stores/router2.tsx} | 12 ++++++------ .../index.tsx => stores/settings-chat.tsx} | 6 +++--- 40 files changed, 67 insertions(+), 67 deletions(-) rename shared/{constants/provision/index.tsx => stores/provision.tsx} (98%) rename shared/{constants/recover-password/index.tsx => stores/recover-password.tsx} (95%) rename shared/{constants/router2/index.tsx => stores/router2.tsx} (94%) rename shared/{constants/settings-chat/index.tsx => stores/settings-chat.tsx} (97%) diff --git a/shared/common-adapters/avatar/hooks.tsx b/shared/common-adapters/avatar/hooks.tsx index c8412c6be4f7..e1177a28b72f 100644 --- a/shared/common-adapters/avatar/hooks.tsx +++ b/shared/common-adapters/avatar/hooks.tsx @@ -9,7 +9,7 @@ import type {Props} from '.' import {useColorScheme} from 'react-native' import {useUsersState} from '@/stores/users' import {useFollowerState} from '@/stores/followers' -import {navToProfile} from '@/constants/router2' +import {navToProfile} from '@/stores/router2' export const avatarSizes = [128, 96, 64, 48, 32, 24, 16] as const export type AvatarSize = (typeof avatarSizes)[number] diff --git a/shared/constants/init/index.desktop.tsx b/shared/constants/init/index.desktop.tsx index 1284e6624e1f..f5d5af3558cb 100644 --- a/shared/constants/init/index.desktop.tsx +++ b/shared/constants/init/index.desktop.tsx @@ -6,7 +6,7 @@ import * as ConfigConstants from '@/stores/config' import {useDaemonState} from '@/stores/daemon' import {useFSState} from '@/constants/fs' import {useProfileState} from '@/stores/profile' -import {useRouterState} from '@/constants/router2' +import {useRouterState} from '@/stores/router2' import * as EngineGen from '@/actions/engine-gen-gen' import * as T from '@/constants/types' import InputMonitor from '@/constants/platform-specific/input-monitor.desktop' diff --git a/shared/constants/init/index.native.tsx b/shared/constants/init/index.native.tsx index 61456ddba6fc..79114a694d80 100644 --- a/shared/constants/init/index.native.tsx +++ b/shared/constants/init/index.native.tsx @@ -7,7 +7,7 @@ import {useDaemonState} from '@/stores/daemon' import {useDarkModeState} from '@/stores/darkmode' import {useFSState} from '@/constants/fs' import {useProfileState} from '@/stores/profile' -import {useRouterState} from '@/constants/router2' +import {useRouterState} from '@/stores/router2' import {useSettingsContactsState} from '@/constants/settings-contacts' import * as T from '@/constants/types' import * as Clipboard from 'expo-clipboard' @@ -21,7 +21,7 @@ import logger from '@/logger' import {Alert, Linking} from 'react-native' import {isAndroid} from '@/constants/platform.native' import {wrapErrors} from '@/util/debug' -import {getTab, getVisiblePath, logState} from '@/constants/router2' +import {getTab, getVisiblePath, logState} from '@/stores/router2' import {launchImageLibraryAsync} from '@/util/expo-image-picker.native' import {setupAudioMode} from '@/util/audio.native' import { diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 375b77c6d8ba..3238dcbf0d36 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -23,7 +23,7 @@ import type * as UseGitStateType from '@/stores/git' import type * as UseNotificationsStateType from '@/stores/notifications' import type * as UsePeopleStateType from '@/stores/people' import type * as UsePinentryStateType from '@/stores/pinentry' -import {useProvisionState} from '../provision' +import {useProvisionState} from '@/stores/provision' import {storeRegistry} from '../store-registry' import {useSettingsContactsState} from '../settings-contacts' import type * as UseSignupStateType from '@/stores/signup' diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 7ff319624e6f..37aa5c637c61 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -14,14 +14,14 @@ import type {State as GitState, useGitState} from '@/stores/git' import type {State as NotificationsState, useNotifState} from '@/stores/notifications' import type {State as PeopleState, usePeopleState} from '@/stores/people' import type {State as ProfileState, useProfileState} from '@/stores/profile' -import type {State as ProvisionState, useProvisionState} from '@/constants/provision' +import type {State as ProvisionState, useProvisionState} from '@/stores/provision' import type {State as PushState, usePushState} from '@/constants/push' import type { State as RecoverPasswordState, useState as useRecoverPasswordState, -} from '@/constants/recover-password' +} from '@/stores/recover-password' import type {State as SettingsState, useSettingsState} from '@/stores/settings' -import type {State as SettingsChatState, useSettingsChatState} from '@/constants/settings-chat' +import type {State as SettingsChatState, useSettingsChatState} from '@/stores/settings-chat' import type {State as SettingsContactsState, useSettingsContactsState} from '@/constants/settings-contacts' import type {State as SettingsEmailState, useSettingsEmailState} from '@/constants/settings-email' import type {State as SettingsPasswordState, usePWState} from '@/constants/settings-password' @@ -157,7 +157,7 @@ class StoreRegistry { return useProfileState } case 'provision': { - const {useProvisionState} = require('@/constants/provision') + const {useProvisionState} = require('@/stores/provision') return useProvisionState } case 'push': { @@ -165,7 +165,7 @@ class StoreRegistry { return usePushState } case 'recover-password': { - const {useState} = require('@/constants/recover-password') + const {useState} = require('@/stores/recover-password') return useState } case 'settings': { @@ -173,7 +173,7 @@ class StoreRegistry { return useSettingsState } case 'settings-chat': { - const {useSettingsChatState} = require('@/constants/settings-chat') + const {useSettingsChatState} = require('@/stores/settings-chat') return useSettingsChatState } case 'settings-contacts': { diff --git a/shared/devices/add-device.tsx b/shared/devices/add-device.tsx index 22d773f2001b..e27c6efffcc5 100644 --- a/shared/devices/add-device.tsx +++ b/shared/devices/add-device.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Devices from '@/stores/devices' import * as React from 'react' import * as Kb from '@/common-adapters' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' type OwnProps = { highlight?: Array<'computer' | 'phone' | 'paper key'> diff --git a/shared/devices/device-icon.tsx b/shared/devices/device-icon.tsx index a5b5135d2151..cc698e7fe61d 100644 --- a/shared/devices/device-icon.tsx +++ b/shared/devices/device-icon.tsx @@ -1,4 +1,4 @@ -import type * as Provision from '@/constants/provision' +import type * as Provision from '@/stores/provision' import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' diff --git a/shared/login/join-or-login.tsx b/shared/login/join-or-login.tsx index ee69bdb4de4d..0e4b0c267713 100644 --- a/shared/login/join-or-login.tsx +++ b/shared/login/join-or-login.tsx @@ -4,7 +4,7 @@ import {useConfigState} from '@/stores/config' import * as Kb from '@/common-adapters' import {InfoIcon} from '@/signup/common' import {useSignupState} from '@/stores/signup' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const Intro = () => { const justDeletedSelf = useConfigState(s => s.justDeletedSelf) diff --git a/shared/login/recover-password/device-selector.tsx b/shared/login/recover-password/device-selector.tsx index 150fb2d21f5a..e73f81372b15 100644 --- a/shared/login/recover-password/device-selector.tsx +++ b/shared/login/recover-password/device-selector.tsx @@ -1,5 +1,5 @@ import SelectOtherDevice from '@/provision/select-other-device' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' const RecoverPasswordDeviceSelector = () => { const devices = useRecoverState(s => s.devices) diff --git a/shared/login/recover-password/error-modal.tsx b/shared/login/recover-password/error-modal.tsx index 0f44820649be..14cb7f80d1e5 100644 --- a/shared/login/recover-password/error-modal.tsx +++ b/shared/login/recover-password/error-modal.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' import {useConfigState} from '@/stores/config' const styles = Kb.Styles.styleSheetCreate(() => ({ diff --git a/shared/login/recover-password/error.tsx b/shared/login/recover-password/error.tsx index c1a9f000880e..c38307524d2e 100644 --- a/shared/login/recover-password/error.tsx +++ b/shared/login/recover-password/error.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import type {ButtonType} from '@/common-adapters/button' import {SignupScreen} from '@/signup/common' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' import {useConfigState} from '@/stores/config' const ConnectedError = () => { diff --git a/shared/login/recover-password/explain-device.tsx b/shared/login/recover-password/explain-device.tsx index 06890c97dab8..f9bd16930337 100644 --- a/shared/login/recover-password/explain-device.tsx +++ b/shared/login/recover-password/explain-device.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import type {ButtonType} from '@/common-adapters/button' import {SignupScreen} from '@/signup/common' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' const ConnectedExplainDevice = () => { const ed = useRecoverState(s => s.explainedDevice) diff --git a/shared/login/recover-password/paper-key.tsx b/shared/login/recover-password/paper-key.tsx index 5e2a332af6d9..9d1983af7a1d 100644 --- a/shared/login/recover-password/paper-key.tsx +++ b/shared/login/recover-password/paper-key.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import type {ButtonType} from '@/common-adapters/button' import {SignupScreen} from '@/signup/common' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' const PaperKey = () => { const error = useRecoverState(s => s.paperKeyError) diff --git a/shared/login/recover-password/password.tsx b/shared/login/recover-password/password.tsx index 452ca011543a..2e61426b7edc 100644 --- a/shared/login/recover-password/password.tsx +++ b/shared/login/recover-password/password.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' import {UpdatePassword} from '@/settings/password' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' const Password = () => { const error = useRecoverState(s => s.passwordError) diff --git a/shared/login/recover-password/prompt-reset-shared.tsx b/shared/login/recover-password/prompt-reset-shared.tsx index 7107a4dc8cf2..dff66e082417 100644 --- a/shared/login/recover-password/prompt-reset-shared.tsx +++ b/shared/login/recover-password/prompt-reset-shared.tsx @@ -6,7 +6,7 @@ import {useSafeNavigation} from '@/util/safe-navigation' import * as T from '@/constants/types' import {SignupScreen} from '@/signup/common' import type {ButtonType} from '@/common-adapters/button' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' export type Props = { resetPassword?: boolean diff --git a/shared/login/relogin/container.tsx b/shared/login/relogin/container.tsx index 9bd1741e3450..ee18a0195aa3 100644 --- a/shared/login/relogin/container.tsx +++ b/shared/login/relogin/container.tsx @@ -3,9 +3,9 @@ import * as React from 'react' import {useConfigState} from '@/stores/config' import Login from '.' import sortBy from 'lodash/sortBy' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' import {useSignupState} from '@/stores/signup' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const needPasswordError = 'passphrase cannot be empty' diff --git a/shared/login/reset/confirm.tsx b/shared/login/reset/confirm.tsx index 50279d56446c..e8a22339520d 100644 --- a/shared/login/reset/confirm.tsx +++ b/shared/login/reset/confirm.tsx @@ -3,7 +3,7 @@ import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import {useState as useRecoverState} from '@/constants/recover-password' +import {useState as useRecoverState} from '@/stores/recover-password' const ConfirmReset = () => { const hasWallet = AutoReset.useAutoResetState(s => s.hasWallet) diff --git a/shared/provision/code-page/container.tsx b/shared/provision/code-page/container.tsx index 9c4d0e26d2ed..a33c2113e0da 100644 --- a/shared/provision/code-page/container.tsx +++ b/shared/provision/code-page/container.tsx @@ -7,7 +7,7 @@ import QRScan from './qr-scan' import Troubleshooting from '../troubleshooting' import type * as T from '@/constants/types' import {useCurrentUserState} from '@/stores/current-user' -import {type Device, useProvisionState} from '@/constants/provision' +import {type Device, useProvisionState} from '@/stores/provision' const CodePageContainer = () => { const {deviceID, storeDeviceName} = useCurrentUserState( diff --git a/shared/provision/code-page/qr-scan/hooks.tsx b/shared/provision/code-page/qr-scan/hooks.tsx index bf1687854d0b..c6515c36c5d4 100644 --- a/shared/provision/code-page/qr-scan/hooks.tsx +++ b/shared/provision/code-page/qr-scan/hooks.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const useQR = () => { const submitTextCode = useProvisionState(s => s.dispatch.dynamic.submitTextCode) diff --git a/shared/provision/error.tsx b/shared/provision/error.tsx index f25a682e54be..a5cafc24ae99 100644 --- a/shared/provision/error.tsx +++ b/shared/provision/error.tsx @@ -5,7 +5,7 @@ import type * as React from 'react' import LoginContainer from '../login/forms/container' import openURL from '@/util/open-url' import * as T from '@/constants/types' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const Wrapper = (p: {onBack: () => void; children: React.ReactNode}) => ( diff --git a/shared/provision/forgot-username.tsx b/shared/provision/forgot-username.tsx index 9b01068677b6..5e85eb873829 100644 --- a/shared/provision/forgot-username.tsx +++ b/shared/provision/forgot-username.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen, errorBanner} from '../signup/common' import {useSettingsPhoneState} from '@/constants/settings-phone' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const ForgotUsername = () => { const defaultCountry = useSettingsPhoneState(s => s.defaultCountry) diff --git a/shared/provision/paper-key.tsx b/shared/provision/paper-key.tsx index 8fb1972d6f6a..0ae84be9dc0d 100644 --- a/shared/provision/paper-key.tsx +++ b/shared/provision/paper-key.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' import {SignupScreen, errorBanner} from '../signup/common' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const Container = () => { const error = useProvisionState(s => s.error) diff --git a/shared/provision/password.tsx b/shared/provision/password.tsx index 3d1f2adddff5..3bef094b69fc 100644 --- a/shared/provision/password.tsx +++ b/shared/provision/password.tsx @@ -3,8 +3,8 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import UserCard from '../login/user-card' import {SignupScreen, errorBanner} from '../signup/common' -import {useState as useRecoverState} from '@/constants/recover-password' -import {useProvisionState} from '@/constants/provision' +import {useState as useRecoverState} from '@/stores/recover-password' +import {useProvisionState} from '@/stores/provision' const Password = () => { const error = useProvisionState(s => s.error) diff --git a/shared/provision/select-other-device-connected.tsx b/shared/provision/select-other-device-connected.tsx index 4ff101b40ee9..69499e1c7547 100644 --- a/shared/provision/select-other-device-connected.tsx +++ b/shared/provision/select-other-device-connected.tsx @@ -3,7 +3,7 @@ import * as AutoReset from '@/stores/autoreset' import * as React from 'react' import {useSafeSubmit} from '@/util/safe-submit' import SelectOtherDevice from './select-other-device' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const SelectOtherDeviceContainer = () => { const devices = useProvisionState(s => s.devices) diff --git a/shared/provision/select-other-device.tsx b/shared/provision/select-other-device.tsx index b39e8c25308e..3ac49ebaba69 100644 --- a/shared/provision/select-other-device.tsx +++ b/shared/provision/select-other-device.tsx @@ -2,7 +2,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import DeviceIcon from '../devices/device-icon' import {SignupScreen} from '../signup/common' -import {type Device} from '@/constants/provision' +import {type Device} from '@/stores/provision' type Props = { passwordRecovery?: boolean diff --git a/shared/provision/set-public-name.tsx b/shared/provision/set-public-name.tsx index d99fde018b10..3b5d7ba52058 100644 --- a/shared/provision/set-public-name.tsx +++ b/shared/provision/set-public-name.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import debounce from 'lodash/debounce' import {SignupScreen, errorBanner} from '../signup/common' -import * as Provision from '@/constants/provision' +import * as Provision from '@/stores/provision' const SetPublicName = () => { const devices = Provision.useProvisionState(s => s.devices) diff --git a/shared/provision/troubleshooting.tsx b/shared/provision/troubleshooting.tsx index b1b65fcd566b..e7aa4f2318c7 100644 --- a/shared/provision/troubleshooting.tsx +++ b/shared/provision/troubleshooting.tsx @@ -3,7 +3,7 @@ import * as C from '@/constants' import * as Devices from '@/stores/devices' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' type Props = { mode: 'QR' | 'text' onCancel: () => void diff --git a/shared/provision/username-or-email.tsx b/shared/provision/username-or-email.tsx index 5d38de65f6b9..fd06d797850d 100644 --- a/shared/provision/username-or-email.tsx +++ b/shared/provision/username-or-email.tsx @@ -8,7 +8,7 @@ import type {RPCError} from '@/util/errors' import * as Kb from '@/common-adapters' import UserCard from '@/login/user-card' import {SignupScreen, errorBanner} from '@/signup/common' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' type OwnProps = {fromReset?: boolean; username?: string} diff --git a/shared/router-v2/account-switcher/index.tsx b/shared/router-v2/account-switcher/index.tsx index cad9658bf1b8..fa570869a785 100644 --- a/shared/router-v2/account-switcher/index.tsx +++ b/shared/router-v2/account-switcher/index.tsx @@ -9,7 +9,7 @@ import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/stores/profile' import {useUsersState} from '@/stores/users' import {useCurrentUserState} from '@/stores/current-user' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const prepareAccountRows = ( accountRows: ReadonlyArray, diff --git a/shared/router-v2/common.native.tsx b/shared/router-v2/common.native.tsx index af2f2056c052..8037a3caaedc 100644 --- a/shared/router-v2/common.native.tsx +++ b/shared/router-v2/common.native.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import {TabActions, type NavigationContainerRef} from '@react-navigation/core' import type {HeaderOptions} from '@react-navigation/elements' import {HeaderLeftArrowCanGoBack} from '@/common-adapters/header-hoc' -import type {NavState} from '@/constants/router2' +import type {NavState} from '@/stores/router2' export const headerDefaultStyle = { get backgroundColor() { diff --git a/shared/router-v2/router.native.tsx b/shared/router-v2/router.native.tsx index 28a7d05bb5eb..b6b3cf21b97c 100644 --- a/shared/router-v2/router.native.tsx +++ b/shared/router-v2/router.native.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as Constants from '@/constants/router2' +import * as Constants from '@/stores/router2' import {useConfigState} from '@/stores/config' import {useDarkModeState} from '@/stores/darkmode' import * as Kb from '@/common-adapters' diff --git a/shared/router-v2/tab-bar.desktop.tsx b/shared/router-v2/tab-bar.desktop.tsx index 1649b65ac0ef..a9cceadc90c8 100644 --- a/shared/router-v2/tab-bar.desktop.tsx +++ b/shared/router-v2/tab-bar.desktop.tsx @@ -19,7 +19,7 @@ import {useFSState} from '@/stores/fs' import {useProfileState} from '@/stores/profile' import {useNotifState} from '@/stores/notifications' import {useCurrentUserState} from '@/stores/current-user' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const {hideWindow, ctlQuit} = KB2.functions diff --git a/shared/settings/chat.tsx b/shared/settings/chat.tsx index ae611ccaabb6..2452ded9fdc8 100644 --- a/shared/settings/chat.tsx +++ b/shared/settings/chat.tsx @@ -4,7 +4,7 @@ import * as Teams from '@/stores/teams' import * as T from '@/constants/types' import * as React from 'react' import Group from './group' -import {useSettingsChatState as useSettingsChatState} from '@/constants/settings-chat' +import {useSettingsChatState as useSettingsChatState} from '@/stores/settings-chat' import {useSettingsNotifState} from '@/constants/settings-notifications' import {useSettingsState} from '@/stores/settings' import {useConfigState} from '@/stores/config' diff --git a/shared/signup/device-name.tsx b/shared/signup/device-name.tsx index 6f558ccd00ed..d53ddce22c04 100644 --- a/shared/signup/device-name.tsx +++ b/shared/signup/device-name.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' import {SignupScreen, errorBanner} from './common' -import * as Provision from '@/constants/provision' +import * as Provision from '@/stores/provision' import {useSignupState} from '@/stores/signup' const ConnectedEnterDevicename = () => { diff --git a/shared/signup/username.tsx b/shared/signup/username.tsx index 68f1d9019e15..8f6da6fca45d 100644 --- a/shared/signup/username.tsx +++ b/shared/signup/username.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as React from 'react' import {SignupScreen, errorBanner} from './common' import {useSignupState} from '@/stores/signup' -import {useProvisionState} from '@/constants/provision' +import {useProvisionState} from '@/stores/provision' const ConnectedEnterUsername = () => { const error = useSignupState(s => s.usernameError) diff --git a/shared/stores/chat2.tsx b/shared/stores/chat2.tsx index d61cc829079b..5e73973dbf30 100644 --- a/shared/stores/chat2.tsx +++ b/shared/stores/chat2.tsx @@ -4,7 +4,7 @@ import * as Tabs from '@/constants/tabs' import * as EngineGen from '@/actions/engine-gen-gen' import type * as ConfigConstants from '@/stores/config' import * as Message from '@/constants/chat2/message' -import * as Router2 from '@/constants/router2' +import * as Router2 from '@/stores/router2' import * as TeamConstants from '@/constants/teams/util' import logger from '@/logger' import {RPCError} from '@/util/errors' diff --git a/shared/constants/provision/index.tsx b/shared/stores/provision.tsx similarity index 98% rename from shared/constants/provision/index.tsx rename to shared/stores/provision.tsx index e948638d1e95..b8377c358c7e 100644 --- a/shared/constants/provision/index.tsx +++ b/shared/stores/provision.tsx @@ -1,15 +1,15 @@ -import * as T from '../types' -import {ignorePromise, wrapErrors} from '../utils' -import {waitingKeyProvision, waitingKeyProvisionForgotUsername} from '../strings' +import * as T from '@/constants/types' +import {ignorePromise, wrapErrors} from '@/constants/utils' +import {waitingKeyProvision, waitingKeyProvisionForgotUsername} from '@/constants/strings' import * as Z from '@/util/zustand' import {RPCError} from '@/util/errors' -import {isMobile} from '../platform' +import {isMobile} from '@/constants/platform' import {type CommonResponseHandler} from '@/engine/types' import isEqual from 'lodash/isEqual' -import {rpcDeviceToDevice} from '../rpc-utils' +import {rpcDeviceToDevice} from '@/constants/rpc-utils' import {invalidPasswordErrorString} from '@/constants/config/util' -import {clearModals, navigateAppend} from '../router2/util' -import {useWaitingState} from '../waiting' +import {clearModals, navigateAppend} from '@/constants/router2/util' +import {useWaitingState} from '@/constants/waiting' export type Device = { deviceNumberOfType: number diff --git a/shared/constants/recover-password/index.tsx b/shared/stores/recover-password.tsx similarity index 95% rename from shared/constants/recover-password/index.tsx rename to shared/stores/recover-password.tsx index 8346cd19876b..464bb2e1aa87 100644 --- a/shared/constants/recover-password/index.tsx +++ b/shared/stores/recover-password.tsx @@ -1,13 +1,13 @@ -import * as T from '../types' -import {ignorePromise, wrapErrors} from '../utils' -import {waitingKeyRecoverPassword} from '../strings' +import * as T from '@/constants/types' +import {ignorePromise, wrapErrors} from '@/constants/utils' +import {waitingKeyRecoverPassword} from '@/constants/strings' import * as Z from '@/util/zustand' import logger from '@/logger' import {RPCError} from '@/util/errors' -import {type Device} from '../provision' -import {rpcDeviceToDevice} from '../rpc-utils' -import {clearModals, navigateAppend, navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' +import {type Device} from '@/stores/provision' +import {rpcDeviceToDevice} from '@/constants/rpc-utils' +import {clearModals, navigateAppend, navigateUp} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' import {useConfigState} from '@/stores/config' type Store = T.Immutable<{ diff --git a/shared/constants/router2/index.tsx b/shared/stores/router2.tsx similarity index 94% rename from shared/constants/router2/index.tsx rename to shared/stores/router2.tsx index 24c72281cad0..69864067988b 100644 --- a/shared/constants/router2/index.tsx +++ b/shared/stores/router2.tsx @@ -1,9 +1,9 @@ -import type * as T from '../types' +import type * as T from '@/constants/types' import * as Z from '@/util/zustand' -import * as Tabs from '../tabs' +import * as Tabs from '@/constants/tabs' import type {RouteKeys} from '@/router-v2/route-params' -import {storeRegistry} from '../store-registry' -import * as Util from './util' +import {storeRegistry} from '@/constants/store-registry' +import * as Util from '@/constants/router2/util' export { type NavState, @@ -21,8 +21,8 @@ export { getRouteLoggedIn, useSafeFocusEffect, makeScreen, -} from './util' -export type {PathParam, Navigator} from './util' +} from '@/constants/router2/util' +export type {PathParam, Navigator} from '@/constants/router2/util' type Store = T.Immutable<{ navState?: unknown diff --git a/shared/constants/settings-chat/index.tsx b/shared/stores/settings-chat.tsx similarity index 97% rename from shared/constants/settings-chat/index.tsx rename to shared/stores/settings-chat.tsx index 50cdeb918da0..71e6af5aca23 100644 --- a/shared/constants/settings-chat/index.tsx +++ b/shared/stores/settings-chat.tsx @@ -1,6 +1,6 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import * as S from '../strings' +import * as T from '@/constants/types' +import {ignorePromise} from '@/constants/utils' +import * as S from '@/constants/strings' import * as Z from '@/util/zustand' import {useConfigState} from '@/stores/config' From 3cac2b3fe583a92b8563d77ad900642974f03f81 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 16:54:52 -0500 Subject: [PATCH 29/37] WIP --- shared/constants/chat2/common.tsx | 2 +- shared/constants/index.tsx | 4 ++-- shared/constants/rpc-utils.tsx | 9 +++++++-- shared/constants/team-building/index.tsx | 10 +++++----- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/shared/constants/chat2/common.tsx b/shared/constants/chat2/common.tsx index 8a64d900c885..c16ed15eb76f 100644 --- a/shared/constants/chat2/common.tsx +++ b/shared/constants/chat2/common.tsx @@ -1,6 +1,6 @@ import * as T from '../types' import {isMobile, isTablet} from '../platform' -import * as Router2 from '../router2' +import * as Router2 from '@/stores/router2' import {useConfigState} from '@/stores/config' export const explodingModeGregorKeyPrefix = 'exploding:' diff --git a/shared/constants/index.tsx b/shared/constants/index.tsx index b3359e15383d..c9d0a1413f0a 100644 --- a/shared/constants/index.tsx +++ b/shared/constants/index.tsx @@ -1,8 +1,8 @@ export * from './platform' export * from './values' export * from './strings' -export {useRouterState, makeScreen} from './router2' -export * as Router2 from './router2' +export {useRouterState, makeScreen} from '@/stores/router2' +export * as Router2 from '@/stores/router2' export * as Tabs from './tabs' export {useWaitingState} from './waiting' export * as Waiting from './waiting' diff --git a/shared/constants/rpc-utils.tsx b/shared/constants/rpc-utils.tsx index 5969509c5d03..8c5993554391 100644 --- a/shared/constants/rpc-utils.tsx +++ b/shared/constants/rpc-utils.tsx @@ -1,6 +1,12 @@ import * as T from './types' import {uint8ArrayToString} from 'uint8array-extras' -import {type Device} from './provision' + +type Device = { + deviceNumberOfType: number + id: T.Devices.DeviceID + name: string + type: T.Devices.DeviceType +} export const bodyToJSON = (body?: Uint8Array): unknown => { if (!body) return undefined @@ -27,4 +33,3 @@ export const rpcDeviceToDevice = (d: T.RPCGen.Device): Device => { throw new Error('Invalid device type detected: ' + type) } } - diff --git a/shared/constants/team-building/index.tsx b/shared/constants/team-building/index.tsx index ed0c5e633f0e..a7105372fc8d 100644 --- a/shared/constants/team-building/index.tsx +++ b/shared/constants/team-building/index.tsx @@ -1,6 +1,6 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' -import * as Router2 from '../router2' +import * as T from '@/constants/types' +import {ignorePromise} from '@/constants/utils' +import * as Router2 from '@/stores/router2' import * as React from 'react' import * as Z from '@/util/zustand' import logger from '@/logger' @@ -12,8 +12,8 @@ import {type StoreApi, type UseBoundStore, useStore} from 'zustand' import {validateEmailAddress} from '@/util/email-address' import {registerDebugClear} from '@/util/debug' import {searchWaitingKey} from './utils' -import {navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' +import {navigateUp} from '@/constants/router2/util' +import {storeRegistry} from '@/constants/store-registry' import {useCryptoState} from '@/stores/crypto' export {allServices, selfToUser, searchWaitingKey} from './utils' From cf00ea2f90eb1afe2c0b25795b86c017ec962725 Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Fri, 9 Jan 2026 16:57:10 -0500 Subject: [PATCH 30/37] WIP --- shared/constants/init/index.native.tsx | 2 +- shared/constants/init/shared.tsx | 2 +- shared/constants/store-registry.tsx | 8 +++--- shared/people/todo.tsx | 2 +- shared/settings/account/add-modals.tsx | 2 +- shared/settings/account/confirm-delete.tsx | 2 +- shared/settings/account/email-phone-row.tsx | 2 +- shared/settings/account/index.tsx | 2 +- shared/settings/chat.tsx | 2 +- shared/settings/contacts-joined.tsx | 2 +- shared/settings/group.tsx | 2 +- shared/settings/invites/index.desktop.tsx | 4 +-- shared/settings/manage-contacts.tsx | 2 +- shared/settings/notifications/hooks.tsx | 4 +-- .../settings/notifications/index.desktop.tsx | 2 +- .../settings/notifications/index.native.tsx | 2 +- shared/settings/root-phone.tsx | 2 +- shared/signup/email.tsx | 2 +- shared/stores/settings-contacts.tsx | 28 +++++++++++++++++++ .../index.tsx => stores/settings-email.tsx} | 6 ++-- .../index.tsx => stores/settings-invites.tsx} | 8 +++--- .../settings-notifications.tsx} | 8 +++--- shared/team-building/contacts.tsx | 2 +- shared/team-building/list-body.tsx | 2 +- shared/teams/common/use-contacts.native.tsx | 2 +- 25 files changed, 65 insertions(+), 37 deletions(-) create mode 100644 shared/stores/settings-contacts.tsx rename shared/{constants/settings-email/index.tsx => stores/settings-email.tsx} (97%) rename shared/{constants/settings-invites/index.tsx => stores/settings-invites.tsx} (95%) rename shared/{constants/settings-notifications/index.tsx => stores/settings-notifications.tsx} (97%) diff --git a/shared/constants/init/index.native.tsx b/shared/constants/init/index.native.tsx index 79114a694d80..d77006dbf81c 100644 --- a/shared/constants/init/index.native.tsx +++ b/shared/constants/init/index.native.tsx @@ -8,7 +8,7 @@ import {useDarkModeState} from '@/stores/darkmode' import {useFSState} from '@/constants/fs' import {useProfileState} from '@/stores/profile' import {useRouterState} from '@/stores/router2' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import * as T from '@/constants/types' import * as Clipboard from 'expo-clipboard' import * as EngineGen from '@/actions/engine-gen-gen' diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 3238dcbf0d36..bde49933e8c8 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -25,7 +25,7 @@ import type * as UsePeopleStateType from '@/stores/people' import type * as UsePinentryStateType from '@/stores/pinentry' import {useProvisionState} from '@/stores/provision' import {storeRegistry} from '../store-registry' -import {useSettingsContactsState} from '../settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import type * as UseSignupStateType from '@/stores/signup' import type * as UseTeamsStateType from '@/stores/teams' import {useTeamsState} from '@/stores/teams' diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index 37aa5c637c61..e07725eaff26 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -22,8 +22,8 @@ import type { } from '@/stores/recover-password' import type {State as SettingsState, useSettingsState} from '@/stores/settings' import type {State as SettingsChatState, useSettingsChatState} from '@/stores/settings-chat' -import type {State as SettingsContactsState, useSettingsContactsState} from '@/constants/settings-contacts' -import type {State as SettingsEmailState, useSettingsEmailState} from '@/constants/settings-email' +import type {State as SettingsContactsState, useSettingsContactsState} from '@/stores/settings-contacts' +import type {State as SettingsEmailState, useSettingsEmailState} from '@/stores/settings-email' import type {State as SettingsPasswordState, usePWState} from '@/constants/settings-password' import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/constants/settings-phone' import type {State as SignupState, useSignupState} from '@/stores/signup' @@ -177,11 +177,11 @@ class StoreRegistry { return useSettingsChatState } case 'settings-contacts': { - const {useSettingsContactsState} = require('@/constants/settings-contacts') + const {useSettingsContactsState} = require('@/stores/settings-contacts') return useSettingsContactsState } case 'settings-email': { - const {useSettingsEmailState} = require('@/constants/settings-email') + const {useSettingsEmailState} = require('@/stores/settings-email') return useSettingsEmailState } case 'settings-password': { diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index 3d1fd9cb1a6e..b0f8eb3c4e8e 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -7,7 +7,7 @@ import type {IconType} from '@/common-adapters/icon.constants-gen' import PeopleItem, {type TaskButton} from './item' import * as Kb from '@/common-adapters' import {useSettingsPhoneState} from '@/constants/settings-phone' -import {useSettingsEmailState} from '@/constants/settings-email' +import {useSettingsEmailState} from '@/stores/settings-email' import {settingsAccountTab, settingsGitTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' import {useProfileState} from '@/stores/profile' diff --git a/shared/settings/account/add-modals.tsx b/shared/settings/account/add-modals.tsx index f5736b62172a..11e6f2d5c8f2 100644 --- a/shared/settings/account/add-modals.tsx +++ b/shared/settings/account/add-modals.tsx @@ -7,7 +7,7 @@ import {EnterPhoneNumberBody} from '@/signup/phone-number' import VerifyBody from '@/signup/phone-number/verify-body' import {e164ToDisplay} from '@/util/phone-numbers' import {useSettingsPhoneState} from '@/constants/settings-phone' -import {useSettingsEmailState} from '@/constants/settings-email' +import {useSettingsEmailState} from '@/stores/settings-email' export const Email = () => { const nav = useSafeNavigation() diff --git a/shared/settings/account/confirm-delete.tsx b/shared/settings/account/confirm-delete.tsx index cec9eaa58255..ea7049ae09ac 100644 --- a/shared/settings/account/confirm-delete.tsx +++ b/shared/settings/account/confirm-delete.tsx @@ -3,7 +3,7 @@ import * as Kb from '@/common-adapters' import * as PhoneUtil from '@/util/phone-numbers' import {useSafeNavigation} from '@/util/safe-navigation' import {useSettingsPhoneState} from '@/constants/settings-phone' -import {useSettingsEmailState} from '@/constants/settings-email' +import {useSettingsEmailState} from '@/stores/settings-email' type OwnProps = { address: string diff --git a/shared/settings/account/email-phone-row.tsx b/shared/settings/account/email-phone-row.tsx index b3b7f6e32a3d..321e0e7be5ad 100644 --- a/shared/settings/account/email-phone-row.tsx +++ b/shared/settings/account/email-phone-row.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {useSettingsPhoneState} from '@/constants/settings-phone' -import {useSettingsEmailState} from '@/constants/settings-email' +import {useSettingsEmailState} from '@/stores/settings-email' const addSpacer = (into: string, add: string) => { return into + (into.length ? ' • ' : '') + add diff --git a/shared/settings/account/index.tsx b/shared/settings/account/index.tsx index 6137476c099e..3d826788959e 100644 --- a/shared/settings/account/index.tsx +++ b/shared/settings/account/index.tsx @@ -4,7 +4,7 @@ import type * as React from 'react' import EmailPhoneRow from './email-phone-row' import {usePWState} from '@/constants/settings-password' import {useSettingsPhoneState} from '@/constants/settings-phone' -import {useSettingsEmailState} from '@/constants/settings-email' +import {useSettingsEmailState} from '@/stores/settings-email' import {useSettingsState, settingsPasswordTab} from '@/stores/settings' export const SettingsSection = ({children}: {children: React.ReactNode}) => ( diff --git a/shared/settings/chat.tsx b/shared/settings/chat.tsx index 2452ded9fdc8..1759ee2dbaa1 100644 --- a/shared/settings/chat.tsx +++ b/shared/settings/chat.tsx @@ -5,7 +5,7 @@ import * as T from '@/constants/types' import * as React from 'react' import Group from './group' import {useSettingsChatState as useSettingsChatState} from '@/stores/settings-chat' -import {useSettingsNotifState} from '@/constants/settings-notifications' +import {useSettingsNotifState} from '@/stores/settings-notifications' import {useSettingsState} from '@/stores/settings' import {useConfigState} from '@/stores/config' diff --git a/shared/settings/contacts-joined.tsx b/shared/settings/contacts-joined.tsx index 51e7f3998508..994dcd5a5a85 100644 --- a/shared/settings/contacts-joined.tsx +++ b/shared/settings/contacts-joined.tsx @@ -4,7 +4,7 @@ import type * as T from '@/constants/types' import {useSafeNavigation} from '@/util/safe-navigation' import * as React from 'react' import UnconnectedFollowButton from '@/profile/user/actions/follow-button' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import {useTrackerState} from '@/stores/tracker2' import {useFollowerState} from '@/stores/followers' diff --git a/shared/settings/group.tsx b/shared/settings/group.tsx index 839ad9fa16b1..fefd140db264 100644 --- a/shared/settings/group.tsx +++ b/shared/settings/group.tsx @@ -1,5 +1,5 @@ import * as Kb from '@/common-adapters' -import type {NotificationsSettingsState} from '@/constants/settings-notifications' +import type {NotificationsSettingsState} from '@/stores/settings-notifications' type GroupProps = { allowEdit: boolean diff --git a/shared/settings/invites/index.desktop.tsx b/shared/settings/invites/index.desktop.tsx index c46bf9fefdd2..c9dd76394d51 100644 --- a/shared/settings/invites/index.desktop.tsx +++ b/shared/settings/invites/index.desktop.tsx @@ -1,11 +1,11 @@ import * as Kb from '@/common-adapters' -import type {AcceptedInvite, PendingInvite} from '@/constants/settings-invites' +import type {AcceptedInvite, PendingInvite} from '@/stores/settings-invites' import * as React from 'react' import SubHeading from '../subheading' import * as dateFns from 'date-fns' import * as C from '@/constants' import {useProfileState} from '@/stores/profile' -import {useState as useSettingsInvitesState} from '@/constants/settings-invites' +import {useState as useSettingsInvitesState} from '@/stores/settings-invites' // Like intersperse but takes a function to define the separator function intersperseFn( diff --git a/shared/settings/manage-contacts.tsx b/shared/settings/manage-contacts.tsx index 864eedc4842c..aca33a0abc2f 100644 --- a/shared/settings/manage-contacts.tsx +++ b/shared/settings/manage-contacts.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import {SettingsSection} from './account' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import {settingsFeedbackTab} from '@/stores/settings' import {useConfigState} from '@/stores/config' diff --git a/shared/settings/notifications/hooks.tsx b/shared/settings/notifications/hooks.tsx index 611f53430ac0..a3c0aecc59fd 100644 --- a/shared/settings/notifications/hooks.tsx +++ b/shared/settings/notifications/hooks.tsx @@ -1,6 +1,6 @@ import * as C from '@/constants' -import {useSettingsEmailState} from '@/constants/settings-email' -import {useSettingsNotifState} from '@/constants/settings-notifications' +import {useSettingsEmailState} from '@/stores/settings-email' +import {useSettingsNotifState} from '@/stores/settings-notifications' import {useSettingsState, settingsAccountTab} from '@/stores/settings' const useNotifications = () => { diff --git a/shared/settings/notifications/index.desktop.tsx b/shared/settings/notifications/index.desktop.tsx index a0ad16c1172e..2b245d4fd6d7 100644 --- a/shared/settings/notifications/index.desktop.tsx +++ b/shared/settings/notifications/index.desktop.tsx @@ -1,7 +1,7 @@ import {Reloadable} from '@/common-adapters' import * as C from '@/constants' import Render from './render' -import {useSettingsNotifState} from '@/constants/settings-notifications' +import {useSettingsNotifState} from '@/stores/settings-notifications' import {useSettingsState} from '@/stores/settings' const Notifications = () => { diff --git a/shared/settings/notifications/index.native.tsx b/shared/settings/notifications/index.native.tsx index 97d950d11bcd..b4e429461668 100644 --- a/shared/settings/notifications/index.native.tsx +++ b/shared/settings/notifications/index.native.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import Notifications from './render' import {Reloadable} from '@/common-adapters' -import {useSettingsNotifState} from '@/constants/settings-notifications' +import {useSettingsNotifState} from '@/stores/settings-notifications' import {useSettingsState} from '@/stores/settings' import {usePushState} from '@/constants/push' diff --git a/shared/settings/root-phone.tsx b/shared/settings/root-phone.tsx index 668f0a4ef3ef..6afc0c92af25 100644 --- a/shared/settings/root-phone.tsx +++ b/shared/settings/root-phone.tsx @@ -7,7 +7,7 @@ import {keybaseFM} from '@/constants/whats-new' import SettingsItem from './sub-nav/settings-item' import WhatsNewIcon from '../whats-new/icon' import noop from 'lodash/noop' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import * as Settings from '@/stores/settings' import {usePushState} from '@/constants/push' import {useNotifState} from '@/stores/notifications' diff --git a/shared/signup/email.tsx b/shared/signup/email.tsx index e0585812a33b..0f6f33bef3b6 100644 --- a/shared/signup/email.tsx +++ b/shared/signup/email.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen, errorBanner} from './common' -import {useSettingsEmailState} from '@/constants/settings-email' +import {useSettingsEmailState} from '@/stores/settings-email' import {useSignupState} from '@/stores/signup' import {usePushState} from '@/constants/push' diff --git a/shared/stores/settings-contacts.tsx b/shared/stores/settings-contacts.tsx new file mode 100644 index 000000000000..e58e0b77761c --- /dev/null +++ b/shared/stores/settings-contacts.tsx @@ -0,0 +1,28 @@ +import * as Z from '@/util/zustand' +import type {Store, State} from '@/stores/settings-contacts' + +const initialStore: Store = { + alreadyOnKeybase: [], + importError: '', + importPromptDismissed: false, + importedCount: undefined, + permissionStatus: 'unknown', + userCountryCode: undefined, + waitingToShowJoinedModal: false, +} + +export const useSettingsContactsState = Z.createZustand(() => { + const dispatch: State['dispatch'] = { + editContactImportEnabled: () => {}, + importContactsLater: () => {}, + loadContactImportEnabled: () => {}, + loadContactPermissions: () => {}, + manageContactsCache: () => {}, + requestPermissions: () => {}, + resetState: 'default', + } + return { + ...initialStore, + dispatch, + } +}) diff --git a/shared/constants/settings-email/index.tsx b/shared/stores/settings-email.tsx similarity index 97% rename from shared/constants/settings-email/index.tsx rename to shared/stores/settings-email.tsx index 7cb1d649961a..935f43208173 100644 --- a/shared/constants/settings-email/index.tsx +++ b/shared/stores/settings-email.tsx @@ -1,7 +1,7 @@ import * as Z from '@/util/zustand' -import {addEmailWaitingKey} from '../strings' -import {ignorePromise} from '../utils' -import * as T from '../types' +import {addEmailWaitingKey} from '@/constants/strings' +import {ignorePromise} from '@/constants/utils' +import * as T from '@/constants/types' import {isValidEmail} from '@/util/simple-validators' import {RPCError} from '@/util/errors' import logger from '@/logger' diff --git a/shared/constants/settings-invites/index.tsx b/shared/stores/settings-invites.tsx similarity index 95% rename from shared/constants/settings-invites/index.tsx rename to shared/stores/settings-invites.tsx index c6b6edc8e582..75cf71ef468f 100644 --- a/shared/constants/settings-invites/index.tsx +++ b/shared/stores/settings-invites.tsx @@ -1,11 +1,11 @@ import * as Z from '@/util/zustand' -import {ignorePromise} from '../utils' -import {waitingKeySettingsGeneric} from '../strings' +import {ignorePromise} from '@/constants/utils' +import {waitingKeySettingsGeneric} from '@/constants/strings' import {RPCError} from '@/util/errors' import logger from '@/logger' import trim from 'lodash/trim' -import * as T from '../types' -import {navigateAppend} from '../router2/util' +import * as T from '@/constants/types' +import {navigateAppend} from '@/constants/router2/util' type InviteBase = { id: string diff --git a/shared/constants/settings-notifications/index.tsx b/shared/stores/settings-notifications.tsx similarity index 97% rename from shared/constants/settings-notifications/index.tsx rename to shared/stores/settings-notifications.tsx index f93adaae9fdc..c22a90a587f0 100644 --- a/shared/constants/settings-notifications/index.tsx +++ b/shared/stores/settings-notifications.tsx @@ -1,10 +1,10 @@ import * as Z from '@/util/zustand' -import * as S from '../strings' -import {isAndroidNewerThanN} from '../platform' -import {ignorePromise, timeoutPromise} from '../utils' +import * as S from '@/constants/strings' +import {isAndroidNewerThanN} from '@/constants/platform' +import {ignorePromise, timeoutPromise} from '@/constants/utils' import {RPCError} from '@/util/errors' import logger from '@/logger' -import * as T from '../types' +import * as T from '@/constants/types' const securityGroup = 'security' const soundGroup = 'sound' diff --git a/shared/team-building/contacts.tsx b/shared/team-building/contacts.tsx index 6d39827419c6..5112b6f2d719 100644 --- a/shared/team-building/contacts.tsx +++ b/shared/team-building/contacts.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import {useTBContext} from '@/constants/team-building' const useContactsProps = () => { diff --git a/shared/team-building/list-body.tsx b/shared/team-building/list-body.tsx index b56284ba92b4..e37d7bb8b5ef 100644 --- a/shared/team-building/list-body.tsx +++ b/shared/team-building/list-body.tsx @@ -14,7 +14,7 @@ import type {RootRouteProps} from '@/router-v2/route-params' import {RecsAndRecos, numSectionLabel} from './recs-and-recos' import {formatAnyPhoneNumbers} from '@/util/phone-numbers' import {useRoute} from '@react-navigation/native' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import {useFollowerState} from '@/stores/followers' import {useCurrentUserState} from '@/stores/current-user' // import {useAnimatedScrollHandler} from '@/common-adapters/reanimated' diff --git a/shared/teams/common/use-contacts.native.tsx b/shared/teams/common/use-contacts.native.tsx index 822c30fea955..5fb8e60858e2 100644 --- a/shared/teams/common/use-contacts.native.tsx +++ b/shared/teams/common/use-contacts.native.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import {e164ToDisplay} from '@/util/phone-numbers' import logger from '@/logger' import {getDefaultCountryCode} from 'react-native-kb' -import {useSettingsContactsState} from '@/constants/settings-contacts' +import {useSettingsContactsState} from '@/stores/settings-contacts' import {getE164} from '@/constants/settings-phone' // Contact info coming from the native contacts library. From c6b766adb11d624735f907de1b0b8d945b4a64b3 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Fri, 9 Jan 2026 17:03:31 -0500 Subject: [PATCH 31/37] WIP --- .../settings-contacts.d.ts | 2 +- .../settings-contacts.desktop.tsx | 0 .../settings-contacts.native.tsx | 12 ++++---- shared/stores/settings-contacts.tsx | 28 ------------------- 4 files changed, 7 insertions(+), 35 deletions(-) rename shared/{constants => stores}/settings-contacts.d.ts (95%) rename shared/{constants => stores}/settings-contacts.desktop.tsx (100%) rename shared/{constants => stores}/settings-contacts.native.tsx (96%) delete mode 100644 shared/stores/settings-contacts.tsx diff --git a/shared/constants/settings-contacts.d.ts b/shared/stores/settings-contacts.d.ts similarity index 95% rename from shared/constants/settings-contacts.d.ts rename to shared/stores/settings-contacts.d.ts index 3f48c273c201..0ab05a739542 100644 --- a/shared/constants/settings-contacts.d.ts +++ b/shared/stores/settings-contacts.d.ts @@ -1,4 +1,4 @@ -import type * as T from './types' +import type * as T from '../constants/types' import type {UseBoundStore, StoreApi} from 'zustand' type PermissionStatus = 'granted' | 'denied' | 'undetermined' | 'unknown' diff --git a/shared/constants/settings-contacts.desktop.tsx b/shared/stores/settings-contacts.desktop.tsx similarity index 100% rename from shared/constants/settings-contacts.desktop.tsx rename to shared/stores/settings-contacts.desktop.tsx diff --git a/shared/constants/settings-contacts.native.tsx b/shared/stores/settings-contacts.native.tsx similarity index 96% rename from shared/constants/settings-contacts.native.tsx rename to shared/stores/settings-contacts.native.tsx index 972a30151b52..65e6f984ebc1 100644 --- a/shared/constants/settings-contacts.native.tsx +++ b/shared/stores/settings-contacts.native.tsx @@ -1,19 +1,19 @@ import * as Contacts from 'expo-contacts' -import {ignorePromise} from './utils' -import {importContactsWaitingKey} from './strings' -import * as T from './types' +import {ignorePromise} from '../constants/utils' +import {importContactsWaitingKey} from '../constants/strings' +import * as T from '../constants/types' import * as Z from '@/util/zustand' import {addNotificationRequest} from 'react-native-kb' import logger from '@/logger' import type {Store, State} from './settings-contacts' import {RPCError} from '@/util/errors' import {getDefaultCountryCode} from 'react-native-kb' -import {getE164} from './settings-phone' +import {getE164} from '../constants/settings-phone' import {pluralize} from '@/util/string' -import {navigateAppend} from './router2/util' +import {navigateAppend} from '../constants/router2/util' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useWaitingState} from './waiting' +import {useWaitingState} from '../constants/waiting' const importContactsConfigKey = (username: string) => `ui.importContacts.${username}` diff --git a/shared/stores/settings-contacts.tsx b/shared/stores/settings-contacts.tsx deleted file mode 100644 index e58e0b77761c..000000000000 --- a/shared/stores/settings-contacts.tsx +++ /dev/null @@ -1,28 +0,0 @@ -import * as Z from '@/util/zustand' -import type {Store, State} from '@/stores/settings-contacts' - -const initialStore: Store = { - alreadyOnKeybase: [], - importError: '', - importPromptDismissed: false, - importedCount: undefined, - permissionStatus: 'unknown', - userCountryCode: undefined, - waitingToShowJoinedModal: false, -} - -export const useSettingsContactsState = Z.createZustand(() => { - const dispatch: State['dispatch'] = { - editContactImportEnabled: () => {}, - importContactsLater: () => {}, - loadContactImportEnabled: () => {}, - loadContactPermissions: () => {}, - manageContactsCache: () => {}, - requestPermissions: () => {}, - resetState: 'default', - } - return { - ...initialStore, - dispatch, - } -}) From dc043c173ae28b97bb8dceac63626934f99da17b Mon Sep 17 00:00:00 2001 From: Chris Nojima Date: Sat, 10 Jan 2026 08:15:14 -0500 Subject: [PATCH 32/37] WIP --- shared/constants/init/shared.tsx | 2 +- shared/constants/push.native.tsx | 2 +- shared/constants/store-registry.tsx | 12 ++++++------ shared/people/todo.tsx | 2 +- shared/provision/forgot-username.tsx | 2 +- shared/settings/account/add-modals.tsx | 2 +- shared/settings/account/confirm-delete.tsx | 2 +- shared/settings/account/email-phone-row.tsx | 2 +- shared/settings/account/index.tsx | 4 ++-- shared/settings/advanced.tsx | 2 +- shared/settings/delete-confirm/index.tsx | 2 +- shared/settings/logout.tsx | 2 +- shared/settings/password.tsx | 2 +- shared/settings/root-phone.tsx | 2 +- shared/settings/sub-nav/left-nav.tsx | 2 +- shared/signup/phone-number/index.tsx | 2 +- shared/signup/phone-number/verify.tsx | 2 +- shared/stores/chat2.tsx | 2 +- shared/stores/provision.tsx | 2 +- .../index.tsx => stores/settings-password.tsx} | 0 .../index.tsx => stores/settings-phone.tsx} | 6 +++--- shared/stores/settings.tsx | 2 +- .../index.tsx => stores/team-building.tsx} | 4 ++-- .../waiting/index.tsx => stores/waiting.tsx} | 2 +- .../wallets/index.tsx => stores/wallets.tsx} | 8 ++++---- .../whats-new/index.tsx => stores/whats-new.tsx} | 6 +++--- shared/team-building/contacts.tsx | 2 +- shared/team-building/email-search.tsx | 2 +- shared/team-building/filtered-service-tab-bar.tsx | 2 +- shared/team-building/index.tsx | 2 +- shared/team-building/list-body.tsx | 2 +- shared/team-building/page.tsx | 2 +- shared/team-building/phone-search.tsx | 4 ++-- .../team-building/search-result/hellobot-result.tsx | 2 +- shared/team-building/search-result/you-result.tsx | 2 +- shared/team-building/shared.tsx | 2 +- shared/teams/add-members-wizard/add-phone.tsx | 2 +- shared/teams/common/use-contacts.native.tsx | 2 +- .../team-invite-by-contacts.native.tsx | 2 +- shared/wallets/index.tsx | 4 ++-- shared/wallets/really-remove-account.tsx | 4 ++-- shared/wallets/remove-account.tsx | 2 +- shared/whats-new/container.tsx | 4 ++-- shared/whats-new/icon/index.tsx | 4 ++-- shared/whats-new/index.tsx | 2 +- shared/whats-new/versions.tsx | 2 +- 46 files changed, 64 insertions(+), 64 deletions(-) rename shared/{constants/settings-password/index.tsx => stores/settings-password.tsx} (100%) rename shared/{constants/settings-phone/index.tsx => stores/settings-phone.tsx} (98%) rename shared/{constants/team-building/index.tsx => stores/team-building.tsx} (99%) rename shared/{constants/waiting/index.tsx => stores/waiting.tsx} (98%) rename shared/{constants/wallets/index.tsx => stores/wallets.tsx} (88%) rename shared/{constants/whats-new/index.tsx => stores/whats-new.tsx} (92%) diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index bde49933e8c8..951d795808f7 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -32,7 +32,7 @@ import {useTeamsState} from '@/stores/teams' import type * as UseTracker2StateType from '@/stores/tracker2' import type * as UseUnlockFoldersStateType from '@/stores/unlock-folders' import type * as UseUsersStateType from '@/stores/users' -import {useWhatsNewState} from '../whats-new' +import {useWhatsNewState} from '@/stores/whats-new' let _emitStartupOnLoadDaemonConnectedOnce = false let _devicesLoaded = false diff --git a/shared/constants/push.native.tsx b/shared/constants/push.native.tsx index 8ad849dbc456..7f115f028fe5 100644 --- a/shared/constants/push.native.tsx +++ b/shared/constants/push.native.tsx @@ -6,7 +6,7 @@ import {storeRegistry} from '@/constants/store-registry' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' import {useLogoutState} from '@/stores/logout' -import {useWaitingState} from '@/constants/waiting' +import {useWaitingState} from '@/stores/waiting' import * as Z from '@/util/zustand' import logger from '@/logger' import * as T from '@/constants/types' diff --git a/shared/constants/store-registry.tsx b/shared/constants/store-registry.tsx index e07725eaff26..d45249872caa 100644 --- a/shared/constants/store-registry.tsx +++ b/shared/constants/store-registry.tsx @@ -1,7 +1,7 @@ // used to allow non-circular cross-calls between stores // ONLY for zustand stores import type * as T from '@/constants/types' -import type * as TBType from '@/constants/team-building' +import type * as TBType from '@/stores/team-building' import type * as ConvoStateType from '@/constants/chat2/convostate' import type {ConvoState} from '@/constants/chat2/convostate' import type {State as AutoResetState, useAutoResetState} from '@/stores/autoreset' @@ -24,8 +24,8 @@ import type {State as SettingsState, useSettingsState} from '@/stores/settings' import type {State as SettingsChatState, useSettingsChatState} from '@/stores/settings-chat' import type {State as SettingsContactsState, useSettingsContactsState} from '@/stores/settings-contacts' import type {State as SettingsEmailState, useSettingsEmailState} from '@/stores/settings-email' -import type {State as SettingsPasswordState, usePWState} from '@/constants/settings-password' -import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/constants/settings-phone' +import type {State as SettingsPasswordState, usePWState} from '@/stores/settings-password' +import type {State as SettingsPhoneState, useSettingsPhoneState} from '@/stores/settings-phone' import type {State as SignupState, useSignupState} from '@/stores/signup' import type {State as TeamsState, useTeamsState} from '@/stores/teams' import type {State as Tracker2State, useTrackerState} from '@/stores/tracker2' @@ -185,11 +185,11 @@ class StoreRegistry { return useSettingsEmailState } case 'settings-password': { - const {usePWState} = require('@/constants/settings-password') + const {usePWState} = require('@/stores/settings-password') return usePWState } case 'settings-phone': { - const {useSettingsPhoneState} = require('@/constants/settings-phone') + const {useSettingsPhoneState} = require('@/stores/settings-phone') return useSettingsPhoneState } case 'signup': { @@ -222,7 +222,7 @@ class StoreRegistry { } getTBStore(name: T.TB.AllowedNamespace): TBType.State { - const {createTBStore} = require('@/constants/team-building') as typeof TBType + const {createTBStore} = require('@/stores/team-building') as typeof TBType const store = createTBStore(name) return store.getState() } diff --git a/shared/people/todo.tsx b/shared/people/todo.tsx index b0f8eb3c4e8e..87cafea4576a 100644 --- a/shared/people/todo.tsx +++ b/shared/people/todo.tsx @@ -6,7 +6,7 @@ import type * as T from '@/constants/types' import type {IconType} from '@/common-adapters/icon.constants-gen' import PeopleItem, {type TaskButton} from './item' import * as Kb from '@/common-adapters' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' import {useSettingsEmailState} from '@/stores/settings-email' import {settingsAccountTab, settingsGitTab} from '@/constants/settings/util' import {useTrackerState} from '@/stores/tracker2' diff --git a/shared/provision/forgot-username.tsx b/shared/provision/forgot-username.tsx index 5e85eb873829..ad746c8e7579 100644 --- a/shared/provision/forgot-username.tsx +++ b/shared/provision/forgot-username.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen, errorBanner} from '../signup/common' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' import {useProvisionState} from '@/stores/provision' const ForgotUsername = () => { diff --git a/shared/settings/account/add-modals.tsx b/shared/settings/account/add-modals.tsx index 11e6f2d5c8f2..5d203251e85d 100644 --- a/shared/settings/account/add-modals.tsx +++ b/shared/settings/account/add-modals.tsx @@ -6,7 +6,7 @@ import {EnterEmailBody} from '@/signup/email' import {EnterPhoneNumberBody} from '@/signup/phone-number' import VerifyBody from '@/signup/phone-number/verify-body' import {e164ToDisplay} from '@/util/phone-numbers' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' import {useSettingsEmailState} from '@/stores/settings-email' export const Email = () => { diff --git a/shared/settings/account/confirm-delete.tsx b/shared/settings/account/confirm-delete.tsx index ea7049ae09ac..1b4fa2d6f9aa 100644 --- a/shared/settings/account/confirm-delete.tsx +++ b/shared/settings/account/confirm-delete.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as PhoneUtil from '@/util/phone-numbers' import {useSafeNavigation} from '@/util/safe-navigation' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' import {useSettingsEmailState} from '@/stores/settings-email' type OwnProps = { diff --git a/shared/settings/account/email-phone-row.tsx b/shared/settings/account/email-phone-row.tsx index 321e0e7be5ad..1eec1a6336e7 100644 --- a/shared/settings/account/email-phone-row.tsx +++ b/shared/settings/account/email-phone-row.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' import {useSettingsEmailState} from '@/stores/settings-email' const addSpacer = (into: string, add: string) => { diff --git a/shared/settings/account/index.tsx b/shared/settings/account/index.tsx index 3d826788959e..c45c1d9725b0 100644 --- a/shared/settings/account/index.tsx +++ b/shared/settings/account/index.tsx @@ -2,8 +2,8 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import type * as React from 'react' import EmailPhoneRow from './email-phone-row' -import {usePWState} from '@/constants/settings-password' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {usePWState} from '@/stores/settings-password' +import {useSettingsPhoneState} from '@/stores/settings-phone' import {useSettingsEmailState} from '@/stores/settings-email' import {useSettingsState, settingsPasswordTab} from '@/stores/settings' diff --git a/shared/settings/advanced.tsx b/shared/settings/advanced.tsx index b5a0027f546d..1f57db34d60b 100644 --- a/shared/settings/advanced.tsx +++ b/shared/settings/advanced.tsx @@ -4,7 +4,7 @@ import * as T from '@/constants/types' import * as React from 'react' import {ProxySettings} from './proxy' import {useSettingsState, traceInProgressKey, processorProfileInProgressKey} from '@/stores/settings' -import {usePWState} from '@/constants/settings-password' +import {usePWState} from '@/stores/settings-password' import {useFSState} from '@/stores/fs' import {useConfigState} from '@/stores/config' diff --git a/shared/settings/delete-confirm/index.tsx b/shared/settings/delete-confirm/index.tsx index a72539e35601..e946c68aa858 100644 --- a/shared/settings/delete-confirm/index.tsx +++ b/shared/settings/delete-confirm/index.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import {useSafeNavigation} from '@/util/safe-navigation' -import {usePWState} from '@/constants/settings-password' +import {usePWState} from '@/stores/settings-password' import {useSettingsState} from '@/stores/settings' import {useCurrentUserState} from '@/stores/current-user' diff --git a/shared/settings/logout.tsx b/shared/settings/logout.tsx index ce846ef17ed8..c61c62e3656e 100644 --- a/shared/settings/logout.tsx +++ b/shared/settings/logout.tsx @@ -3,7 +3,7 @@ import {useSafeSubmit} from '@/util/safe-submit' import * as C from '@/constants' import * as Kb from '@/common-adapters' import {UpdatePassword} from './password' -import {usePWState} from '@/constants/settings-password' +import {usePWState} from '@/stores/settings-password' import {useSettingsState} from '@/stores/settings' import {useLogoutState} from '@/stores/logout' diff --git a/shared/settings/password.tsx b/shared/settings/password.tsx index afea9f8392ed..f9c157c2641b 100644 --- a/shared/settings/password.tsx +++ b/shared/settings/password.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import * as C from '@/constants' -import {usePWState} from '@/constants/settings-password' +import {usePWState} from '@/stores/settings-password' type Props = { error: string diff --git a/shared/settings/root-phone.tsx b/shared/settings/root-phone.tsx index 6afc0c92af25..379ad5fbc252 100644 --- a/shared/settings/root-phone.tsx +++ b/shared/settings/root-phone.tsx @@ -3,7 +3,7 @@ import {useConfigState} from '@/stores/config' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import {keybaseFM} from '@/constants/whats-new' +import {keybaseFM} from '@/stores/whats-new' import SettingsItem from './sub-nav/settings-item' import WhatsNewIcon from '../whats-new/icon' import noop from 'lodash/noop' diff --git a/shared/settings/sub-nav/left-nav.tsx b/shared/settings/sub-nav/left-nav.tsx index 4608d0727afb..57ca3a5fbf13 100644 --- a/shared/settings/sub-nav/left-nav.tsx +++ b/shared/settings/sub-nav/left-nav.tsx @@ -3,7 +3,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import WhatsNewIcon from '@/whats-new/icon' import SettingsItem from './settings-item' -import {keybaseFM} from '@/constants/whats-new' +import {keybaseFM} from '@/stores/whats-new' import * as Settings from '@/stores/settings' import {usePushState} from '@/constants/push' import {useNotifState} from '@/stores/notifications' diff --git a/shared/signup/phone-number/index.tsx b/shared/signup/phone-number/index.tsx index 9467647febbe..03ef62e70146 100644 --- a/shared/signup/phone-number/index.tsx +++ b/shared/signup/phone-number/index.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import {SignupScreen, errorBanner} from '../common' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' type BodyProps = { autoFocus?: boolean diff --git a/shared/signup/phone-number/verify.tsx b/shared/signup/phone-number/verify.tsx index 1e58e3fde7aa..b3368353a527 100644 --- a/shared/signup/phone-number/verify.tsx +++ b/shared/signup/phone-number/verify.tsx @@ -4,7 +4,7 @@ import * as Kb from '@/common-adapters' import {SignupScreen} from '../common' import {e164ToDisplay} from '@/util/phone-numbers' import VerifyBody from './verify-body' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' const Container = () => { const error = useSettingsPhoneState(s => (s.verificationState === 'error' ? s.error : '')) diff --git a/shared/stores/chat2.tsx b/shared/stores/chat2.tsx index 5e73973dbf30..18936b18c5c4 100644 --- a/shared/stores/chat2.tsx +++ b/shared/stores/chat2.tsx @@ -20,7 +20,7 @@ import {navigateAppend, navUpToScreen, switchTab} from '@/constants/router2/util import {storeRegistry} from '@/constants/store-registry' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useWaitingState} from '@/constants/waiting' +import {useWaitingState} from '@/stores/waiting' import * as S from '@/constants/strings' const defaultTopReacjis = [ diff --git a/shared/stores/provision.tsx b/shared/stores/provision.tsx index b8377c358c7e..b30d9a3d5e05 100644 --- a/shared/stores/provision.tsx +++ b/shared/stores/provision.tsx @@ -9,7 +9,7 @@ import isEqual from 'lodash/isEqual' import {rpcDeviceToDevice} from '@/constants/rpc-utils' import {invalidPasswordErrorString} from '@/constants/config/util' import {clearModals, navigateAppend} from '@/constants/router2/util' -import {useWaitingState} from '@/constants/waiting' +import {useWaitingState} from '@/stores/waiting' export type Device = { deviceNumberOfType: number diff --git a/shared/constants/settings-password/index.tsx b/shared/stores/settings-password.tsx similarity index 100% rename from shared/constants/settings-password/index.tsx rename to shared/stores/settings-password.tsx diff --git a/shared/constants/settings-phone/index.tsx b/shared/stores/settings-phone.tsx similarity index 98% rename from shared/constants/settings-phone/index.tsx rename to shared/stores/settings-phone.tsx index cc19e82aa27d..7bc7fdb62f46 100644 --- a/shared/constants/settings-phone/index.tsx +++ b/shared/stores/settings-phone.tsx @@ -1,6 +1,6 @@ -import * as T from '../types' -import * as S from '../strings' -import {ignorePromise} from '../utils' +import * as T from '@/constants/types' +import * as S from '@/constants/strings' +import {ignorePromise} from '@/constants/utils' import * as Z from '@/util/zustand' import logger from '@/logger' import {RPCError} from '@/util/errors' diff --git a/shared/stores/settings.tsx b/shared/stores/settings.tsx index fe18f64b2736..73fbe751a5f8 100644 --- a/shared/stores/settings.tsx +++ b/shared/stores/settings.tsx @@ -11,7 +11,7 @@ import {clearModals, navigateAppend, switchTab} from '@/constants/router2/util' import {storeRegistry} from '@/constants/store-registry' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useWaitingState} from '@/constants/waiting' +import {useWaitingState} from '@/stores/waiting' import {processorProfileInProgressKey, traceInProgressKey} from '@/constants/settings/util' export * from '@/constants/settings/util' diff --git a/shared/constants/team-building/index.tsx b/shared/stores/team-building.tsx similarity index 99% rename from shared/constants/team-building/index.tsx rename to shared/stores/team-building.tsx index a7105372fc8d..4db76d25466f 100644 --- a/shared/constants/team-building/index.tsx +++ b/shared/stores/team-building.tsx @@ -11,11 +11,11 @@ import {serviceIdFromString} from '@/util/platforms' import {type StoreApi, type UseBoundStore, useStore} from 'zustand' import {validateEmailAddress} from '@/util/email-address' import {registerDebugClear} from '@/util/debug' -import {searchWaitingKey} from './utils' +import {searchWaitingKey} from '@/constants/team-building/utils' import {navigateUp} from '@/constants/router2/util' import {storeRegistry} from '@/constants/store-registry' import {useCryptoState} from '@/stores/crypto' -export {allServices, selfToUser, searchWaitingKey} from './utils' +export {allServices, selfToUser, searchWaitingKey} from '@/constants/team-building/utils' type Store = T.Immutable<{ namespace: T.TB.AllowedNamespace diff --git a/shared/constants/waiting/index.tsx b/shared/stores/waiting.tsx similarity index 98% rename from shared/constants/waiting/index.tsx rename to shared/stores/waiting.tsx index c98dd7515a17..effcb51b5006 100644 --- a/shared/constants/waiting/index.tsx +++ b/shared/stores/waiting.tsx @@ -1,5 +1,5 @@ import type {RPCError} from '@/util/errors' -import type * as T from '../types' +import type * as T from '@/constants/types' import * as Z from '@/util/zustand' // This store has no dependencies on other stores and is safe to import directly from other stores. diff --git a/shared/constants/wallets/index.tsx b/shared/stores/wallets.tsx similarity index 88% rename from shared/constants/wallets/index.tsx rename to shared/stores/wallets.tsx index afd7a7acb144..e340fd2cf383 100644 --- a/shared/constants/wallets/index.tsx +++ b/shared/stores/wallets.tsx @@ -1,10 +1,10 @@ -import * as T from '../types' -import {ignorePromise} from '../utils' +import * as T from '@/constants/types' +import {ignorePromise} from '@/constants/utils' import * as Z from '@/util/zustand' -import {loadAccountsWaitingKey} from './utils' +import {loadAccountsWaitingKey} from '@/constants/wallets/utils' import {useConfigState} from '@/stores/config' -export {loadAccountsWaitingKey} from './utils' +export {loadAccountsWaitingKey} from '@/constants/wallets/utils' export type Account = { accountID: string diff --git a/shared/constants/whats-new/index.tsx b/shared/stores/whats-new.tsx similarity index 92% rename from shared/constants/whats-new/index.tsx rename to shared/stores/whats-new.tsx index 4a2d0bddcac0..2944a3685655 100644 --- a/shared/constants/whats-new/index.tsx +++ b/shared/stores/whats-new.tsx @@ -1,9 +1,9 @@ -import type * as T from '../types' +import type * as T from '@/constants/types' import * as Z from '@/util/zustand' import {uint8ArrayToString} from 'uint8array-extras' -import {noVersion, getSeenVersions} from './utils' +import {noVersion, getSeenVersions} from '@/constants/whats-new/utils' -export {currentVersion, lastVersion, lastLastVersion, keybaseFM} from './utils' +export {currentVersion, lastVersion, lastLastVersion, keybaseFM} from '@/constants/whats-new/utils' // This store has no dependencies on other stores and is safe to import directly from other stores. type SeenVersionsMap = {[key in string]: boolean} diff --git a/shared/team-building/contacts.tsx b/shared/team-building/contacts.tsx index 5112b6f2d719..06edc5fb79f2 100644 --- a/shared/team-building/contacts.tsx +++ b/shared/team-building/contacts.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' import {useSettingsContactsState} from '@/stores/settings-contacts' -import {useTBContext} from '@/constants/team-building' +import {useTBContext} from '@/stores/team-building' const useContactsProps = () => { const contactsImported = useSettingsContactsState(s => s.importEnabled) diff --git a/shared/team-building/email-search.tsx b/shared/team-building/email-search.tsx index 669e819c92a4..3b0ffa004508 100644 --- a/shared/team-building/email-search.tsx +++ b/shared/team-building/email-search.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as TB from '@/constants/team-building' +import * as TB from '@/stores/team-building' import * as React from 'react' import * as Kb from '@/common-adapters' import type * as T from '@/constants/types' diff --git a/shared/team-building/filtered-service-tab-bar.tsx b/shared/team-building/filtered-service-tab-bar.tsx index 353ce9fa5665..b882965f5429 100644 --- a/shared/team-building/filtered-service-tab-bar.tsx +++ b/shared/team-building/filtered-service-tab-bar.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import type * as T from '@/constants/types' import {ServiceTabBar} from './service-tab-bar' -import * as TeamBuilding from '@/constants/team-building' +import * as TeamBuilding from '@/stores/team-building' export const FilteredServiceTabBar = ( props: Omit, 'services'> & { diff --git a/shared/team-building/index.tsx b/shared/team-building/index.tsx index 617f88b7b935..7b94ab175862 100644 --- a/shared/team-building/index.tsx +++ b/shared/team-building/index.tsx @@ -1,5 +1,5 @@ import * as C from '@/constants' -import * as TB from '@/constants/team-building' +import * as TB from '@/stores/team-building' import * as Teams from '@/stores/teams' import * as Kb from '@/common-adapters' import * as React from 'react' diff --git a/shared/team-building/list-body.tsx b/shared/team-building/list-body.tsx index e37d7bb8b5ef..20b0bcd9dac5 100644 --- a/shared/team-building/list-body.tsx +++ b/shared/team-building/list-body.tsx @@ -1,6 +1,6 @@ import * as React from 'react' import * as C from '@/constants' -import * as TB from '@/constants/team-building' +import * as TB from '@/stores/team-building' import {useTeamsState} from '@/stores/teams' import * as Kb from '@/common-adapters' import * as Shared from './shared' diff --git a/shared/team-building/page.tsx b/shared/team-building/page.tsx index a5f899216400..083c6b96837b 100644 --- a/shared/team-building/page.tsx +++ b/shared/team-building/page.tsx @@ -1,7 +1,7 @@ import type * as C from '@/constants' import * as Kb from '@/common-adapters' import * as React from 'react' -import {TBProvider} from '@/constants/team-building' +import {TBProvider} from '@/stores/team-building' const getOptions = ({route}: OwnProps) => { const namespace: unknown = route.params.namespace diff --git a/shared/team-building/phone-search.tsx b/shared/team-building/phone-search.tsx index 4a93fd2dd078..993278b057c9 100644 --- a/shared/team-building/phone-search.tsx +++ b/shared/team-building/phone-search.tsx @@ -1,10 +1,10 @@ import * as C from '@/constants' -import * as TB from '@/constants/team-building' +import * as TB from '@/stores/team-building' import * as React from 'react' import * as Kb from '@/common-adapters/index' import type * as T from 'constants/types' import ContinueButton from './continue-button' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' type PhoneSearchProps = { continueLabel: string diff --git a/shared/team-building/search-result/hellobot-result.tsx b/shared/team-building/search-result/hellobot-result.tsx index 4ba191ddc868..8e080121a890 100644 --- a/shared/team-building/search-result/hellobot-result.tsx +++ b/shared/team-building/search-result/hellobot-result.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/stores/chat2' import * as React from 'react' -import {useTBContext} from '@/constants/team-building' +import {useTBContext} from '@/stores/team-building' import * as Kb from '@/common-adapters' import CommonResult, {type ResultProps} from './common-result' diff --git a/shared/team-building/search-result/you-result.tsx b/shared/team-building/search-result/you-result.tsx index 3ce11d515026..0c482c089fc9 100644 --- a/shared/team-building/search-result/you-result.tsx +++ b/shared/team-building/search-result/you-result.tsx @@ -1,6 +1,6 @@ import * as Chat from '@/stores/chat2' import * as React from 'react' -import {useTBContext} from '@/constants/team-building' +import {useTBContext} from '@/stores/team-building' import * as Kb from '@/common-adapters' import CommonResult, {type ResultProps} from './common-result' diff --git a/shared/team-building/shared.tsx b/shared/team-building/shared.tsx index 6342bd06fd0b..9303fdcff0ef 100644 --- a/shared/team-building/shared.tsx +++ b/shared/team-building/shared.tsx @@ -1,7 +1,7 @@ import type * as T from '@/constants/types' import * as Kb from '@/common-adapters' import type {IconType} from '@/common-adapters/icon.constants-gen' -import * as TeamBuilding from '@/constants/team-building' +import * as TeamBuilding from '@/stores/team-building' const services: { [K in T.TB.ServiceIdWithContact]: { diff --git a/shared/teams/add-members-wizard/add-phone.tsx b/shared/teams/add-members-wizard/add-phone.tsx index abeaa50273a8..5ed2a3a15ae2 100644 --- a/shared/teams/add-members-wizard/add-phone.tsx +++ b/shared/teams/add-members-wizard/add-phone.tsx @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import {ModalTitle, usePhoneNumberList} from '../common' import {useSafeNavigation} from '@/util/safe-navigation' -import {useSettingsPhoneState} from '@/constants/settings-phone' +import {useSettingsPhoneState} from '@/stores/settings-phone' const waitingKey = 'phoneLookup' diff --git a/shared/teams/common/use-contacts.native.tsx b/shared/teams/common/use-contacts.native.tsx index 5fb8e60858e2..75a3ec6b9dd4 100644 --- a/shared/teams/common/use-contacts.native.tsx +++ b/shared/teams/common/use-contacts.native.tsx @@ -4,7 +4,7 @@ import {e164ToDisplay} from '@/util/phone-numbers' import logger from '@/logger' import {getDefaultCountryCode} from 'react-native-kb' import {useSettingsContactsState} from '@/stores/settings-contacts' -import {getE164} from '@/constants/settings-phone' +import {getE164} from '@/stores/settings-phone' // Contact info coming from the native contacts library. export type Contact = { diff --git a/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx b/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx index cc3aa7bba913..38aa29b4a19e 100644 --- a/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx +++ b/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx @@ -5,7 +5,7 @@ import useContacts, {type Contact} from '../common/use-contacts.native' import {InviteByContact, type ContactRowProps} from './index.native' import {useTeamDetailsSubscribe} from '../subscriber' import {useSafeNavigation} from '@/util/safe-navigation' -import {getE164} from '@/constants/settings-phone' +import {getE164} from '@/stores/settings-phone' // Seitan invite names (labels) look like this: "[name] ([phone number])". Try // to derive E164 phone number based on seitan invite name and user's region. diff --git a/shared/wallets/index.tsx b/shared/wallets/index.tsx index 796c7dc738ab..9cdbccfe61df 100644 --- a/shared/wallets/index.tsx +++ b/shared/wallets/index.tsx @@ -2,8 +2,8 @@ import * as C from '@/constants' import * as React from 'react' import * as Kb from '@/common-adapters' import * as T from '@/constants/types' -import * as Wallets from '@/constants/wallets' -import {useState as useWalletsState} from '@/constants/wallets' +import * as Wallets from '@/stores/wallets' +import {useState as useWalletsState} from '@/stores/wallets' const Row = (p: {account: Wallets.Account}) => { const {account} = p diff --git a/shared/wallets/really-remove-account.tsx b/shared/wallets/really-remove-account.tsx index 1e356ab1b640..88c7ad3c6408 100644 --- a/shared/wallets/really-remove-account.tsx +++ b/shared/wallets/really-remove-account.tsx @@ -3,8 +3,8 @@ import * as Kb from '@/common-adapters' import * as T from '@/constants/types' import * as React from 'react' import WalletPopup from './wallet-popup' -import * as Wallets from '@/constants/wallets' -import {useState as useWalletsState} from '@/constants/wallets' +import * as Wallets from '@/stores/wallets' +import {useState as useWalletsState} from '@/stores/wallets' import {useConfigState} from '@/stores/config' type OwnProps = {accountID: string} diff --git a/shared/wallets/remove-account.tsx b/shared/wallets/remove-account.tsx index 6088a87265c4..4847147c1825 100644 --- a/shared/wallets/remove-account.tsx +++ b/shared/wallets/remove-account.tsx @@ -1,7 +1,7 @@ import * as C from '@/constants' import * as Kb from '@/common-adapters' import WalletPopup from './wallet-popup' -import {useState as useWalletsState} from '@/constants/wallets' +import {useState as useWalletsState} from '@/stores/wallets' type OwnProps = {accountID: string} diff --git a/shared/whats-new/container.tsx b/shared/whats-new/container.tsx index 7fa47ff09947..5f2fbf69501d 100644 --- a/shared/whats-new/container.tsx +++ b/shared/whats-new/container.tsx @@ -1,9 +1,9 @@ import * as C from '@/constants' import openURL from '@/util/open-url' -import {currentVersion} from '@/constants/whats-new' +import {currentVersion} from '@/stores/whats-new' import {Current, Last, LastLast} from './versions' import WhatsNew from '.' -import {useWhatsNewState as useWNState} from '@/constants/whats-new' +import {useWhatsNewState as useWNState} from '@/stores/whats-new' import {useConfigState} from '@/stores/config' const WhatsNewContainer = () => { diff --git a/shared/whats-new/icon/index.tsx b/shared/whats-new/icon/index.tsx index 05ca4fb3b455..08ee61d17832 100644 --- a/shared/whats-new/icon/index.tsx +++ b/shared/whats-new/icon/index.tsx @@ -1,10 +1,10 @@ import * as React from 'react' import * as Kb from '@/common-adapters' import type {IconStyle} from '@/common-adapters/icon' -import {keybaseFM} from '@/constants/whats-new' +import {keybaseFM} from '@/stores/whats-new' import Popup from './popup' import './icon.css' -import {useWhatsNewState as useWNState} from '@/constants/whats-new' +import {useWhatsNewState as useWNState} from '@/stores/whats-new' type OwnProps = { color?: string diff --git a/shared/whats-new/index.tsx b/shared/whats-new/index.tsx index f52f93af4ef6..f15609db9263 100644 --- a/shared/whats-new/index.tsx +++ b/shared/whats-new/index.tsx @@ -1,7 +1,7 @@ import type * as React from 'react' import * as Kb from '@/common-adapters' import type * as C from '@/constants' -import {currentVersion, lastVersion, lastLastVersion} from '@/constants/whats-new' +import {currentVersion, lastVersion, lastLastVersion} from '@/stores/whats-new' import type {VersionProps} from './versions' type Props = { diff --git a/shared/whats-new/versions.tsx b/shared/whats-new/versions.tsx index cd3763ab6b12..05433c1fa130 100644 --- a/shared/whats-new/versions.tsx +++ b/shared/whats-new/versions.tsx @@ -2,7 +2,7 @@ import * as C from '@/constants' import {encryptTab} from '@/constants/crypto/util' import type * as React from 'react' import * as Kb from '@/common-adapters' -import {keybaseFM} from '@/constants/whats-new' +import {keybaseFM} from '@/stores/whats-new' import NewFeatureRow from './new-feature-row' import {settingsCryptoTab, settingsDisplayTab} from '@/constants/settings/util' From c34e5cddb177151ec4661b5c864c0cb27609b13d Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Sat, 10 Jan 2026 08:42:43 -0500 Subject: [PATCH 33/37] WIP --- shared/constants/index.tsx | 4 +-- shared/stores/settings-contacts.native.tsx | 6 ++--- shared/stores/settings-phone.tsx | 26 +------------------ shared/teams/common/use-contacts.native.tsx | 2 +- .../team-invite-by-contacts.native.tsx | 2 +- shared/util/phone-numbers/index.tsx | 20 +++++++++++--- 6 files changed, 25 insertions(+), 35 deletions(-) diff --git a/shared/constants/index.tsx b/shared/constants/index.tsx index c9d0a1413f0a..7911ee17773b 100644 --- a/shared/constants/index.tsx +++ b/shared/constants/index.tsx @@ -4,7 +4,7 @@ export * from './strings' export {useRouterState, makeScreen} from '@/stores/router2' export * as Router2 from '@/stores/router2' export * as Tabs from './tabs' -export {useWaitingState} from './waiting' -export * as Waiting from './waiting' +export {useWaitingState} from '@/stores/waiting' +export * as Waiting from '@/stores/waiting' export * as PlatformSpecific from './platform-specific' export * from './utils' diff --git a/shared/stores/settings-contacts.native.tsx b/shared/stores/settings-contacts.native.tsx index 65e6f984ebc1..786e6d0710ab 100644 --- a/shared/stores/settings-contacts.native.tsx +++ b/shared/stores/settings-contacts.native.tsx @@ -8,12 +8,12 @@ import logger from '@/logger' import type {Store, State} from './settings-contacts' import {RPCError} from '@/util/errors' import {getDefaultCountryCode} from 'react-native-kb' -import {getE164} from '../constants/settings-phone' +import {getE164} from '@/util/phone-numbers' import {pluralize} from '@/util/string' -import {navigateAppend} from '../constants/router2/util' +import {navigateAppend} from '@/constants/router2/util' import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' -import {useWaitingState} from '../constants/waiting' +import {useWaitingState} from '@/stores/waiting' const importContactsConfigKey = (username: string) => `ui.importContacts.${username}` diff --git a/shared/stores/settings-phone.tsx b/shared/stores/settings-phone.tsx index 7bc7fdb62f46..a70f161aa1f0 100644 --- a/shared/stores/settings-phone.tsx +++ b/shared/stores/settings-phone.tsx @@ -4,12 +4,7 @@ import {ignorePromise} from '@/constants/utils' import * as Z from '@/util/zustand' import logger from '@/logger' import {RPCError} from '@/util/errors' -import type { - e164ToDisplay as e164ToDisplayType, - phoneUtil as phoneUtilType, - ValidationResult as ValidationResultType, - PhoneNumberFormat as PhoneNumberFormatType, -} from '@/util/phone-numbers' +import type {e164ToDisplay as e164ToDisplayType} from '@/util/phone-numbers' export const makePhoneRow = (): PhoneRow => ({ displayNumber: '', @@ -19,25 +14,6 @@ export const makePhoneRow = (): PhoneRow => ({ verified: false, }) -// Get phone number in e.164, or null if we can't parse it. -export const getE164 = (phoneNumber: string, countryCode?: string) => { - const {phoneUtil, ValidationResult, PhoneNumberFormat} = require('@/util/phone-numbers') as { - phoneUtil: typeof phoneUtilType - ValidationResult: typeof ValidationResultType - PhoneNumberFormat: typeof PhoneNumberFormatType - } - try { - const parsed = countryCode ? phoneUtil.parse(phoneNumber, countryCode) : phoneUtil.parse(phoneNumber) - const reason = phoneUtil.isPossibleNumberWithReason(parsed) - if (reason !== ValidationResult.IS_POSSIBLE) { - return null - } - return phoneUtil.format(parsed, PhoneNumberFormat.E164) - } catch { - return null - } -} - const toPhoneRow = (p: T.RPCGen.UserPhoneNumber) => { const {e164ToDisplay} = require('@/util/phone-numbers') as {e164ToDisplay: typeof e164ToDisplayType} return { diff --git a/shared/teams/common/use-contacts.native.tsx b/shared/teams/common/use-contacts.native.tsx index 75a3ec6b9dd4..aa8329ca7130 100644 --- a/shared/teams/common/use-contacts.native.tsx +++ b/shared/teams/common/use-contacts.native.tsx @@ -4,7 +4,7 @@ import {e164ToDisplay} from '@/util/phone-numbers' import logger from '@/logger' import {getDefaultCountryCode} from 'react-native-kb' import {useSettingsContactsState} from '@/stores/settings-contacts' -import {getE164} from '@/stores/settings-phone' +import {getE164} from '@/util/phone-numbers' // Contact info coming from the native contacts library. export type Contact = { diff --git a/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx b/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx index 38aa29b4a19e..cffc7f924255 100644 --- a/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx +++ b/shared/teams/invite-by-contact/team-invite-by-contacts.native.tsx @@ -5,7 +5,7 @@ import useContacts, {type Contact} from '../common/use-contacts.native' import {InviteByContact, type ContactRowProps} from './index.native' import {useTeamDetailsSubscribe} from '../subscriber' import {useSafeNavigation} from '@/util/safe-navigation' -import {getE164} from '@/stores/settings-phone' +import {getE164} from '@/util/phone-numbers' // Seitan invite names (labels) look like this: "[name] ([phone number])". Try // to derive E164 phone number based on seitan invite name and user's region. diff --git a/shared/util/phone-numbers/index.tsx b/shared/util/phone-numbers/index.tsx index 7c419b18d118..587795dbaf09 100644 --- a/shared/util/phone-numbers/index.tsx +++ b/shared/util/phone-numbers/index.tsx @@ -2,10 +2,10 @@ import * as C from '@/constants' import libphonenumber from 'google-libphonenumber' const PNF = libphonenumber.PhoneNumberFormat -export const PhoneNumberFormat = PNF +const PhoneNumberFormat = PNF -export const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance() -export const ValidationResult = libphonenumber.PhoneNumberUtil.ValidationResult +const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance() +const ValidationResult = libphonenumber.PhoneNumberUtil.ValidationResult const supported = phoneUtil.getSupportedRegions() export type CountryData = { @@ -188,3 +188,17 @@ export const formatPhoneNumberInternational = (rawNumber: string): string | unde return undefined } } + +// Get phone number in e.164, or null if we can't parse it. +export const getE164 = (phoneNumber: string, countryCode?: string) => { + try { + const parsed = countryCode ? phoneUtil.parse(phoneNumber, countryCode) : phoneUtil.parse(phoneNumber) + const reason = phoneUtil.isPossibleNumberWithReason(parsed) + if (reason !== ValidationResult.IS_POSSIBLE) { + return null + } + return phoneUtil.format(parsed, PhoneNumberFormat.E164) + } catch { + return null + } +} From 6b100a4fcaa33513fbf420c5ef494aa7f193f8f5 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Mon, 12 Jan 2026 08:38:51 -0500 Subject: [PATCH 34/37] WIP --- shared/stores/autoreset.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/shared/stores/autoreset.tsx b/shared/stores/autoreset.tsx index ba72bf82ba3c..af4e33076267 100644 --- a/shared/stores/autoreset.tsx +++ b/shared/stores/autoreset.tsx @@ -61,10 +61,15 @@ export const useAutoResetState = Z.createZustand((set, get) => { logger.error('Error in CancelAutoreset', error) switch (error.code) { case T.RPCGen.StatusCode.scnosession: + // We got logged out because we were revoked (which might have been + // because the reset was completed and this device wasn't notified). return undefined case T.RPCGen.StatusCode.scnotfound: + // "User not in autoreset queue." + // do nothing, fall out of the catch block to cancel reset modal. break default: + // Any other error - display a red bar in the modal. { const desc = error.desc set(s => { @@ -135,10 +140,7 @@ export const useAutoResetState = Z.createZustand((set, get) => { s.endTime = params.endTime * 1000 }) } - navigateAppend( - {props: {pipelineStarted: !params.needVerify}, selected: 'resetWaiting'}, - true - ) + navigateAppend({props: {pipelineStarted: !params.needVerify}, selected: 'resetWaiting'}, true) }, }, params: { From f7e7a01eaaa85d3a5747cf3627ad57fcf60b4231 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Mon, 12 Jan 2026 08:41:03 -0500 Subject: [PATCH 35/37] WIP --- shared/stores/bots.tsx | 3 ++- shared/stores/devices.tsx | 5 +++++ shared/stores/followers.tsx | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/shared/stores/bots.tsx b/shared/stores/bots.tsx index 6a65ba660878..e922a4538206 100644 --- a/shared/stores/bots.tsx +++ b/shared/stores/bots.tsx @@ -14,7 +14,7 @@ type Store = T.Immutable<{ featuredBotsPage: number featuredBotsLoaded: boolean featuredBotsMap: Map - botSearchResults: Map + botSearchResults: Map // Keyed so that we never show results that don't match the user's input (e.g. outdated results) }> const initialStore: Store = { @@ -136,6 +136,7 @@ export const useBotsState = Z.createZustand((set, get) => { query, }) if (!bots || bots.length === 0) { + // don't do anything with a bad response from rpc return } get().dispatch.updateFeaturedBots(bots) diff --git a/shared/stores/devices.tsx b/shared/stores/devices.tsx index 7012413b7337..a8404ad69f98 100644 --- a/shared/stores/devices.tsx +++ b/shared/stores/devices.tsx @@ -110,6 +110,10 @@ export const useRevokedDeviceCounts = () => { return [...ds.values()].reduce((c, v) => (v.revokedAt ? c + 1 : c), 0) } +// Icons are numbered 1-10, so this focuses on mapping +// Device -> [1, 10] +// We split devices by type and order them by creation time. Then, we use (index mod 10) +// as the background # export const numBackgrounds = 10 export const useDeviceIconNumber = (deviceID: T.Devices.DeviceID) => { @@ -120,6 +124,7 @@ export const useDeviceIconNumber = (deviceID: T.Devices.DeviceID) => { export const useNextDeviceIconNumber = () => { const dm = useDevicesState(s => s.deviceMap) const next = React.useMemo(() => { + // Find the max device number and add one (+ one more since these are 1-indexed) const result = {backup: 1, desktop: 1, mobile: 1} dm.forEach(device => { if (device.deviceNumberOfType >= result[device.type]) { diff --git a/shared/stores/followers.tsx b/shared/stores/followers.tsx index f7f550f23102..b403722e07af 100644 --- a/shared/stores/followers.tsx +++ b/shared/stores/followers.tsx @@ -1,6 +1,6 @@ import * as T from '@/constants/types' import * as Z from '@/util/zustand' - +// This store has no dependencies on other stores and is safe to import directly from other stores. type Store = T.Immutable<{ followers: Set following: Set From 01c43127c2480e5cb6a57be3d489defe9e1d4696 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Mon, 12 Jan 2026 09:07:15 -0500 Subject: [PATCH 36/37] WIP --- shared/constants/fs/common.native.tsx | 2 +- shared/constants/fs/index.tsx | 1812 ----------------- .../fs/platform-specific.android.tsx | 68 +- .../fs/platform-specific.desktop.tsx | 5 +- shared/constants/init/index.desktop.tsx | 2 +- shared/constants/init/index.native.tsx | 2 +- 6 files changed, 39 insertions(+), 1852 deletions(-) delete mode 100644 shared/constants/fs/index.tsx diff --git a/shared/constants/fs/common.native.tsx b/shared/constants/fs/common.native.tsx index 6358c7a6cbc4..920f0561993f 100644 --- a/shared/constants/fs/common.native.tsx +++ b/shared/constants/fs/common.native.tsx @@ -6,7 +6,7 @@ import * as Styles from '@/styles' import * as FS from '@/stores/fs' import {launchImageLibraryAsync} from '@/util/expo-image-picker.native' import {saveAttachmentToCameraRoll, showShareActionSheet} from '../platform-specific' -import {useFSState} from '.' +import {useFSState} from '@/stores/fs' export default function initNative() { useFSState.setState(s => { diff --git a/shared/constants/fs/index.tsx b/shared/constants/fs/index.tsx deleted file mode 100644 index 0a81ec057c9b..000000000000 --- a/shared/constants/fs/index.tsx +++ /dev/null @@ -1,1812 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {ignorePromise, timeoutPromise} from '../utils' -import * as S from '../strings' -import {requestPermissionsToWrite} from '../platform-specific' -import * as Tabs from '../tabs' -import * as T from '../types' -import * as Z from '@/util/zustand' -import NotifyPopup from '@/util/notify-popup' -import {RPCError} from '@/util/errors' -import logger from '@/logger' -import {tlfToPreferredOrder} from '@/util/kbfs' -import isObject from 'lodash/isObject' -import isEqual from 'lodash/isEqual' -import {navigateAppend, navigateUp} from '../router2/util' -import {storeRegistry} from '../store-registry' -import {useConfigState} from '@/stores/config' -import {useCurrentUserState} from '@/stores/current-user' -import * as Util from './util' - -export * from './util' - -const subscriptionDeduplicateIntervalSecond = 1 - -// RPC expects a string that's interpreted as [16]byte on Go side and it has to -// be unique among all ongoing ops at any given time. uuidv1 may exceed 16 -// bytes, so just roll something simple that's seeded with time. -// -// MAX_SAFE_INTEGER after toString(36) is 11 characters, so this should take <= -// 12 chars -const uuidSeed = Date.now().toString(36) + '-' -let counter = 0 -// We have 36^4=1,679,616 of space to work with in order to not exceed 16 -// bytes. -const counterMod = 36 * 36 * 36 * 36 -export const makeUUID = () => { - counter = (counter + 1) % counterMod - return uuidSeed + counter.toString(36) -} - -export const clientID = makeUUID() - -export const makeEditID = (): T.FS.EditID => T.FS.stringToEditID(makeUUID()) - -export const resetBannerType = (s: State, path: T.FS.Path): T.FS.ResetBannerType => { - const resetParticipants = Util.getTlfFromPath(s.tlfs, path).resetParticipants - if (resetParticipants.length === 0) { - return T.FS.ResetBannerNoOthersType.None - } - - const you = useCurrentUserState.getState().username - if (resetParticipants.findIndex(username => username === you) >= 0) { - return T.FS.ResetBannerNoOthersType.Self - } - return resetParticipants.length -} - -export const makeActionsForDestinationPickerOpen = (index: number, path: T.FS.Path) => { - useFSState.getState().dispatch.setDestinationPickerParentPath(index, path) - navigateAppend({props: {index}, selected: 'destinationPicker'}) -} - -const noAccessErrorCodes: Array = [ - T.RPCGen.StatusCode.scsimplefsnoaccess, - T.RPCGen.StatusCode.scteamnotfound, - T.RPCGen.StatusCode.scteamreaderror, -] - -export const errorToActionOrThrow = (error: unknown, path?: T.FS.Path) => { - if (!isObject(error)) return - const code = (error as {code?: T.RPCGen.StatusCode}).code - if (code === T.RPCGen.StatusCode.sckbfsclienttimeout) { - useFSState.getState().dispatch.checkKbfsDaemonRpcStatus() - return - } - if (code === T.RPCGen.StatusCode.scidentifiesfailed) { - // This is specifically to address the situation where when user tries to - // remove a shared TLF from their favorites but another user of the TLF has - // deleted their account the subscribePath call cauused from the popup will - // get SCIdentifiesFailed error. We can't do anything here so just move on. - // (Ideally we'd be able to tell it's becaue the user was deleted, but we - // don't have that from Go right now.) - // - // TODO: TRIAGE-2379 this should probably be ignored on Go side. We - // already use fsGui identifyBehavior and there's no reason we should get - // an identify error here. - return undefined - } - if (path && code === T.RPCGen.StatusCode.scsimplefsnotexist) { - useFSState.getState().dispatch.setPathSoftError(path, T.FS.SoftError.Nonexistent) - return - } - if (path && code && noAccessErrorCodes.includes(code)) { - const tlfPath = Util.getTlfPath(path) - if (tlfPath) { - useFSState.getState().dispatch.setTlfSoftError(tlfPath, T.FS.SoftError.NoAccess) - return - } - } - if (code === T.RPCGen.StatusCode.scdeleted) { - // The user is deleted. Let user know and move on. - useFSState.getState().dispatch.redbar('A user in this shared folder has deleted their account.') - return - } - throw error -} - -type Store = T.Immutable<{ - badge: T.RPCGen.FilesTabBadge - criticalUpdate: boolean - destinationPicker: T.FS.DestinationPicker - downloads: T.FS.Downloads - edits: T.FS.Edits - errors: ReadonlyArray - fileContext: ReadonlyMap - folderViewFilter: string | undefined // on mobile, '' is expanded empty, undefined is unexpanded - kbfsDaemonStatus: T.FS.KbfsDaemonStatus - lastPublicBannerClosedTlf: string - overallSyncStatus: T.FS.OverallSyncStatus - pathItemActionMenu: T.FS.PathItemActionMenu - pathItems: T.FS.PathItems - pathInfos: ReadonlyMap - pathUserSettings: ReadonlyMap - settings: T.FS.Settings - sfmi: T.FS.SystemFileManagerIntegration - softErrors: T.FS.SoftErrors - tlfUpdates: T.FS.UserTlfUpdates - tlfs: T.FS.Tlfs - uploads: T.FS.Uploads -}> -const initialStore: Store = { - badge: T.RPCGen.FilesTabBadge.none, - criticalUpdate: false, - destinationPicker: { - destinationParentPath: [], - source: { - type: T.FS.DestinationPickerSource.None, - }, - }, - downloads: { - info: new Map(), - regularDownloads: [], - state: new Map(), - }, - edits: new Map(), - errors: [], - fileContext: new Map(), - folderViewFilter: undefined, - kbfsDaemonStatus: Util.unknownKbfsDaemonStatus, - lastPublicBannerClosedTlf: '', - overallSyncStatus: Util.emptyOverallSyncStatus, - pathInfos: new Map(), - pathItemActionMenu: Util.emptyPathItemActionMenu, - pathItems: new Map(), - pathUserSettings: new Map(), - settings: Util.emptySettings, - sfmi: { - directMountDir: '', - driverStatus: Util.defaultDriverStatus, - preferredMountDirs: [], - }, - softErrors: { - pathErrors: new Map(), - tlfErrors: new Map(), - }, - tlfUpdates: [], - tlfs: { - additionalTlfs: new Map(), - loaded: false, - private: new Map(), - public: new Map(), - team: new Map(), - }, - uploads: { - endEstimate: undefined, - syncingPaths: new Set(), - totalSyncingBytes: 0, - writingToJournal: new Map(), - }, -} - -export interface State extends Store { - dispatch: { - cancelDownload: (downloadID: string) => void - checkKbfsDaemonRpcStatus: () => void - commitEdit: (editID: T.FS.EditID) => void - deleteFile: (path: T.FS.Path) => void - discardEdit: (editID: T.FS.EditID) => void - dismissDownload: (downloadID: string) => void - dismissRedbar: (index: number) => void - dismissUpload: (uploadID: string) => void - download: (path: T.FS.Path, type: 'download' | 'share' | 'saveMedia') => void - driverDisable: () => void - driverDisabling: () => void - driverEnable: (isRetry?: boolean) => void - driverKextPermissionError: () => void - dynamic: { - afterDriverDisable?: () => void - afterDriverDisabling?: () => void - afterDriverEnabled?: (isRetry: boolean) => void - afterKbfsDaemonRpcStatusChanged?: () => void - finishedDownloadWithIntentMobile?: ( - downloadID: string, - downloadIntent: T.FS.DownloadIntent, - mimeType: string - ) => void - finishedRegularDownloadMobile?: (downloadID: string, mimeType: string) => void - openFilesFromWidgetDesktop?: (path: T.FS.Path) => void - openAndUploadDesktop?: (type: T.FS.OpenDialogType, parentPath: T.FS.Path) => void - pickAndUploadMobile?: (type: T.FS.MobilePickType, parentPath: T.FS.Path) => void - openLocalPathInSystemFileManagerDesktop?: (localPath: string) => void - openPathInSystemFileManagerDesktop?: (path: T.FS.Path) => void - openSecurityPreferencesDesktop?: () => void - refreshDriverStatusDesktop?: () => void - refreshMountDirsDesktop?: () => void - setSfmiBannerDismissedDesktop?: (dismissed: boolean) => void - uploadFromDragAndDropDesktop?: (parentPath: T.FS.Path, localPaths: Array) => void - } - editError: (editID: T.FS.EditID, error: string) => void - editSuccess: (editID: T.FS.EditID) => void - favoritesLoad: () => void - favoriteIgnore: (path: T.FS.Path) => void - finishManualConflictResolution: (localViewTlfPath: T.FS.Path) => void - folderListLoad: (path: T.FS.Path, recursive: boolean) => void - getOnlineStatus: () => void - journalUpdate: (syncingPaths: Array, totalSyncingBytes: number, endEstimate?: number) => void - kbfsDaemonOnlineStatusChanged: (onlineStatus: T.RPCGen.KbfsOnlineStatus) => void - kbfsDaemonRpcStatusChanged: (rpcStatus: T.FS.KbfsDaemonRpcStatus) => void - letResetUserBackIn: (id: T.RPCGen.TeamID, username: string) => void - loadAdditionalTlf: (tlfPath: T.FS.Path) => void - loadFileContext: (path: T.FS.Path) => void - loadFilesTabBadge: () => void - loadPathInfo: (path: T.FS.Path) => void - loadPathMetadata: (path: T.FS.Path) => void - loadSettings: () => void - loadTlfSyncConfig: (tlfPath: T.FS.Path) => void - loadUploadStatus: () => void - loadDownloadInfo: (downloadID: string) => void - loadDownloadStatus: () => void - loadedPathInfo: (path: T.FS.Path, info: T.FS.PathInfo) => void - newFolderRow: (parentPath: T.FS.Path) => void - moveOrCopy: (destinationParentPath: T.FS.Path, type: 'move' | 'copy') => void - onChangedFocus: (appFocused: boolean) => void - onEngineIncomingImpl: (action: EngineGen.Actions) => void - onPathChange: ( - clientID: string, - path: string, - topics: ReadonlyArray - ) => void - onSubscriptionNotify: (clientID: string, topic: T.RPCGen.SubscriptionTopic) => void - pollJournalStatus: () => void - redbar: (error: string) => void - resetState: () => void - setCriticalUpdate: (u: boolean) => void - setDebugLevel: (level: string) => void - setDestinationPickerParentPath: (index: number, path: T.FS.Path) => void - setDirectMountDir: (directMountDir: string) => void - setDriverStatus: (driverStatus: T.FS.DriverStatus) => void - setEditName: (editID: T.FS.EditID, name: string) => void - setFolderViewFilter: (filter?: string) => void - setIncomingShareSource: (source: ReadonlyArray) => void - setLastPublicBannerClosedTlf: (tlf: string) => void - setMoveOrCopySource: (path: T.FS.Path) => void - setPathItemActionMenuDownload: (downloadID?: string, intent?: T.FS.DownloadIntent) => void - setPathItemActionMenuView: (view: T.FS.PathItemActionMenuView) => void - setPreferredMountDirs: (preferredMountDirs: ReadonlyArray) => void - setPathSoftError: (path: T.FS.Path, softError?: T.FS.SoftError) => void - setSpaceAvailableNotificationThreshold: (spaceAvailableNotificationThreshold: number) => void - setTlfSoftError: (path: T.FS.Path, softError?: T.FS.SoftError) => void - setTlfsAsUnloaded: () => void - setTlfSyncConfig: (tlfPath: T.FS.Path, enabled: boolean) => void - setSorting: (path: T.FS.Path, sortSetting: T.FS.SortSetting) => void - setupSubscriptions: () => Promise - showIncomingShare: (initialDestinationParentPath: T.FS.Path) => void - showMoveOrCopy: (initialDestinationParentPath: T.FS.Path) => void - startManualConflictResolution: (tlfPath: T.FS.Path) => void - startRename: (path: T.FS.Path) => void - subscribeNonPath: (subscriptionID: string, topic: T.RPCGen.SubscriptionTopic) => void - subscribePath: (subscriptionID: string, path: T.FS.Path, topic: T.RPCGen.PathSubscriptionTopic) => void - syncStatusChanged: (status: T.RPCGen.FolderSyncStatus) => void - unsubscribe: (subscriptionID: string) => void - upload: (parentPath: T.FS.Path, localPath: string) => void - userIn: () => void - userOut: () => void - userFileEditsLoad: () => void - waitForKbfsDaemon: () => void - } - getUploadIconForFilesTab: () => T.FS.UploadIcon | undefined -} - -const getPrefetchStatusFromRPC = ( - prefetchStatus: T.RPCGen.PrefetchStatus, - prefetchProgress: T.RPCGen.PrefetchProgress -) => { - switch (prefetchStatus) { - case T.RPCGen.PrefetchStatus.notStarted: - return Util.prefetchNotStarted - case T.RPCGen.PrefetchStatus.inProgress: - return { - ...Util.emptyPrefetchInProgress, - bytesFetched: prefetchProgress.bytesFetched, - bytesTotal: prefetchProgress.bytesTotal, - endEstimate: prefetchProgress.endEstimate, - startTime: prefetchProgress.start, - } - case T.RPCGen.PrefetchStatus.complete: - return Util.prefetchComplete - default: - return Util.prefetchNotStarted - } -} - -const direntToMetadata = (d: T.RPCGen.Dirent) => ({ - lastModifiedTimestamp: d.time, - lastWriter: d.lastWriterUnverified.username, - name: d.name.split('/').pop(), - prefetchStatus: getPrefetchStatusFromRPC(d.prefetchStatus, d.prefetchProgress), - size: d.size, - writable: d.writable, -}) - -const makeEntry = (d: T.RPCGen.Dirent, children?: Set): T.FS.PathItem => { - switch (d.direntType) { - case T.RPCGen.DirentType.dir: - return { - ...Util.emptyFolder, - ...direntToMetadata(d), - children: new Set(children || []), - progress: children ? T.FS.ProgressType.Loaded : T.FS.ProgressType.Pending, - } as T.FS.PathItem - case T.RPCGen.DirentType.sym: - return { - ...Util.emptySymlink, - ...direntToMetadata(d), - // TODO: plumb link target - } as T.FS.PathItem - case T.RPCGen.DirentType.file: - case T.RPCGen.DirentType.exec: - return { - ...Util.emptyFile, - ...direntToMetadata(d), - } as T.FS.PathItem - } -} - -const updatePathItem = ( - oldPathItem: T.Immutable, - newPathItemFromAction: T.Immutable -): T.Immutable => { - if ( - oldPathItem.type === T.FS.PathType.Folder && - newPathItemFromAction.type === T.FS.PathType.Folder && - oldPathItem.progress === T.FS.ProgressType.Loaded && - newPathItemFromAction.progress === T.FS.ProgressType.Pending - ) { - // The new one doesn't have children, but the old one has. We don't - // want to override a loaded folder into pending. So first set the children - // in new one using what we already have, see if they are equal. - const newPathItemNoOverridingChildrenAndProgress = { - ...newPathItemFromAction, - children: oldPathItem.children, - progress: T.FS.ProgressType.Loaded, - } - return newPathItemNoOverridingChildrenAndProgress - } - return newPathItemFromAction -} - -export const useFSState = Z.createZustand((set, get) => { - // Can't rely on kbfsDaemonStatus.rpcStatus === 'waiting' as that's set by - // reducer and happens before this. - let waitForKbfsDaemonInProgress = false - - const getUploadIconForFilesTab = () => { - switch (get().badge) { - case T.RPCGen.FilesTabBadge.awaitingUpload: - return T.FS.UploadIcon.AwaitingToUpload - case T.RPCGen.FilesTabBadge.uploadingStuck: - return T.FS.UploadIcon.UploadingStuck - case T.RPCGen.FilesTabBadge.uploading: - return T.FS.UploadIcon.Uploading - case T.RPCGen.FilesTabBadge.none: - return undefined - } - } - - // At start-up we might have a race where we get connected to a kbfs daemon - // which dies soon after, and we get an EOF here. So retry for a few times - // until we get through. After each try we delay for 2s, so this should give us - // e.g. 12s when n == 6. If it still doesn't work after 12s, something's wrong - // and we deserve a black bar. - const checkIfWeReConnectedToMDServerUpToNTimes = async (n: number): Promise => { - try { - const onlineStatus = await T.RPCGen.SimpleFSSimpleFSGetOnlineStatusRpcPromise({clientID}) - get().dispatch.kbfsDaemonOnlineStatusChanged(onlineStatus) - return - } catch (error) { - if (n > 0) { - logger.warn(`failed to check if we are connected to MDServer: ${String(error)}; n=${n}`) - await timeoutPromise(2000) - return checkIfWeReConnectedToMDServerUpToNTimes(n - 1) - } else { - logger.warn(`failed to check if we are connected to MDServer : ${String(error)}; n=${n}, throwing`) - throw error - } - } - } - - let fsBadgeSubscriptionID: string = '' - let settingsSubscriptionID: string = '' - let uploadStatusSubscriptionID: string = '' - let journalStatusSubscriptionID: string = '' - let pollJournalStatusPolling = false - - const dispatch: State['dispatch'] = { - cancelDownload: downloadID => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSCancelDownloadRpcPromise({downloadID}) - } - ignorePromise(f()) - }, - checkKbfsDaemonRpcStatus: () => { - const f = async () => { - const connected = await T.RPCGen.configWaitForClientRpcPromise({ - clientType: T.RPCGen.ClientType.kbfs, - timeout: 0, // Don't wait; just check if it's there. - }) - const newStatus = connected ? T.FS.KbfsDaemonRpcStatus.Connected : T.FS.KbfsDaemonRpcStatus.Waiting - const kbfsDaemonStatus = get().kbfsDaemonStatus - const {kbfsDaemonRpcStatusChanged, waitForKbfsDaemon} = get().dispatch - - if (kbfsDaemonStatus.rpcStatus !== newStatus) { - kbfsDaemonRpcStatusChanged(newStatus) - } - if (newStatus === T.FS.KbfsDaemonRpcStatus.Waiting) { - waitForKbfsDaemon() - } - } - ignorePromise(f()) - }, - commitEdit: editID => { - const edit = get().edits.get(editID) - if (!edit) { - return - } - const f = async () => { - switch (edit.type) { - case T.FS.EditType.NewFolder: - try { - await T.RPCGen.SimpleFSSimpleFSOpenRpcPromise( - { - dest: Util.pathToRPCPath(T.FS.pathConcat(edit.parentPath, edit.name)), - flags: T.RPCGen.OpenFlags.directory, - opID: makeUUID(), - }, - S.waitingKeyFSCommitEdit - ) - get().dispatch.editSuccess(editID) - return - } catch (e) { - errorToActionOrThrow(e, edit.parentPath) - return - } - case T.FS.EditType.Rename: - try { - const opID = makeUUID() - await T.RPCGen.SimpleFSSimpleFSMoveRpcPromise({ - dest: Util.pathToRPCPath(T.FS.pathConcat(edit.parentPath, edit.name)), - opID, - overwriteExistingFiles: false, - src: Util.pathToRPCPath(T.FS.pathConcat(edit.parentPath, edit.originalName)), - }) - await T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}, S.waitingKeyFSCommitEdit) - get().dispatch.editSuccess(editID) - return - } catch (error) { - if (!(error instanceof RPCError)) { - return - } - if ( - [ - T.RPCGen.StatusCode.scsimplefsnameexists, - T.RPCGen.StatusCode.scsimplefsdirnotempty, - ].includes(error.code) - ) { - get().dispatch.editError(editID, error.desc || 'name exists') - return - } - throw error - } - } - } - ignorePromise(f()) - }, - deleteFile: path => { - const f = async () => { - const opID = makeUUID() - try { - await T.RPCGen.SimpleFSSimpleFSRemoveRpcPromise({ - opID, - path: Util.pathToRPCPath(path), - recursive: true, - }) - await T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}) - } catch (e) { - errorToActionOrThrow(e, path) - } - } - ignorePromise(f()) - }, - discardEdit: editID => { - set(s => { - s.edits.delete(editID) - }) - }, - dismissDownload: downloadID => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSDismissDownloadRpcPromise({downloadID}) - } - ignorePromise(f()) - }, - dismissRedbar: index => { - set(s => { - s.errors = [...s.errors.slice(0, index), ...s.errors.slice(index + 1)] - }) - }, - dismissUpload: uploadID => { - const f = async () => { - try { - await T.RPCGen.SimpleFSSimpleFSDismissUploadRpcPromise({uploadID}) - } catch {} - } - ignorePromise(f()) - }, - download: (path, type) => { - const f = async () => { - await requestPermissionsToWrite() - const downloadID = await T.RPCGen.SimpleFSSimpleFSStartDownloadRpcPromise({ - isRegularDownload: type === 'download', - path: Util.pathToRPCPath(path).kbfs, - }) - if (type !== 'download') { - get().dispatch.setPathItemActionMenuDownload( - downloadID, - type === 'share' ? T.FS.DownloadIntent.Share : T.FS.DownloadIntent.CameraRoll - ) - } - } - ignorePromise(f()) - }, - driverDisable: () => { - get().dispatch.dynamic.afterDriverDisable?.() - }, - driverDisabling: () => { - set(s => { - if (s.sfmi.driverStatus.type === T.FS.DriverStatusType.Enabled) { - s.sfmi.driverStatus.isDisabling = true - } - }) - get().dispatch.dynamic.afterDriverDisabling?.() - }, - driverEnable: isRetry => { - set(s => { - if (s.sfmi.driverStatus.type === T.FS.DriverStatusType.Disabled) { - s.sfmi.driverStatus.isEnabling = true - } - }) - get().dispatch.dynamic.afterDriverEnabled?.(!!isRetry) - }, - driverKextPermissionError: () => { - set(s => { - if (s.sfmi.driverStatus.type === T.FS.DriverStatusType.Disabled) { - s.sfmi.driverStatus.kextPermissionError = true - s.sfmi.driverStatus.isEnabling = false - } - }) - }, - dynamic: { - afterDriverDisable: undefined, - afterDriverDisabling: undefined, - afterDriverEnabled: undefined, - afterKbfsDaemonRpcStatusChanged: undefined, - finishedDownloadWithIntentMobile: undefined, - finishedRegularDownloadMobile: undefined, - openAndUploadDesktop: undefined, - openFilesFromWidgetDesktop: undefined, - openLocalPathInSystemFileManagerDesktop: undefined, - openPathInSystemFileManagerDesktop: undefined, - openSecurityPreferencesDesktop: undefined, - pickAndUploadMobile: undefined, - refreshDriverStatusDesktop: undefined, - refreshMountDirsDesktop: undefined, - setSfmiBannerDismissedDesktop: undefined, - uploadFromDragAndDropDesktop: undefined, - }, - editError: (editID, error) => { - set(s => { - const e = s.edits.get(editID) - if (e) e.error = error - }) - }, - editSuccess: editID => { - set(s => { - s.edits.delete(editID) - }) - }, - favoriteIgnore: path => { - const f = async () => { - const folder = Util.folderRPCFromPath(path) - if (!folder) { - throw new Error('No folder specified') - } - try { - await T.RPCGen.favoriteFavoriteIgnoreRpcPromise({folder}) - } catch (error) { - errorToActionOrThrow(error, path) - set(s => { - const elems = T.FS.getPathElements(path) - const visibility = T.FS.getVisibilityFromElems(elems) - if (!visibility) { - return - } - s.tlfs[visibility] = new Map(s.tlfs[visibility]) - s.tlfs[visibility].set( - elems[2] ?? '', - T.castDraft({ - ...(s.tlfs[visibility].get(elems[2] ?? '') || Util.unknownTlf), - isIgnored: false, - }) - ) - }) - } - } - set(s => { - const elems = T.FS.getPathElements(path) - const visibility = T.FS.getVisibilityFromElems(elems) - if (!visibility) { - return - } - s.tlfs[visibility] = new Map(s.tlfs[visibility]) - s.tlfs[visibility].set( - elems[2] ?? '', - T.castDraft({ - ...(s.tlfs[visibility].get(elems[2] ?? '') || Util.unknownTlf), - isIgnored: true, - }) - ) - }) - ignorePromise(f()) - }, - favoritesLoad: () => { - const f = async () => { - try { - if (!useConfigState.getState().loggedIn) { - return - } - const results = await T.RPCGen.SimpleFSSimpleFSListFavoritesRpcPromise() - const payload = { - private: new Map(), - public: new Map(), - team: new Map(), - } as const - const fs = [ - ...(results.favoriteFolders - ? [{folders: results.favoriteFolders, isFavorite: true, isIgnored: false, isNew: false}] - : []), - ...(results.ignoredFolders - ? [{folders: results.ignoredFolders, isFavorite: false, isIgnored: true, isNew: false}] - : []), - ...(results.newFolders - ? [{folders: results.newFolders, isFavorite: true, isIgnored: false, isNew: true}] - : []), - ] - fs.forEach(({folders, isFavorite, isIgnored, isNew}) => - folders.forEach(folder => { - const tlfType = Util.rpcFolderTypeToTlfType(folder.folderType) - const tlfName = - tlfType === T.FS.TlfType.Private || tlfType === T.FS.TlfType.Public - ? tlfToPreferredOrder(folder.name, useCurrentUserState.getState().username) - : folder.name - tlfType && - payload[tlfType].set( - tlfName, - Util.makeTlf({ - conflictState: Util.rpcConflictStateToConflictState(folder.conflictState || undefined), - isFavorite, - isIgnored, - isNew, - name: tlfName, - resetParticipants: (folder.reset_members || []).map(({username}) => username), - syncConfig: Util.getSyncConfigFromRPC(tlfName, tlfType, folder.syncConfig || undefined), - teamId: folder.team_id || '', - tlfMtime: folder.mtime || 0, - }) - ) - }) - ) - - if (payload.private.size) { - set(s => { - s.tlfs.private = T.castDraft(payload.private) - s.tlfs.public = T.castDraft(payload.public) - s.tlfs.team = T.castDraft(payload.team) - s.tlfs.loaded = true - }) - const counts = new Map() - counts.set(Tabs.fsTab, Util.computeBadgeNumberForAll(get().tlfs)) - storeRegistry.getState('notifications').dispatch.setBadgeCounts(counts) - } - } catch (e) { - errorToActionOrThrow(e) - } - return - } - ignorePromise(f()) - }, - finishManualConflictResolution: localViewTlfPath => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSFinishResolvingConflictRpcPromise({ - path: Util.pathToRPCPath(localViewTlfPath), - }) - get().dispatch.favoritesLoad() - } - ignorePromise(f()) - }, - folderListLoad: (rootPath, isRecursive) => { - const f = async () => { - try { - const opID = makeUUID() - if (isRecursive) { - await T.RPCGen.SimpleFSSimpleFSListRecursiveToDepthRpcPromise({ - depth: 1, - filter: T.RPCGen.ListFilter.filterSystemHidden, - opID, - path: Util.pathToRPCPath(rootPath), - refreshSubscription: false, - }) - } else { - await T.RPCGen.SimpleFSSimpleFSListRpcPromise({ - filter: T.RPCGen.ListFilter.filterSystemHidden, - opID, - path: Util.pathToRPCPath(rootPath), - refreshSubscription: false, - }) - } - - await T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}, S.waitingKeyFSFolderList) - - const result = await T.RPCGen.SimpleFSSimpleFSReadListRpcPromise({opID}) - const entries = result.entries || [] - const childMap = entries.reduce((m, d) => { - const [parent, child] = d.name.split('/') - if (child) { - // Only add to the children set if the parent definitely has children. - const fullParent = T.FS.pathConcat(rootPath, parent ?? '') - let children = m.get(fullParent) - if (!children) { - children = new Set() - m.set(fullParent, children) - } - children.add(child) - } else { - let children = m.get(rootPath) - if (!children) { - children = new Set() - m.set(rootPath, children) - } - children.add(d.name) - } - return m - }, new Map>()) - - const direntToPathAndPathItem = (d: T.RPCGen.Dirent) => { - const path = T.FS.pathConcat(rootPath, d.name) - const entry = makeEntry(d, childMap.get(path)) - if (entry.type === T.FS.PathType.Folder && isRecursive && !d.name.includes('/')) { - // Since we are loading with a depth of 2, first level directories are - // considered "loaded". - return [ - path, - { - ...entry, - progress: T.FS.ProgressType.Loaded, - }, - ] as const - } - return [path, entry] as const - } - - // Get metadata fields of the directory that we just loaded from state to - // avoid overriding them. - const rootPathItem = Util.getPathItem(get().pathItems, rootPath) - const rootFolder: T.FS.FolderPathItem = { - ...(rootPathItem.type === T.FS.PathType.Folder - ? rootPathItem - : {...Util.emptyFolder, name: T.FS.getPathName(rootPath)}), - children: new Set(childMap.get(rootPath)), - progress: T.FS.ProgressType.Loaded, - } - - const pathItems = new Map([ - ...(T.FS.getPathLevel(rootPath) > 2 ? [[rootPath, rootFolder] as const] : []), - ...entries.map(direntToPathAndPathItem), - ] as const) - set(s => { - pathItems.forEach((pathItemFromAction, path) => { - const oldPathItem = Util.getPathItem(s.pathItems, path) - const newPathItem = updatePathItem(oldPathItem, pathItemFromAction) - oldPathItem.type === T.FS.PathType.Folder && - oldPathItem.children.forEach( - name => - (newPathItem.type !== T.FS.PathType.Folder || !newPathItem.children.has(name)) && - s.pathItems.delete(T.FS.pathConcat(path, name)) - ) - s.pathItems.set(path, T.castDraft(newPathItem)) - }) - - // Remove Rename edits that are for path items that don't exist anymore in - // case when/if a new item is added later the edit causes confusion. - const newEntries = [...s.edits.entries()].filter(([_, edit]) => { - if (edit.type !== T.FS.EditType.Rename) { - return true - } - const parent = Util.getPathItem(s.pathItems, edit.parentPath) - if (parent.type === T.FS.PathType.Folder && parent.children.has(edit.name)) { - return true - } - return false - }) - if (newEntries.length !== s.edits.size) { - s.edits = new Map(newEntries) - } - }) - } catch (error) { - errorToActionOrThrow(error, rootPath) - return - } - } - ignorePromise(f()) - }, - getOnlineStatus: () => { - const f = async () => { - await checkIfWeReConnectedToMDServerUpToNTimes(2) - } - ignorePromise(f()) - }, - journalUpdate: (syncingPaths, totalSyncingBytes, endEstimate) => { - set(s => { - const sp = new Set(syncingPaths) - if (!isEqual(sp, s.uploads.syncingPaths)) { - s.uploads.syncingPaths = sp - } - s.uploads.totalSyncingBytes = totalSyncingBytes - s.uploads.endEstimate = endEstimate - }) - }, - kbfsDaemonOnlineStatusChanged: onlineStatus => { - set(s => { - s.kbfsDaemonStatus.onlineStatus = - onlineStatus === T.RPCGen.KbfsOnlineStatus.offline - ? T.FS.KbfsDaemonOnlineStatus.Offline - : onlineStatus === T.RPCGen.KbfsOnlineStatus.trying - ? T.FS.KbfsDaemonOnlineStatus.Trying - : // eslint-disable-next-line - onlineStatus === T.RPCGen.KbfsOnlineStatus.online - ? T.FS.KbfsDaemonOnlineStatus.Online - : T.FS.KbfsDaemonOnlineStatus.Unknown - }) - }, - kbfsDaemonRpcStatusChanged: rpcStatus => { - set(s => { - if (rpcStatus !== T.FS.KbfsDaemonRpcStatus.Connected) { - s.kbfsDaemonStatus.onlineStatus = T.FS.KbfsDaemonOnlineStatus.Offline - } - s.kbfsDaemonStatus.rpcStatus = rpcStatus - }) - - const kbfsDaemonStatus = get().kbfsDaemonStatus - if (kbfsDaemonStatus.rpcStatus !== T.FS.KbfsDaemonRpcStatus.Connected) { - get().dispatch.setTlfsAsUnloaded() - } - - const subscribeAndLoadFsBadge = () => { - const oldFsBadgeSubscriptionID = fsBadgeSubscriptionID - fsBadgeSubscriptionID = makeUUID() - const kbfsDaemonStatus = get().kbfsDaemonStatus - if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { - if (oldFsBadgeSubscriptionID) { - get().dispatch.unsubscribe(oldFsBadgeSubscriptionID) - } - get().dispatch.subscribeNonPath(fsBadgeSubscriptionID, T.RPCGen.SubscriptionTopic.filesTabBadge) - get().dispatch.loadFilesTabBadge() - } - } - - subscribeAndLoadFsBadge() - - const subscribeAndLoadSettings = () => { - const oldSettingsSubscriptionID = settingsSubscriptionID - settingsSubscriptionID = makeUUID() - const kbfsDaemonStatus = get().kbfsDaemonStatus - if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { - get().dispatch.loadSettings() - } - - if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { - if (oldSettingsSubscriptionID) { - get().dispatch.unsubscribe(oldSettingsSubscriptionID) - } - get().dispatch.subscribeNonPath(settingsSubscriptionID, T.RPCGen.SubscriptionTopic.settings) - } - } - subscribeAndLoadSettings() - - const subscribeAndLoadUploadStatus = () => { - const oldUploadStatusSubscriptionID = uploadStatusSubscriptionID - uploadStatusSubscriptionID = makeUUID() - const kbfsDaemonStatus = get().kbfsDaemonStatus - - if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { - get().dispatch.loadUploadStatus() - } - - if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { - if (oldUploadStatusSubscriptionID) { - get().dispatch.unsubscribe(oldUploadStatusSubscriptionID) - } - - get().dispatch.subscribeNonPath(uploadStatusSubscriptionID, T.RPCGen.SubscriptionTopic.uploadStatus) - } - } - subscribeAndLoadUploadStatus() - - const subscribeAndLoadJournalStatus = () => { - const oldJournalStatusSubscriptionID = journalStatusSubscriptionID - journalStatusSubscriptionID = makeUUID() - const kbfsDaemonStatus = get().kbfsDaemonStatus - if (kbfsDaemonStatus.rpcStatus === T.FS.KbfsDaemonRpcStatus.Connected) { - if (oldJournalStatusSubscriptionID) { - get().dispatch.unsubscribe(oldJournalStatusSubscriptionID) - } - get().dispatch.subscribeNonPath( - journalStatusSubscriptionID, - T.RPCGen.SubscriptionTopic.journalStatus - ) - get().dispatch.pollJournalStatus() - } - } - subscribeAndLoadJournalStatus() - // how this works isn't great. This function gets called way early before we set this - get().dispatch.dynamic.afterKbfsDaemonRpcStatusChanged?.() - }, - letResetUserBackIn: (id, username) => { - const f = async () => { - try { - await T.RPCGen.teamsTeamReAddMemberAfterResetRpcPromise({id, username}) - } catch (error) { - errorToActionOrThrow(error) - } - } - ignorePromise(f()) - }, - loadAdditionalTlf: tlfPath => { - const f = async () => { - if (T.FS.getPathLevel(tlfPath) !== 3) { - logger.warn('loadAdditionalTlf called on non-TLF path') - return - } - try { - const {folder, isFavorite, isIgnored, isNew} = await T.RPCGen.SimpleFSSimpleFSGetFolderRpcPromise({ - path: Util.pathToRPCPath(tlfPath).kbfs, - }) - const tlfType = Util.rpcFolderTypeToTlfType(folder.folderType) - const tlfName = - tlfType === T.FS.TlfType.Private || tlfType === T.FS.TlfType.Public - ? tlfToPreferredOrder(folder.name, useCurrentUserState.getState().username) - : folder.name - - if (tlfType) { - set(s => { - s.tlfs.additionalTlfs.set( - tlfPath, - T.castDraft( - Util.makeTlf({ - conflictState: Util.rpcConflictStateToConflictState(folder.conflictState || undefined), - isFavorite, - isIgnored, - isNew, - name: tlfName, - resetParticipants: (folder.reset_members || []).map(({username}) => username), - syncConfig: Util.getSyncConfigFromRPC(tlfName, tlfType, folder.syncConfig || undefined), - teamId: folder.team_id || '', - tlfMtime: folder.mtime || 0, - }) - ) - ) - }) - } - } catch (error) { - if (!(error instanceof RPCError)) { - return - } - if (error.code === T.RPCGen.StatusCode.scteamcontactsettingsblock) { - const fields = error.fields as undefined | Array<{key?: string; value?: string}> - const users = fields?.filter(elem => elem.key === 'usernames') - const usernames = users?.map(elem => elem.value ?? '') ?? [] - // Don't leave the user on a broken FS dir screen. - navigateUp() - navigateAppend({ - props: {source: 'newFolder', usernames}, - selected: 'contactRestricted', - }) - } - errorToActionOrThrow(error, tlfPath) - } - } - ignorePromise(f()) - }, - loadDownloadInfo: downloadID => { - const f = async () => { - try { - const res = await T.RPCGen.SimpleFSSimpleFSGetDownloadInfoRpcPromise({ - downloadID, - }) - set(s => { - s.downloads.info.set(downloadID, { - filename: res.filename, - isRegularDownload: res.isRegularDownload, - path: T.FS.stringToPath('/keybase' + res.path.path), - startTime: res.startTime, - }) - }) - } catch (error) { - errorToActionOrThrow(error) - } - } - ignorePromise(f()) - }, - loadDownloadStatus: () => { - const f = async () => { - try { - const res = await T.RPCGen.SimpleFSSimpleFSGetDownloadStatusRpcPromise() - - const regularDownloads = res.regularDownloadIDs || [] - const state = new Map( - (res.states || []).map(s => [ - s.downloadID, - { - canceled: s.canceled, - done: s.done, - endEstimate: s.endEstimate, - error: s.error, - localPath: s.localPath, - progress: s.progress, - }, - ]) - ) - - set(s => { - s.downloads.regularDownloads = T.castDraft(regularDownloads) - s.downloads.state = state - - const toDelete = [...s.downloads.info.keys()].filter(downloadID => !state.has(downloadID)) - if (toDelete.length) { - toDelete.forEach(downloadID => s.downloads.info.delete(downloadID)) - } - }) - } catch (error) { - errorToActionOrThrow(error) - } - } - ignorePromise(f()) - }, - loadFileContext: path => { - const f = async () => { - try { - const res = await T.RPCGen.SimpleFSSimpleFSGetGUIFileContextRpcPromise({ - path: Util.pathToRPCPath(path).kbfs, - }) - - set(s => { - s.fileContext.set(path, { - contentType: res.contentType, - url: res.url, - viewType: res.viewType, - }) - }) - } catch (err) { - errorToActionOrThrow(err) - return - } - } - ignorePromise(f()) - }, - loadFilesTabBadge: () => { - const f = async () => { - try { - const badge = await T.RPCGen.SimpleFSSimpleFSGetFilesTabBadgeRpcPromise() - set(s => { - s.badge = badge - }) - } catch { - // retry once HOTPOT-1226 - try { - const badge = await T.RPCGen.SimpleFSSimpleFSGetFilesTabBadgeRpcPromise() - set(s => { - s.badge = badge - }) - } catch {} - } - } - ignorePromise(f()) - }, - loadPathInfo: path => { - const f = async () => { - const pathInfo = await T.RPCGen.kbfsMountGetKBFSPathInfoRpcPromise({ - standardPath: T.FS.pathToString(path), - }) - get().dispatch.loadedPathInfo(path, { - deeplinkPath: pathInfo.deeplinkPath, - platformAfterMountPath: pathInfo.platformAfterMountPath, - }) - } - ignorePromise(f()) - }, - loadPathMetadata: path => { - const f = async () => { - try { - const dirent = await T.RPCGen.SimpleFSSimpleFSStatRpcPromise( - { - path: Util.pathToRPCPath(path), - refreshSubscription: false, - }, - S.waitingKeyFSStat - ) - - const pathItem = makeEntry(dirent) - set(s => { - const oldPathItem = Util.getPathItem(s.pathItems, path) - s.pathItems.set(path, T.castDraft(updatePathItem(oldPathItem, pathItem))) - s.softErrors.pathErrors.delete(path) - s.softErrors.tlfErrors.delete(path) - }) - } catch (err) { - errorToActionOrThrow(err, path) - return - } - } - ignorePromise(f()) - }, - loadSettings: () => { - const f = async () => { - set(s => { - s.settings.isLoading = true - }) - try { - const settings = await T.RPCGen.SimpleFSSimpleFSSettingsRpcPromise() - set(s => { - const o = s.settings - o.isLoading = false - o.loaded = true - o.sfmiBannerDismissed = settings.sfmiBannerDismissed - o.spaceAvailableNotificationThreshold = settings.spaceAvailableNotificationThreshold - o.syncOnCellular = settings.syncOnCellular - }) - } catch { - set(s => { - s.settings.isLoading = false - }) - } - } - ignorePromise(f()) - }, - loadTlfSyncConfig: tlfPath => { - const f = async () => { - const parsedPath = Util.parsePath(tlfPath) - if (parsedPath.kind !== T.FS.PathKind.GroupTlf && parsedPath.kind !== T.FS.PathKind.TeamTlf) { - return - } - try { - const result = await T.RPCGen.SimpleFSSimpleFSFolderSyncConfigAndStatusRpcPromise({ - path: Util.pathToRPCPath(tlfPath), - }) - const syncConfig = Util.getSyncConfigFromRPC(parsedPath.tlfName, parsedPath.tlfType, result.config) - const tlfName = parsedPath.tlfName - const tlfType = parsedPath.tlfType - - set(s => { - const oldTlfList = s.tlfs[tlfType] - const oldTlfFromFavorites = oldTlfList.get(tlfName) || Util.unknownTlf - if (oldTlfFromFavorites !== Util.unknownTlf) { - s.tlfs[tlfType] = T.castDraft( - new Map([...oldTlfList, [tlfName, {...oldTlfFromFavorites, syncConfig}]]) - ) - return - } - - const tlfPath = T.FS.pathConcat(T.FS.pathConcat(Util.defaultPath, tlfType), tlfName) - const oldTlfFromAdditional = s.tlfs.additionalTlfs.get(tlfPath) || Util.unknownTlf - if (oldTlfFromAdditional !== Util.unknownTlf) { - s.tlfs.additionalTlfs = T.castDraft( - new Map([...s.tlfs.additionalTlfs, [tlfPath, {...oldTlfFromAdditional, syncConfig}]]) - ) - return - } - }) - } catch (e) { - errorToActionOrThrow(e, tlfPath) - return - } - } - ignorePromise(f()) - }, - loadUploadStatus: () => { - const f = async () => { - try { - const uploadStates = await T.RPCGen.SimpleFSSimpleFSGetUploadStatusRpcPromise() - set(s => { - // return FsGen.createLoadedUploadStatus({uploadStates: uploadStates || []}) - - const writingToJournal = new Map( - uploadStates?.map(uploadState => { - const path = Util.rpcPathToPath(uploadState.targetPath) - const oldUploadState = s.uploads.writingToJournal.get(path) - return [ - path, - oldUploadState && - uploadState.error === oldUploadState.error && - uploadState.canceled === oldUploadState.canceled && - uploadState.uploadID === oldUploadState.uploadID - ? oldUploadState - : uploadState, - ] - }) - ) - if (!isEqual(writingToJournal, s.uploads.writingToJournal)) { - s.uploads.writingToJournal = writingToJournal - } - }) - } catch (err) { - errorToActionOrThrow(err) - } - } - ignorePromise(f()) - }, - loadedPathInfo: (path, info) => { - set(s => { - s.pathInfos.set(path, info) - }) - }, - moveOrCopy: (destinationParentPath: T.FS.Path, type: 'move' | 'copy') => { - const f = async () => { - const zState = get() - if (zState.destinationPicker.source.type === T.FS.DestinationPickerSource.None) { - return - } - - const params = - zState.destinationPicker.source.type === T.FS.DestinationPickerSource.MoveOrCopy - ? [ - { - dest: Util.pathToRPCPath( - T.FS.pathConcat( - destinationParentPath, - T.FS.getPathName(zState.destinationPicker.source.path) - ) - ), - opID: makeUUID(), - overwriteExistingFiles: false, - src: Util.pathToRPCPath(zState.destinationPicker.source.path), - }, - ] - : zState.destinationPicker.source.source - .map(item => ({originalPath: item.originalPath ?? '', scaledPath: item.scaledPath})) - .filter(({originalPath}) => !!originalPath) - .map(({originalPath, scaledPath}) => ({ - dest: Util.pathToRPCPath( - T.FS.pathConcat( - destinationParentPath, - T.FS.getLocalPathName(originalPath) - // We use the local path name here since we only care about file name. - ) - ), - opID: makeUUID(), - overwriteExistingFiles: false, - src: { - PathType: T.RPCGen.PathType.local, - local: T.FS.getNormalizedLocalPath( - useConfigState.getState().incomingShareUseOriginal - ? originalPath - : scaledPath || originalPath - ), - } as T.RPCGen.Path, - })) - - try { - const rpc = - type === 'move' - ? T.RPCGen.SimpleFSSimpleFSMoveRpcPromise - : T.RPCGen.SimpleFSSimpleFSCopyRecursiveRpcPromise - await Promise.all(params.map(async p => rpc(p))) - await Promise.all(params.map(async ({opID}) => T.RPCGen.SimpleFSSimpleFSWaitRpcPromise({opID}))) - // We get source/dest paths from state rather than action, so we can't - // just retry it. If we do want retry in the future we can include those - // paths in the action. - } catch (e) { - errorToActionOrThrow(e, destinationParentPath) - return - } - } - ignorePromise(f()) - }, - newFolderRow: parentPath => { - const parentPathItem = Util.getPathItem(get().pathItems, parentPath) - if (parentPathItem.type !== T.FS.PathType.Folder) { - console.warn(`bad parentPath: ${parentPathItem.type}`) - return - } - - const existingNewFolderNames = new Set([...get().edits.values()].map(({name}) => name)) - - let newFolderName = 'New Folder' - let i = 2 - while (parentPathItem.children.has(newFolderName) || existingNewFolderNames.has(newFolderName)) { - newFolderName = `New Folder ${i}` - ++i - } - - set(s => { - s.edits.set(makeEditID(), { - ...Util.emptyNewFolder, - name: newFolderName, - originalName: newFolderName, - parentPath, - }) - }) - }, - onChangedFocus: appFocused => { - const driverStatus = get().sfmi.driverStatus - if ( - appFocused && - driverStatus.type === T.FS.DriverStatusType.Disabled && - driverStatus.kextPermissionError - ) { - get().dispatch.driverEnable(true) - } - }, - onEngineIncomingImpl: action => { - switch (action.type) { - case EngineGen.keybase1NotifyFSFSOverallSyncStatusChanged: - get().dispatch.syncStatusChanged(action.payload.params.status) - break - case EngineGen.keybase1NotifyFSFSSubscriptionNotifyPath: { - const {clientID, path, topics} = action.payload.params - get().dispatch.onPathChange(clientID, path, topics ?? []) - break - } - case EngineGen.keybase1NotifyFSFSSubscriptionNotify: { - const {clientID, topic} = action.payload.params - get().dispatch.onSubscriptionNotify(clientID, topic) - break - } - default: - } - }, - onPathChange: (cid, path, topics) => { - if (cid !== clientID) { - return - } - - const {folderListLoad} = useFSState.getState().dispatch - topics.forEach(topic => { - switch (topic) { - case T.RPCGen.PathSubscriptionTopic.children: - folderListLoad(T.FS.stringToPath(path), false) - break - case T.RPCGen.PathSubscriptionTopic.stat: - get().dispatch.loadPathMetadata(T.FS.stringToPath(path)) - break - } - }) - }, - onSubscriptionNotify: (cid, topic) => { - const f = async () => { - if (cid !== clientID) { - return - } - switch (topic) { - case T.RPCGen.SubscriptionTopic.favorites: - get().dispatch.favoritesLoad() - break - case T.RPCGen.SubscriptionTopic.journalStatus: - get().dispatch.pollJournalStatus() - break - case T.RPCGen.SubscriptionTopic.onlineStatus: - await checkIfWeReConnectedToMDServerUpToNTimes(1) - break - case T.RPCGen.SubscriptionTopic.downloadStatus: - get().dispatch.loadDownloadStatus() - break - case T.RPCGen.SubscriptionTopic.uploadStatus: - get().dispatch.loadUploadStatus() - break - case T.RPCGen.SubscriptionTopic.filesTabBadge: - get().dispatch.loadFilesTabBadge() - break - case T.RPCGen.SubscriptionTopic.settings: - get().dispatch.loadSettings() - break - case T.RPCGen.SubscriptionTopic.overallSyncStatus: - break - } - } - ignorePromise(f()) - }, - pollJournalStatus: () => { - if (pollJournalStatusPolling) { - return - } - pollJournalStatusPolling = true - - const getWaitDuration = (endEstimate: number | undefined, lower: number, upper: number): number => { - if (!endEstimate) { - return upper - } - const diff = endEstimate - Date.now() - return diff < lower ? lower : diff > upper ? upper : diff - } - - const f = async () => { - try { - while (true) { - const {syncingPaths, totalSyncingBytes, endEstimate} = - await T.RPCGen.SimpleFSSimpleFSSyncStatusRpcPromise({ - filter: T.RPCGen.ListFilter.filterSystemHidden, - }) - get().dispatch.journalUpdate( - (syncingPaths || []).map(T.FS.stringToPath), - totalSyncingBytes, - endEstimate ?? undefined - ) - - // It's possible syncingPaths has not been emptied before - // totalSyncingBytes becomes 0. So check both. - if (totalSyncingBytes <= 0 && !syncingPaths?.length) { - break - } - storeRegistry.getState('notifications').dispatch.badgeApp('kbfsUploading', true) - await timeoutPromise(getWaitDuration(endEstimate || undefined, 100, 4000)) // 0.1s to 4s - } - } finally { - pollJournalStatusPolling = false - storeRegistry.getState('notifications').dispatch.badgeApp('kbfsUploading', false) - get().dispatch.checkKbfsDaemonRpcStatus() - } - } - ignorePromise(f()) - }, - redbar: error => { - set(s => { - s.errors.push(error) - }) - }, - resetState: () => { - set(s => ({ - ...s, - ...initialStore, - dispatch: s.dispatch, - })) - }, - setCriticalUpdate: u => { - set(s => { - s.criticalUpdate = u - }) - }, - setDebugLevel: level => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSSetDebugLevelRpcPromise({level}) - } - ignorePromise(f()) - }, - setDestinationPickerParentPath: (index, path) => { - set(s => { - s.destinationPicker.destinationParentPath[index] = path - }) - }, - setDirectMountDir: directMountDir => { - set(s => { - s.sfmi.directMountDir = directMountDir - }) - }, - setDriverStatus: driverStatus => { - set(s => { - s.sfmi.driverStatus = driverStatus - }) - get().dispatch.dynamic.refreshMountDirsDesktop?.() - }, - setEditName: (editID, name) => { - set(s => { - const e = s.edits.get(editID) - if (e) { - e.name = name - } - }) - }, - setFolderViewFilter: filter => { - set(s => { - s.folderViewFilter = filter - }) - }, - setIncomingShareSource: source => { - set(s => { - s.destinationPicker.source = { - source: T.castDraft(source), - type: T.FS.DestinationPickerSource.IncomingShare, - } - }) - }, - setLastPublicBannerClosedTlf: tlf => { - set(s => { - s.lastPublicBannerClosedTlf = tlf - }) - }, - setMoveOrCopySource: path => { - set(s => { - s.destinationPicker.source = {path, type: T.FS.DestinationPickerSource.MoveOrCopy} - }) - }, - setPathItemActionMenuDownload: (downloadID, intent) => { - set(s => { - s.pathItemActionMenu.downloadID = downloadID - s.pathItemActionMenu.downloadIntent = intent - }) - }, - setPathItemActionMenuView: view => { - set(s => { - s.pathItemActionMenu.previousView = s.pathItemActionMenu.view - s.pathItemActionMenu.view = view - }) - }, - setPathSoftError: (path, softError) => { - set(s => { - if (softError) { - s.softErrors.pathErrors.set(path, softError) - } else { - s.softErrors.pathErrors.delete(path) - } - }) - }, - setPreferredMountDirs: preferredMountDirs => { - set(s => { - s.sfmi.preferredMountDirs = T.castDraft(preferredMountDirs) - }) - }, - setSorting: (path, sortSetting) => { - set(s => { - const old = s.pathUserSettings.get(path) - if (old) { - old.sort = sortSetting - } else { - s.pathUserSettings.set(path, {...Util.defaultPathUserSetting, sort: sortSetting}) - } - }) - }, - setSpaceAvailableNotificationThreshold: threshold => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSSetNotificationThresholdRpcPromise({ - threshold, - }) - get().dispatch.loadSettings() - } - ignorePromise(f()) - }, - setTlfSoftError: (path, softError) => { - set(s => { - if (softError) { - s.softErrors.tlfErrors.set(path, softError) - } else { - s.softErrors.tlfErrors.delete(path) - } - }) - }, - setTlfSyncConfig: (tlfPath, enabled) => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSSetFolderSyncConfigRpcPromise( - { - config: {mode: enabled ? T.RPCGen.FolderSyncMode.enabled : T.RPCGen.FolderSyncMode.disabled}, - path: Util.pathToRPCPath(tlfPath), - }, - S.waitingKeyFSSyncToggle - ) - get().dispatch.loadTlfSyncConfig(tlfPath) - } - ignorePromise(f()) - }, - setTlfsAsUnloaded: () => { - set(s => { - s.tlfs.loaded = false - }) - }, - setupSubscriptions: async () => { - const initPlatformSpecific = await import('./platform-specific') - initPlatformSpecific.default() - }, - showIncomingShare: initialDestinationParentPath => { - set(s => { - if (s.destinationPicker.source.type !== T.FS.DestinationPickerSource.IncomingShare) { - s.destinationPicker.source = {source: [], type: T.FS.DestinationPickerSource.IncomingShare} - } - s.destinationPicker.destinationParentPath = [initialDestinationParentPath] - }) - navigateAppend({props: {index: 0}, selected: 'destinationPicker'}) - }, - showMoveOrCopy: initialDestinationParentPath => { - set(s => { - s.destinationPicker.source = - s.destinationPicker.source.type === T.FS.DestinationPickerSource.MoveOrCopy - ? s.destinationPicker.source - : { - path: Util.defaultPath, - type: T.FS.DestinationPickerSource.MoveOrCopy, - } - - s.destinationPicker.destinationParentPath = [initialDestinationParentPath] - }) - - navigateAppend({props: {index: 0}, selected: 'destinationPicker'}) - }, - startManualConflictResolution: tlfPath => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSClearConflictStateRpcPromise({ - path: Util.pathToRPCPath(tlfPath), - }) - get().dispatch.favoritesLoad() - } - ignorePromise(f()) - }, - startRename: path => { - const parentPath = T.FS.getPathParent(path) - const originalName = T.FS.getPathName(path) - set(s => { - s.edits.set(makeEditID(), { - name: originalName, - originalName, - parentPath, - type: T.FS.EditType.Rename, - }) - }) - }, - subscribeNonPath: (subscriptionID, topic) => { - const f = async () => { - try { - await T.RPCGen.SimpleFSSimpleFSSubscribeNonPathRpcPromise({ - clientID, - deduplicateIntervalSecond: subscriptionDeduplicateIntervalSecond, - identifyBehavior: T.RPCGen.TLFIdentifyBehavior.fsGui, - subscriptionID, - topic, - }) - } catch (err) { - errorToActionOrThrow(err) - } - } - ignorePromise(f()) - }, - subscribePath: (subscriptionID, path, topic) => { - const f = async () => { - try { - await T.RPCGen.SimpleFSSimpleFSSubscribePathRpcPromise({ - clientID, - deduplicateIntervalSecond: subscriptionDeduplicateIntervalSecond, - identifyBehavior: T.RPCGen.TLFIdentifyBehavior.fsGui, - kbfsPath: T.FS.pathToString(path), - subscriptionID, - topic, - }) - } catch (error) { - if (!(error instanceof RPCError)) { - return - } - if (error.code !== T.RPCGen.StatusCode.scteamcontactsettingsblock) { - // We'll handle this error in loadAdditionalTLF instead. - errorToActionOrThrow(error, path) - } - } - } - ignorePromise(f()) - }, - syncStatusChanged: status => { - const diskSpaceStatus = status.outOfSyncSpace - ? T.FS.DiskSpaceStatus.Error - : status.localDiskBytesAvailable < get().settings.spaceAvailableNotificationThreshold - ? T.FS.DiskSpaceStatus.Warning - : T.FS.DiskSpaceStatus.Ok - - const oldStatus = get().overallSyncStatus.diskSpaceStatus - set(s => { - s.overallSyncStatus.syncingFoldersProgress = status.prefetchProgress - s.overallSyncStatus.diskSpaceStatus = diskSpaceStatus - }) - - // Only notify about the disk space status if it has changed. - if (oldStatus !== diskSpaceStatus) { - switch (diskSpaceStatus) { - case T.FS.DiskSpaceStatus.Error: { - NotifyPopup('Sync Error', { - body: 'You are out of disk space. Some folders could not be synced.', - sound: true, - }) - storeRegistry.getState('notifications').dispatch.badgeApp('outOfSpace', status.outOfSyncSpace) - break - } - case T.FS.DiskSpaceStatus.Warning: - { - const threshold = Util.humanizeBytes(get().settings.spaceAvailableNotificationThreshold, 0) - NotifyPopup('Disk Space Low', { - body: `You have less than ${threshold} of storage space left.`, - }) - // Only show the banner if the previous state was OK and the new state - // is warning. Otherwise we rely on the previous state of the banner. - if (oldStatus === T.FS.DiskSpaceStatus.Ok) { - set(s => { - s.overallSyncStatus.showingBanner = true - }) - } - } - break - case T.FS.DiskSpaceStatus.Ok: - break - default: - } - } - }, - unsubscribe: subscriptionID => { - const f = async () => { - try { - await T.RPCGen.SimpleFSSimpleFSUnsubscribeRpcPromise({ - clientID, - identifyBehavior: T.RPCGen.TLFIdentifyBehavior.fsGui, - subscriptionID, - }) - } catch {} - } - ignorePromise(f()) - }, - upload: (parentPath, localPath) => { - const f = async () => { - try { - await T.RPCGen.SimpleFSSimpleFSStartUploadRpcPromise({ - sourceLocalPath: T.FS.getNormalizedLocalPath(localPath), - targetParentPath: Util.pathToRPCPath(parentPath).kbfs, - }) - } catch (err) { - errorToActionOrThrow(err) - } - } - ignorePromise(f()) - }, - userFileEditsLoad: () => { - const f = async () => { - try { - const writerEdits = await T.RPCGen.SimpleFSSimpleFSUserEditHistoryRpcPromise() - set(s => { - s.tlfUpdates = T.castDraft(Util.userTlfHistoryRPCToState(writerEdits || [])) - }) - } catch (error) { - errorToActionOrThrow(error) - } - } - ignorePromise(f()) - }, - userIn: () => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSUserInRpcPromise({clientID}) - } - ignorePromise(f()) - get().dispatch.checkKbfsDaemonRpcStatus() - }, - userOut: () => { - const f = async () => { - await T.RPCGen.SimpleFSSimpleFSUserOutRpcPromise({clientID}) - } - ignorePromise(f()) - }, - waitForKbfsDaemon: () => { - if (waitForKbfsDaemonInProgress) { - return - } - waitForKbfsDaemonInProgress = true - set(s => { - s.kbfsDaemonStatus.rpcStatus = T.FS.KbfsDaemonRpcStatus.Waiting - }) - const f = async () => { - try { - await T.RPCGen.configWaitForClientRpcPromise({ - clientType: T.RPCGen.ClientType.kbfs, - timeout: 60, // 1min. This is arbitrary since we're gonna check again anyway if we're not connected. - }) - } catch {} - - waitForKbfsDaemonInProgress = false - get().dispatch.checkKbfsDaemonRpcStatus() - } - ignorePromise(f()) - }, - } - - return { - ...initialStore, - dispatch, - getUploadIconForFilesTab, - } -}) diff --git a/shared/constants/fs/platform-specific.android.tsx b/shared/constants/fs/platform-specific.android.tsx index 37db57525572..a31524a9b47e 100644 --- a/shared/constants/fs/platform-specific.android.tsx +++ b/shared/constants/fs/platform-specific.android.tsx @@ -3,7 +3,7 @@ import {ignorePromise, wrapErrors} from '../utils' import * as FS from '@/stores/fs' import logger from '@/logger' import nativeInit from './common.native' -import {useFSState} from '.' +import {useFSState} from '@/stores/fs' import {androidAddCompleteDownload, fsCacheDir, fsDownloadDir} from 'react-native-kb' const finishedRegularDownloadIDs = new Set() @@ -26,43 +26,41 @@ export default function initPlatformSpecific() { // needs to be called, TODO could make this better s.dispatch.dynamic.afterKbfsDaemonRpcStatusChanged() - s.dispatch.dynamic.finishedRegularDownloadMobile = wrapErrors( - (downloadID: string, mimeType: string) => { - const f = async () => { - // This is fired from a hook and can happen more than once per downloadID. - // So just deduplicate them here. This is small enough and won't happen - // constantly, so don't worry about clearing them. - if (finishedRegularDownloadIDs.has(downloadID)) { - return - } - finishedRegularDownloadIDs.add(downloadID) + s.dispatch.dynamic.finishedRegularDownloadMobile = wrapErrors((downloadID: string, mimeType: string) => { + const f = async () => { + // This is fired from a hook and can happen more than once per downloadID. + // So just deduplicate them here. This is small enough and won't happen + // constantly, so don't worry about clearing them. + if (finishedRegularDownloadIDs.has(downloadID)) { + return + } + finishedRegularDownloadIDs.add(downloadID) - const {downloads} = useFSState.getState() + const {downloads} = useFSState.getState() - const downloadState = downloads.state.get(downloadID) || FS.emptyDownloadState - const downloadInfo = downloads.info.get(downloadID) || FS.emptyDownloadInfo - if (downloadState === FS.emptyDownloadState || downloadInfo === FS.emptyDownloadInfo) { - logger.warn('missing download', downloadID) - return - } - if (downloadState.error) { - return - } - try { - await androidAddCompleteDownload({ - description: `Keybase downloaded ${downloadInfo.filename}`, - mime: mimeType, - path: downloadState.localPath, - showNotification: true, - title: downloadInfo.filename, - }) - } catch { - logger.warn('Failed to addCompleteDownload') - } - // No need to dismiss here as the download wrapper does it for Android. + const downloadState = downloads.state.get(downloadID) || FS.emptyDownloadState + const downloadInfo = downloads.info.get(downloadID) || FS.emptyDownloadInfo + if (downloadState === FS.emptyDownloadState || downloadInfo === FS.emptyDownloadInfo) { + logger.warn('missing download', downloadID) + return + } + if (downloadState.error) { + return } - ignorePromise(f()) + try { + await androidAddCompleteDownload({ + description: `Keybase downloaded ${downloadInfo.filename}`, + mime: mimeType, + path: downloadState.localPath, + showNotification: true, + title: downloadInfo.filename, + }) + } catch { + logger.warn('Failed to addCompleteDownload') + } + // No need to dismiss here as the download wrapper does it for Android. } - ) + ignorePromise(f()) + }) }) } diff --git a/shared/constants/fs/platform-specific.desktop.tsx b/shared/constants/fs/platform-specific.desktop.tsx index 26ff8a81e597..557910c110af 100644 --- a/shared/constants/fs/platform-specific.desktop.tsx +++ b/shared/constants/fs/platform-specific.desktop.tsx @@ -1,16 +1,17 @@ import * as T from '@/constants/types' import {ignorePromise, wrapErrors} from '../utils' -import * as Constants from '../fs' +import * as Constants from '@/stores/fs' import * as Tabs from '../tabs' import {isWindows, isLinux, pathSep, isDarwin} from '../platform.desktop' import logger from '@/logger' import * as Path from '@/util/path' import KB2 from '@/util/electron.desktop' import {uint8ArrayToHex} from 'uint8array-extras' -import {useFSState} from '.' import {navigateAppend} from '../router2/util' import {useConfigState} from '@/stores/config' +const useFSState = Constants.useFSState + const {openPathInFinder, openURL, getPathType, selectFilesToUploadDialog} = KB2.functions const {darwinCopyToKBFSTempUploadFile, relaunchApp, uninstallKBFSDialog, uninstallDokanDialog} = KB2.functions const {exitApp, windowsCheckMountFromOtherDokanInstall, installCachedDokan, uninstallDokan} = KB2.functions diff --git a/shared/constants/init/index.desktop.tsx b/shared/constants/init/index.desktop.tsx index f5d5af3558cb..c7ba7e02fb83 100644 --- a/shared/constants/init/index.desktop.tsx +++ b/shared/constants/init/index.desktop.tsx @@ -4,7 +4,7 @@ import {ignorePromise} from '@/constants/utils' import {useConfigState} from '@/stores/config' import * as ConfigConstants from '@/stores/config' import {useDaemonState} from '@/stores/daemon' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' import {useProfileState} from '@/stores/profile' import {useRouterState} from '@/stores/router2' import * as EngineGen from '@/actions/engine-gen-gen' diff --git a/shared/constants/init/index.native.tsx b/shared/constants/init/index.native.tsx index d77006dbf81c..380f554e8503 100644 --- a/shared/constants/init/index.native.tsx +++ b/shared/constants/init/index.native.tsx @@ -5,7 +5,7 @@ import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '@/stores/daemon' import {useDarkModeState} from '@/stores/darkmode' -import {useFSState} from '@/constants/fs' +import {useFSState} from '@/stores/fs' import {useProfileState} from '@/stores/profile' import {useRouterState} from '@/stores/router2' import {useSettingsContactsState} from '@/stores/settings-contacts' From c1e5f4129c274bb5b27241a2eff90a029ab19783 Mon Sep 17 00:00:00 2001 From: chrisnojima Date: Mon, 12 Jan 2026 09:23:39 -0500 Subject: [PATCH 37/37] WIP --- shared/common-adapters/avatar/util.tsx | 14 --- shared/constants/deeplinks/index.tsx | 15 --- shared/constants/deeplinks/util.tsx | 13 --- shared/constants/init/shared.tsx | 134 +++++++------------------ 4 files changed, 38 insertions(+), 138 deletions(-) delete mode 100644 shared/common-adapters/avatar/util.tsx delete mode 100644 shared/constants/deeplinks/util.tsx diff --git a/shared/common-adapters/avatar/util.tsx b/shared/common-adapters/avatar/util.tsx deleted file mode 100644 index 6e08e360ab2f..000000000000 --- a/shared/common-adapters/avatar/util.tsx +++ /dev/null @@ -1,14 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {useAvatarState} from '@/common-adapters/avatar/store' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyTeamAvatarUpdated: { - const {name} = action.payload.params - useAvatarState.getState().dispatch.updated(name) - break - } - default: - } -} - diff --git a/shared/constants/deeplinks/index.tsx b/shared/constants/deeplinks/index.tsx index 405b5c517fba..998f184dc780 100644 --- a/shared/constants/deeplinks/index.tsx +++ b/shared/constants/deeplinks/index.tsx @@ -1,7 +1,6 @@ import * as Crypto from '../crypto/util' import * as Tabs from '../tabs' import {isPathSaltpackEncrypted, isPathSaltpackSigned} from '@/util/path' -import * as EngineGen from '@/actions/engine-gen-gen' import type HiddenString from '@/util/hidden-string' import URL from 'url-parse' import logger from '@/logger' @@ -286,17 +285,3 @@ export const handleSaltPackOpen = (_path: string | HiddenString) => { useCryptoState.getState().dispatch.onSaltpackOpenFile(operation, path) switchTab(Tabs.cryptoTab) } - -export const onEngineIncomingImpl = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyServiceHandleKeybaseLink: { - const {link, deferred} = action.payload.params - if (deferred && !link.startsWith('keybase://team-invite-link/')) { - return - } - handleKeybaseLink(link) - break - } - default: - } -} diff --git a/shared/constants/deeplinks/util.tsx b/shared/constants/deeplinks/util.tsx deleted file mode 100644 index e5f2d279fcc6..000000000000 --- a/shared/constants/deeplinks/util.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import * as EngineGen from '@/actions/engine-gen-gen' -import {onEngineIncomingImpl} from './index' - -export const onEngineIncoming = (action: EngineGen.Actions) => { - switch (action.type) { - case EngineGen.keybase1NotifyServiceHandleKeybaseLink: - { - onEngineIncomingImpl(action) - } - break - default: - } -} diff --git a/shared/constants/init/shared.tsx b/shared/constants/init/shared.tsx index 951d795808f7..7be982c97f36 100644 --- a/shared/constants/init/shared.tsx +++ b/shared/constants/init/shared.tsx @@ -6,7 +6,7 @@ import {ignorePromise} from '../utils' import type * as UseArchiveStateType from '@/stores/archive' import type * as UseAutoResetStateType from '@/stores/autoreset' import type * as UseDevicesStateType from '@/stores/devices' -import * as AvatarUtil from '@/common-adapters/avatar/util' +import {useAvatarState} from '@/common-adapters/avatar/store' import type * as UseBotsStateType from '@/stores/bots' import {useChatState} from '@/stores/chat2' import {getSelectedConversation} from '@/constants/chat2/common' @@ -15,7 +15,7 @@ import {useConfigState} from '@/stores/config' import {useCurrentUserState} from '@/stores/current-user' import {useDaemonState} from '@/stores/daemon' import {useDarkModeState} from '@/stores/darkmode' -import * as DeepLinksUtil from '../deeplinks/util' +import {handleKeybaseLink} from '../deeplinks' import {useFollowerState} from '@/stores/followers' import isEqual from 'lodash/isEqual' import type * as UseFSStateType from '@/stores/fs' @@ -40,59 +40,39 @@ let _gitLoaded = false export const onEngineConnected = () => { { - // Chat2 - const f = async () => { + const registerUIs = async () => { try { await T.RPCGen.delegateUiCtlRegisterChatUIRpcPromise() await T.RPCGen.delegateUiCtlRegisterLogUIRpcPromise() - console.log('Registered Chat UI') + logger.info('Registered Chat UI') + await T.RPCGen.delegateUiCtlRegisterHomeUIRpcPromise() + logger.info('Registered home UI') + await T.RPCGen.delegateUiCtlRegisterSecretUIRpcPromise() + logger.info('Registered secret ui') + await T.RPCGen.delegateUiCtlRegisterIdentify3UIRpcPromise() + logger.info('Registered identify ui') + await T.RPCGen.delegateUiCtlRegisterRekeyUIRpcPromise() + logger.info('Registered rekey ui') } catch (error) { - console.warn('Error in registering Chat UI:', error) + logger.error('Error in registering UIs:', error) } } - ignorePromise(f()) + ignorePromise(registerUIs()) } useConfigState.getState().dispatch.onEngineConnected() storeRegistry.getState('daemon').dispatch.startHandshake() { - const f = async () => { + const notifyCtl = async () => { try { + // prettier-ignore await T.RPCGen.notifyCtlSetNotificationsRpcPromise({ channels: { - allowChatNotifySkips: true, - app: true, - audit: true, - badges: true, - chat: true, - chatarchive: true, - chatattachments: true, - chatdev: false, - chatemoji: false, - chatemojicross: false, - chatkbfsedits: false, - deviceclone: false, - ephemeral: false, - favorites: false, - featuredBots: true, - kbfs: true, - kbfsdesktop: !isMobile, - kbfslegacy: false, - kbfsrequest: false, - kbfssubscription: true, - keyfamily: false, - notifysimplefs: true, - paperkeys: false, - pgp: true, - reachability: true, - runtimestats: true, - saltpack: true, - service: true, - session: true, - team: true, - teambot: false, - tracking: true, - users: true, - wallet: false, + allowChatNotifySkips: true, app: true, audit: true, badges: true, chat: true, chatarchive: true, + chatattachments: true, chatdev: false, chatemoji: false, chatemojicross: false, chatkbfsedits: false, + deviceclone: false, ephemeral: false, favorites: false, featuredBots: true, kbfs: true, kbfsdesktop: !isMobile, + kbfslegacy: false, kbfsrequest: false, kbfssubscription: true, keyfamily: false, notifysimplefs: true, + paperkeys: false, pgp: true, reachability: true, runtimestats: true, saltpack: true, service: true, session: true, + team: true, teambot: false, tracking: true, users: true, wallet: false, }, }) } catch (error) { @@ -101,54 +81,7 @@ export const onEngineConnected = () => { } } } - ignorePromise(f()) - } - { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterHomeUIRpcPromise() - console.log('Registered home UI') - } catch (error) { - console.warn('Error in registering home UI:', error) - } - } - ignorePromise(f()) - } - { - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterSecretUIRpcPromise() - logger.info('Registered secret ui') - } catch (error) { - logger.warn('error in registering secret ui: ', error) - } - } - ignorePromise(f()) - } - { - // Tracker2 - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterIdentify3UIRpcPromise() - logger.info('Registered identify ui') - } catch (error) { - logger.warn('error in registering identify ui: ', error) - } - } - ignorePromise(f()) - } - { - // UnlockFolders - const f = async () => { - try { - await T.RPCGen.delegateUiCtlRegisterRekeyUIRpcPromise() - logger.info('Registered rekey ui') - } catch (error) { - logger.warn('error in registering rekey ui: ') - logger.debug('error in registering rekey ui: ', error) - } - } - ignorePromise(f()) + ignorePromise(notifyCtl()) } } @@ -498,12 +431,20 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { useChatState.getState().dispatch.onEngineIncomingImpl(action) } break - default: - } - AvatarUtil.onEngineIncoming(action) - useConfigState.getState().dispatch.onEngineIncoming(action) - DeepLinksUtil.onEngineIncoming(action) - switch (action.type) { + case EngineGen.keybase1NotifyServiceHandleKeybaseLink: + { + const {link, deferred} = action.payload.params + if (deferred && !link.startsWith('keybase://team-invite-link/')) { + return + } + handleKeybaseLink(link) + } + break + case EngineGen.keybase1NotifyTeamAvatarUpdated: { + const {name} = action.payload.params + useAvatarState.getState().dispatch.updated(name) + break + } case EngineGen.keybase1NotifyTrackingTrackingChanged: { const {isTracking, username} = action.payload.params useFollowerState.getState().dispatch.updateFollowing(username, isTracking) @@ -556,4 +497,5 @@ export const _onEngineIncoming = (action: EngineGen.Actions) => { break default: } + useConfigState.getState().dispatch.onEngineIncoming(action) }