Skip to content
Merged

shift 7 #28767

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions shared/constants/config/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -243,15 +243,6 @@ export const useConfigState = Z.createZustand<State>((set, get) => {
set(s => {
s.gregorReachable = r
})
// Re-get info about our account if you log in/we're done handshaking/became reachable
if (r === T.RPCGen.Reachable.yes) {
// not in waiting state
if (storeRegistry.getState('daemon').handshakeWaiters.size === 0) {
ignorePromise(storeRegistry.getState('daemon').dispatch.loadDaemonBootstrapStatus())
}
}

storeRegistry.getState('teams').dispatch.eagerLoadTeams()
}

const setGregorPushState = (state: T.RPCGen.Gregor1.State) => {
Expand Down Expand Up @@ -394,8 +385,6 @@ export const useConfigState = Z.createZustand<State>((set, get) => {
set(s => {
s.installerRanCount++
})

storeRegistry.getState('fs').dispatch.checkKbfsDaemonRpcStatus()
},
loadIsOnline: () => {
const f = async () => {
Expand Down Expand Up @@ -756,11 +745,6 @@ export const useConfigState = Z.createZustand<State>((set, get) => {

if (!changed) return

if (loggedIn) {
ignorePromise(storeRegistry.getState('daemon').dispatch.loadDaemonBootstrapStatus())
}
storeRegistry.getState('daemon').dispatch.loadDaemonAccounts()

const {loadOnStart} = get().dispatch
if (loggedIn) {
if (!causedByStartup) {
Expand All @@ -776,14 +760,6 @@ export const useConfigState = Z.createZustand<State>((set, get) => {
} else {
Z.resetAllStores()
}

if (loggedIn) {
storeRegistry.getState('fs').dispatch.checkKbfsDaemonRpcStatus()
}

if (!causedByStartup) {
ignorePromise(storeRegistry.getState('daemon').dispatch.refreshAccounts())
}
},
setLoginError: error => {
set(s => {
Expand All @@ -798,9 +774,6 @@ export const useConfigState = Z.createZustand<State>((set, get) => {
set(s => {
s.mobileAppState = nextAppState
})
if (nextAppState === 'background' && storeRegistry.getState('chat').inboxSearch) {
storeRegistry.getState('chat').dispatch.toggleInboxSearch(false)
}
},
setNotifySound: n => {
set(s => {
Expand Down
112 changes: 72 additions & 40 deletions shared/constants/platform-specific/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,59 +31,91 @@ import * as UsersUtil from '../users/util'

export const initSharedSubscriptions = () => {
useConfigState.subscribe((s, old) => {
if (s.loadOnStartPhase === old.loadOnStartPhase) return
if (s.loadOnStartPhase !== old.loadOnStartPhase) {
if (s.loadOnStartPhase === 'startupOrReloginButNotInARush') {
const getFollowerInfo = () => {
const {uid} = useCurrentUserState.getState()
logger.info(`getFollowerInfo: init; uid=${uid}`)
if (uid) {
// request follower info in the background
T.RPCGen.configRequestFollowingAndUnverifiedFollowersRpcPromise()
.then(() => {})
.catch(() => {})
}
}

if (s.loadOnStartPhase === 'startupOrReloginButNotInARush') {
const getFollowerInfo = () => {
const {uid} = useCurrentUserState.getState()
logger.info(`getFollowerInfo: init; uid=${uid}`)
if (uid) {
// request follower info in the background
T.RPCGen.configRequestFollowingAndUnverifiedFollowersRpcPromise()
.then(() => {})
.catch(() => {})
const updateServerConfig = async () => {
if (s.loggedIn) {
try {
await T.RPCGen.configUpdateLastLoggedInAndServerConfigRpcPromise({
serverConfigPath: serverConfigFileName,
})
} catch {}
}
}

const updateTeams = () => {
useTeamsState.getState().dispatch.getTeams()
useTeamsState.getState().dispatch.refreshTeamRoleMap()
}

const updateSettings = () => {
useSettingsContactsState.getState().dispatch.loadContactImportEnabled()
}
}

const updateServerConfig = async () => {
if (s.loggedIn) {
const updateChat = async () => {
// On login lets load the untrusted inbox. This helps make some flows easier
if (useCurrentUserState.getState().username) {
const {inboxRefresh} = useChatState.getState().dispatch
inboxRefresh('bootstrap')
}
try {
await T.RPCGen.configUpdateLastLoggedInAndServerConfigRpcPromise({
serverConfigPath: serverConfigFileName,
})
const rows = await T.RPCGen.configGuiGetValueRpcPromise({path: 'ui.inboxSmallRows'})
const ri = rows.i ?? -1
if (ri > 0) {
useChatState.getState().dispatch.setInboxNumSmallRows(ri, true)
}
} catch {}
}
}

const updateTeams = () => {
useTeamsState.getState().dispatch.getTeams()
useTeamsState.getState().dispatch.refreshTeamRoleMap()
getFollowerInfo()
ignorePromise(updateServerConfig())
updateTeams()
updateSettings()
ignorePromise(updateChat())
}
}

const updateSettings = () => {
useSettingsContactsState.getState().dispatch.loadContactImportEnabled()
if (s.gregorReachable !== old.gregorReachable) {
// Re-get info about our account if you log in/we're done handshaking/became reachable
if (s.gregorReachable === T.RPCGen.Reachable.yes) {
// not in waiting state
if (storeRegistry.getState('daemon').handshakeWaiters.size === 0) {
ignorePromise(storeRegistry.getState('daemon').dispatch.loadDaemonBootstrapStatus())
}
storeRegistry.getState('teams').dispatch.eagerLoadTeams()
}
}

const updateChat = async () => {
// On login lets load the untrusted inbox. This helps make some flows easier
if (useCurrentUserState.getState().username) {
const {inboxRefresh} = useChatState.getState().dispatch
inboxRefresh('bootstrap')
}
try {
const rows = await T.RPCGen.configGuiGetValueRpcPromise({path: 'ui.inboxSmallRows'})
const ri = rows.i ?? -1
if (ri > 0) {
useChatState.getState().dispatch.setInboxNumSmallRows(ri, true)
}
} catch {}
if (s.installerRanCount !== old.installerRanCount) {
storeRegistry.getState('fs').dispatch.checkKbfsDaemonRpcStatus()
}

if (s.loggedIn !== old.loggedIn) {
if (s.loggedIn) {
ignorePromise(storeRegistry.getState('daemon').dispatch.loadDaemonBootstrapStatus())
storeRegistry.getState('fs').dispatch.checkKbfsDaemonRpcStatus()
}
storeRegistry.getState('daemon').dispatch.loadDaemonAccounts()
if (!s.loggedInCausedbyStartup) {
ignorePromise(storeRegistry.getState('daemon').dispatch.refreshAccounts())
}
}

getFollowerInfo()
ignorePromise(updateServerConfig())
updateTeams()
updateSettings()
ignorePromise(updateChat())
if (s.mobileAppState !== old.mobileAppState) {
if (s.mobileAppState === 'background' && storeRegistry.getState('chat').inboxSearch) {
storeRegistry.getState('chat').dispatch.toggleInboxSearch(false)
}
}
})
}
Expand Down