Skip to content
Open
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
7 changes: 3 additions & 4 deletions shared/chat/audio/audio-recorder.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,7 @@ const useIconAndOverlay = (p: {
const maxCancelDrift = -120
const maxLockDrift = -100
dragYSV.set(interpolate(e.translationY, [maxLockDrift, 0], [maxLockDrift, 0], Extrapolation.CLAMP))
dragXSV.set(
interpolate(e.translationX, [maxCancelDrift, 0], [maxCancelDrift, 0], Extrapolation.CLAMP)
)
dragXSV.set(interpolate(e.translationX, [maxCancelDrift, 0], [maxCancelDrift, 0], Extrapolation.CLAMP))
if (e.translationX < maxCancelDrift) {
canceledSV.set(1)
} else if (e.translationY < maxLockDrift) {
Expand Down Expand Up @@ -476,7 +474,8 @@ const useRecorder = (p: {ampSV: SVN; setShowAudioSend: (s: boolean) => void; sho
React.useEffect(() => {
return () => {
setShowAudioSend(false)
onResetRef.current()
onResetRef
.current()
.then(() => {})
.catch(() => {})
}
Expand Down
2 changes: 1 addition & 1 deletion shared/chat/conversation/header-area/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const headerNavigationOptions = (route: {params?: {conversationIDKey?: st
const conversationIDKey = route.params?.conversationIDKey ?? Chat.noConversationIDKey
return {
headerLeft: (props: HeaderBackButtonProps) => {
const {onLabelLayout, labelStyle, ...rest} = props
const {labelStyle, ...rest} = props
return (
<Chat.ChatProvider id={conversationIDKey}>
<BadgeHeaderLeftArray {...rest} />
Expand Down
2 changes: 1 addition & 1 deletion shared/chat/inbox-and-conversation-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Header = () => {
canBeNull={true}
id={
// eslint-disable-next-line
params?.conversationIDKey ?? Chat.noConversationIDKey
(params as {conversationIDKey?: string} | undefined)?.conversationIDKey ?? Chat.noConversationIDKey
}
>
<Header2 />
Expand Down
36 changes: 1 addition & 35 deletions shared/constants/init/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import {ignorePromise, neverThrowPromiseFunc, timeoutPromise} from '../utils'
import {useChatState} from '@/stores/chat'
import {useConfigState} from '@/stores/config'
import {useCurrentUserState} from '@/stores/current-user'
import {useDaemonState} from '@/stores/daemon'
import {useDarkModeState} from '@/stores/darkmode'
import {useFSState} from '@/stores/fs'
Expand All @@ -21,7 +20,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, switchTab} from '@/constants/router'
import {getTab, getVisiblePath, logState} from '@/constants/router'
import {launchImageLibraryAsync} from '@/util/expo-image-picker.native'
import {pickDocumentsAsync} from '@/util/expo-document-picker.native'
import {setupAudioMode} from '@/util/audio.native'
Expand Down Expand Up @@ -529,21 +528,6 @@ export const initPlatformListener = () => {
})
})

let _pendingFastSwitchTab: string | undefined
useRouterState.setState(s => {
s.dispatch.defer.tabLongPress = wrapErrors((tab: string) => {
if (tab !== Tabs.peopleTab) return
const accountRows = useConfigState.getState().configuredAccounts
const current = useCurrentUserState.getState().username
const row = accountRows.find(a => a.username !== current && a.hasStoredSecret)
if (row) {
_pendingFastSwitchTab = getTab() ?? undefined
useConfigState.getState().dispatch.setUserSwitching(true)
useConfigState.getState().dispatch.login(row.username, '')
}
})
})

useFSState.setState(s => {
s.dispatch.defer.pickAndUploadMobile = wrapErrors(
(type: T.FS.MobilePickType, parentPath: T.FS.Path) => {
Expand Down Expand Up @@ -675,24 +659,6 @@ export const initPlatformListener = () => {
})
}

useConfigState.subscribe((state, prevState) => {
const tab = _pendingFastSwitchTab
if (!tab) return
if (state.loggedIn && !prevState.loggedIn) {
_pendingFastSwitchTab = undefined
let attempts = 0
const trySwitch = () => {
if (attempts++ > 20) return
if (getTab()) {
switchTab(tab as Tabs.AppTab)
} else {
setTimeout(trySwitch, 100)
}
}
setTimeout(trySwitch, 100)
}
})

initSharedSubscriptions()
}

Expand Down
37 changes: 27 additions & 10 deletions shared/constants/router.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export type PathParam = NavigateAppendType
export type Navigator = NavigationContainerRef<KBRootParamList>

const DEBUG_NAV = __DEV__ && (false as boolean)
const rootNonModalRouteNames = new Set<string>(['chatConversation'])

export const getRootState = (): NavState | undefined => {
if (!navigationRef.isReady()) return
Expand Down Expand Up @@ -117,7 +118,7 @@ export const getModalStack = (navState?: T.Immutable<NavState>) => {
if (!_isLoggedIn(rs)) {
return []
}
return rs.routes?.slice(1) ?? []
return (rs.routes?.slice(1) ?? []).filter(r => !rootNonModalRouteNames.has(r.name))
}

export const getVisibleScreen = (navState?: T.Immutable<NavState>, _inludeModals?: boolean) => {
Expand Down Expand Up @@ -170,8 +171,20 @@ export const clearModals = () => {
const n = _getNavigator()
if (!n) return
const ns = getRootState()
if (_isLoggedIn(ns) && (ns?.routes?.length ?? 0) > 1) {
n.dispatch({...StackActions.popToTop(), target: ns?.key})
if (!_isLoggedIn(ns)) {
return
}
const rootRoutes = ns?.routes ?? []
const keepRoutes = rootRoutes.filter((route, index) => index === 0 || rootNonModalRouteNames.has(route.name))
if (keepRoutes.length !== rootRoutes.length) {
n.dispatch({
...CommonActions.reset({
...ns,
index: keepRoutes.length - 1,
routes: keepRoutes,
} as Parameters<typeof CommonActions.reset>[0]),
target: ns?.key,
})
}
}

Expand Down Expand Up @@ -282,14 +295,18 @@ export const navToThread = (conversationIDKey: T.Chat.ConversationIDKey) => {
target: tabNavState.key,
})
} else {
// Phone: full reset to build the chat conversation stack
// Phone: switch to the chat tab, then push the conversation above the tabs.
const nextState = {
routes: [{name: 'loggedIn', state: {
routes: [{name: Tabs.chatTab, state: {
index: 1,
routes: [{name: 'chatRoot'}, {name: 'chatConversation', params: {conversationIDKey}}],
}}],
}}],
index: 1,
routes: [
{
name: 'loggedIn',
state: {
routes: [{name: Tabs.chatTab, state: {index: 0, routes: [{name: 'chatRoot'}]}}],
},
},
{name: 'chatConversation', params: {conversationIDKey}},
],
}
n.dispatch({
...CommonActions.reset(nextState as Parameters<typeof CommonActions.reset>[0]),
Expand Down
9 changes: 3 additions & 6 deletions shared/crypto/sub-nav/index.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
createNavigatorFactory,
type NavigationContainerRef,
} from '@react-navigation/core'
import type {TypedNavigator, NavigatorTypeBagBase, StaticConfig} from '@react-navigation/native'
import type {TypedNavigator, NavigatorTypeBagBase} from '@react-navigation/native'
import {routeMapToScreenElements} from '@/router-v2/routes'
import {makeLayout} from '@/router-v2/screen-layout.desktop'
import type {RouteDef, GetOptionsParams} from '@/constants/types/router'
Expand Down Expand Up @@ -98,10 +98,7 @@ type NavType = NavigatorTypeBagBase & {
}
}

export const createLeftTabNavigator = createNavigatorFactory(LeftTabNavigator) as () => TypedNavigator<
NavType,
StaticConfig<NavigatorTypeBagBase>
>
export const createLeftTabNavigator = createNavigatorFactory(LeftTabNavigator) as unknown as () => TypedNavigator<NavType>
const TabNavigator = createLeftTabNavigator()
const makeOptions = (rd: RouteDef) => {
return ({route, navigation}: GetOptionsParams) => {
Expand All @@ -110,7 +107,7 @@ const makeOptions = (rd: RouteDef) => {
return {...opt}
}
}
const cryptoScreens = routeMapToScreenElements(cryptoSubRoutes, TabNavigator.Screen, makeLayout, makeOptions, false, false)
const cryptoScreens = routeMapToScreenElements(cryptoSubRoutes, TabNavigator.Screen, makeLayout, makeOptions, false, false, false)
const CryptoSubNavigator = () => (
<TabNavigator.Navigator initialRouteName={Crypto.encryptTab} backBehavior="none">
{cryptoScreens}
Expand Down
18 changes: 16 additions & 2 deletions shared/fs/nav-header/mobile-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ const MaybePublicTag = ({path}: {path: T.FS.Path}) =>
<Kb.Meta title="public" backgroundColor={Kb.Styles.globalColors.green} />
) : null

const FilesTabStatusIcon = () => {
const uploadIcon = useFSState(s => s.getUploadIconForFilesTab())
return uploadIcon ? <Kbfs.UploadIcon uploadIcon={uploadIcon} style={styles.filesTabStatusIcon} /> : null
}

const NavMobileHeader = (props: Props) => {
const {expanded, setFolderViewFilter} = useFSState(
C.useShallow(s => ({
Expand All @@ -50,8 +55,11 @@ const NavMobileHeader = (props: Props) => {

return props.path === FS.defaultPath ? (
<Kb.SafeAreaViewTop>
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.headerContainer} centerChildren={true}>
<Kb.Text type="BodyBig">Files</Kb.Text>
<Kb.Box2 direction="vertical" fullWidth={true} style={styles.headerContainer}>
<Kb.Box2 direction="horizontal" fullWidth={true} centerChildren={true} gap="xtiny">
<Kb.Text type="BodyBig">Files</Kb.Text>
<FilesTabStatusIcon />
</Kb.Box2>
</Kb.Box2>
<MainBanner />
</Kb.SafeAreaViewTop>
Expand All @@ -66,6 +74,7 @@ const NavMobileHeader = (props: Props) => {
<Kb.BackButton badgeNumber={0 /* TODO KBFS-4109 */} onClick={pop} style={styles.backButton} />
) : null}
<Kb.Box2 direction="horizontal" flex={1} />
<FilesTabStatusIcon />
<Actions path={props.path} onTriggerFilterMobile={triggerFilterMobile} />
</Kb.Box2>
)}
Expand Down Expand Up @@ -108,13 +117,18 @@ const styles = Kb.Styles.styleSheetCreate(
},
expandedTopContainer: Kb.Styles.platformStyles({
common: {
alignItems: 'center',
backgroundColor: Kb.Styles.globalColors.white,
paddingRight: Kb.Styles.globalMargins.tiny,
},
isAndroid: {height: 56},
isIOS: {height: 44},
}),
filename: {marginLeft: Kb.Styles.globalMargins.xtiny},
filesTabStatusIcon: {
height: Kb.Styles.globalMargins.small,
width: Kb.Styles.globalMargins.small,
},
headerContainer: {
backgroundColor: Kb.Styles.globalColors.white,
borderBottomColor: Kb.Styles.globalColors.black_10,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"info": {
"author": "xcode",
"version": 1
},
"symbols": [
{
"filename": "kb-nav-chat.svg",
"idiom": "universal"
}
]
}
Loading