Skip to content
Merged
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
4 changes: 2 additions & 2 deletions shared/chat/conversation/messages/wrapper/wrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,13 @@ function AuthorSection(p: AuthorProps) {
const {author, botAlias, isAdhocBot, teamID, teamType, teamname, timestamp, showUsername} = p

const authorRoleInTeam = useTeamsState(s => s.teamIDToMembers.get(teamID)?.get(author)?.type)
const showUser = useTrackerState(s => s.dispatch.showUser)
const showTracker = useTrackerState(s => s.dispatch.showTracker)

const onAuthorClick = () => {
if (C.isMobile) {
navToProfile(showUsername)
} else {
showUser(showUsername, true)
showTracker(showUsername)
}
}

Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/mention-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ const Container = (ownProps: OwnProps) => {
}
})()

const showUser = useTrackerState(s => s.dispatch.showUser)
const showTracker = useTrackerState(s => s.dispatch.showTracker)
const _onClick = () => {
if (C.isMobile) {
navToProfile(username)
} else {
showUser(username, true)
showTracker(username)
}
}
const onClick = Chat.isSpecialMention(username) ? undefined : _onClick
Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/name-with-icon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,9 @@ const ConnectedNameWithIcon = (p: OwnProps) => {
navigateAppend({name: 'team', params: {teamID}})
}
}
const showUser = useTrackerState(s => s.dispatch.showUser)
const showTracker = useTrackerState(s => s.dispatch.showTracker)
const onOpenTracker = () => {
username && showUser(username, true)
username && showTracker(username)
}
const onOpenUserProfile = () => {
username && navToProfile(username)
Expand Down
6 changes: 3 additions & 3 deletions shared/common-adapters/profile-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,10 @@ const ProfileCard = ({
bio: userDetailsBio,
fullname: userDetailsFullname,
} = userDetails
const showUser = useTrackerState(s => s.dispatch.showUser)
const loadProfile = useTrackerState(s => s.dispatch.loadProfile)
React.useEffect(() => {
userDetailsState === 'unknown' && showUser(username, false, true)
}, [showUser, username, userDetailsState])
userDetailsState === 'unknown' && loadProfile(username)
}, [loadProfile, username, userDetailsState])
// signal layout change when it happens, to prevent popup cutoff.
React.useEffect(() => {
onLayoutChange?.()
Expand Down
4 changes: 2 additions & 2 deletions shared/common-adapters/proof-broken-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ type Props = {users?: Array<string>}
type ProofBrokenBannerNonEmptyProps = {users: Array<string>}

const ProofBrokenBannerNonEmpty = (props: ProofBrokenBannerNonEmptyProps) => {
const showUser = useTrackerState(s => s.dispatch.showUser)
const showTracker = useTrackerState(s => s.dispatch.showTracker)
const onClickUsername = (username: string) => {
if (C.isMobile) {
navToProfile(username)
} else {
showUser(username, true)
showTracker(username)
}
}
const content: Array<string | {text: string; onClick: () => void}> =
Expand Down
2 changes: 1 addition & 1 deletion shared/common-adapters/usernames.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function Username(p: UsernameProps) {
if (onUsernameClicked === 'tracker') {
onClicked = (evt?: React.BaseSyntheticEvent) => {
evt?.stopPropagation()
useTrackerState.getState().dispatch.showUser(username, true)
useTrackerState.getState().dispatch.showTracker(username)
}
} else if (onUsernameClicked === 'profile') {
onClicked = (evt?: React.BaseSyntheticEvent) => {
Expand Down
3 changes: 0 additions & 3 deletions shared/constants/init/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -331,9 +331,6 @@ export const initTracker2Callbacks = () => {
...currentState.dispatch,
defer: {
...currentState.dispatch.defer,
onShowUserProfile: (username: string) => {
navToProfile(username)
},
onUsersUpdates: (updates: ReadonlyArray<{name: string; info: Partial<T.Users.UserInfo>}>) => {
useUsersState.getState().dispatch.updates(updates)
},
Expand Down
8 changes: 3 additions & 5 deletions shared/fs/banner/reset-banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ 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 '@/stores/tracker'
import {useFSState} from '@/stores/fs'
import * as FS from '@/stores/fs'
import {navToProfile} from '@/constants/router'
Expand All @@ -25,9 +24,8 @@ const ConnectedBanner = (ownProps: OwnProps) => {
letResetUserBackIn(id, username)
}

const showUser = useTrackerState(s => s.dispatch.showUser)
const onViewProfile = (username: string) => () => {
C.isMobile ? navToProfile(username) : showUser(username, true)
const onOpenProfile = (username: string) => () => {
navToProfile(username)
}
Comment thread
chrisnojima marked this conversation as resolved.
const onOpenWithoutResetUsers = () =>
_onOpenWithoutResetUsers(
Expand Down Expand Up @@ -100,7 +98,7 @@ const ConnectedBanner = (ownProps: OwnProps) => {
<Kb.Button
mode="Secondary"
label={'View ' + p + "'s profile"}
onClick={onViewProfile(p)}
onClick={onOpenProfile(p)}
style={Kb.Styles.collapseStyles([styles.button, styles.secondaryOnRed])}
labelStyle={styles.secondaryOnRedLabel}
/>
Expand Down
9 changes: 7 additions & 2 deletions shared/git/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {openURL} from '@/util/misc'
import {useTrackerState} from '@/stores/tracker'
import * as FS from '@/stores/fs'
import {useCurrentUserState} from '@/stores/current-user'
import {navToProfile} from '@/constants/router'

export const NewContext = React.createContext<ReadonlySet<string>>(new Set())

Expand Down Expand Up @@ -77,9 +78,13 @@ function ConnectedRow(ownProps: OwnProps) {
)
}

const showUser = useTrackerState(s => s.dispatch.showUser)
const showTracker = useTrackerState(s => s.dispatch.showTracker)
const openUserTracker = (username: string) => {
Comment thread
chrisnojima marked this conversation as resolved.
showUser(username, true)
if (C.isMobile) {
navToProfile(username)
} else {
showTracker(username)
}
}

const onBrowseGitRepo = () =>
Expand Down
5 changes: 1 addition & 4 deletions shared/people/todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import * as Kb from '@/common-adapters'
import {useSettingsEmailState} from '@/stores/settings-email'
import {settingsAccountTab, settingsGitTab} from '@/constants/settings'
import type {AppTab} from '@/constants/tabs'
import {useTrackerState} from '@/stores/tracker'
import {useCurrentUserState} from '@/stores/current-user'
import {navToProfile} from '@/constants/router'

Expand Down Expand Up @@ -138,10 +137,8 @@ const AvatarUserTask = (props: TodoOwnProps) => (

const BioTask = (props: TodoOwnProps) => {
const myUsername = useCurrentUserState(s => s.username)
const showUser = useTrackerState(s => s.dispatch.showUser)
const onConfirm = () => {
// Ensure tracker state exists and the profile view is up to date.
showUser(myUsername, false)
navToProfile(myUsername)
}
return <BasicTask {...props} onConfirm={onConfirm} />
}
Expand Down
5 changes: 2 additions & 3 deletions shared/profile/edit-profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import * as Kb from '@/common-adapters'
import * as React from 'react'
import {useTrackerState} from '@/stores/tracker'
import {useCurrentUserState} from '@/stores/current-user'
import {generateGUIID} from '@/constants/utils'
import * as T from '@/constants/types'

const Container = () => {
const username = useCurrentUserState(s => s.username)
const d = useTrackerState(s => s.getDetails(username))
const loadProfile = useTrackerState(s => s.dispatch.load)
const loadProfile = useTrackerState(s => s.dispatch.loadProfile)
const _bio = d.bio || ''
const _fullname = d.fullname || ''
const _location = d.location || ''
Expand All @@ -20,7 +19,7 @@ const Container = () => {
editProfile(
[{bio, fullName: fullname, location}, C.waitingKeyTracker],
() => {
loadProfile({assertion: username, guiID: generateGUIID(), inTracker: false, reason: ''})
loadProfile(username, false)
navigateUp()
},
() => {}
Expand Down
7 changes: 3 additions & 4 deletions shared/profile/generic/proofs-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {useConfigState} from '@/stores/config'
import {openURL as openUrl} from '@/util/misc'
import {subtitle} from '@/util/platforms'
import {useCurrentUserState} from '@/stores/current-user'
import {generateGUIID, ignorePromise} from '@/constants/utils'
import {ignorePromise} from '@/constants/utils'
import {RPCError} from '@/util/errors'
import logger from '@/logger'
import {navToProfile} from '@/constants/router'
Expand Down Expand Up @@ -108,7 +108,7 @@ type Step =

const Container = ({platform, reason = 'profile'}: Props) => {
const currentUsername = useCurrentUserState(s => s.username)
const loadProfile = useTrackerState(s => s.dispatch.load)
const loadProfile = useTrackerState(s => s.dispatch.loadProfile)
const proofSuggestions = useTrackerState(s => s.proofSuggestions)
const copyToClipboard = useConfigState(s => s.dispatch.defer.copyToClipboard)
const registerCryptoAddress = C.useRPC(T.RPCGen.cryptocurrencyRegisterAddressRpcPromise)
Expand Down Expand Up @@ -168,8 +168,7 @@ const Container = ({platform, reason = 'profile'}: Props) => {
}
}, [])

const loadCurrentProfile = () =>
loadProfile({assertion: currentUsername, guiID: generateGUIID(), inTracker: false, reason: ''})
const loadCurrentProfile = () => loadProfile(currentUsername, false)

const closeModal = () => {
cancelSession()
Expand Down
5 changes: 2 additions & 3 deletions shared/profile/revoke.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import * as T from '@/constants/types'
import Modal from './modal'
import {useCurrentUserState} from '@/stores/current-user'
import {useTrackerState} from '@/stores/tracker'
import {generateGUIID} from '@/constants/utils'
import {navToProfile} from '@/constants/router'

type OwnProps = {
Expand All @@ -22,14 +21,14 @@ const RevokeProof = (ownProps: OwnProps) => {
const [errorMessage, setErrorMessage] = React.useState('')
const currentUsername = useCurrentUserState(s => s.username)
const assertions = useTrackerState(s => s.getDetails(currentUsername).assertions)
const loadProfile = useTrackerState(s => s.dispatch.load)
const loadProfile = useTrackerState(s => s.dispatch.loadProfile)
const revokeKey = C.useRPC(T.RPCGen.revokeRevokeKeyRpcPromise)
const revokeSigs = C.useRPC(T.RPCGen.revokeRevokeSigsRpcPromise)
const clearModals = C.Router2.clearModals
const proof = assertions ? [...assertions.values()].find(a => a.sigID === proofId) : undefined
const onSuccess = () => {
navToProfile(currentUsername)
loadProfile({assertion: currentUsername, guiID: generateGUIID(), inTracker: false, reason: ''})
loadProfile(currentUsername, false)
clearModals()
}
const onCancel = () => {
Expand Down
8 changes: 1 addition & 7 deletions shared/profile/showcase-team-offer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,7 @@ const Container = () => {
React.useEffect(() => {
return () => {
setTimeout(() => {
useTrackerState.getState().dispatch.load({
assertion: you,
guiID: C.generateGUIID(),
ignoreCache: true,
inTracker: false,
reason: '',
})
useTrackerState.getState().dispatch.loadProfile(you)
}, 500)
}
}, [you])
Expand Down
4 changes: 2 additions & 2 deletions shared/profile/user/actions/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const Container = (ownProps: OwnProps) => {
navigateAppend({name: 'chatBlockingModal', params: {username}})
const _onOpenPrivateFolder = (myUsername: string, theirUsername: string) =>
FS.navToPath(T.FS.stringToPath(`/keybase/private/${theirUsername},${myUsername}`))
const showUser = useTrackerState(s => s.dispatch.showUser)
const loadProfile = useTrackerState(s => s.dispatch.loadProfile)
const _onReload = (username: string) => {
showUser(username, false)
loadProfile(username)
}
const onAccept = () => _onFollow(_guiID, true)
const onAddToTeam = () => _onAddToTeam(username)
Expand Down
7 changes: 4 additions & 3 deletions shared/profile/user/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ const useUserData = (username: string) => {
d: s.getDetails(username),
getProofSuggestions: s.dispatch.getProofSuggestions,
loadNonUserProfile: s.dispatch.loadNonUserProfile,
loadProfile: s.dispatch.loadProfile,
nonUserDetails: s.getNonUserDetails(username),
showUser: s.dispatch.showUser,
}
})
)
const {d, getProofSuggestions, loadNonUserProfile, nonUserDetails, showUser, _suggestionKeys} = trackerState
const {d, getProofSuggestions, loadProfile, loadNonUserProfile, nonUserDetails, _suggestionKeys} =
trackerState
const notAUser = d.state === 'notAUserYet'

const commonProps = {
Expand Down Expand Up @@ -138,7 +139,7 @@ const useUserData = (username: string) => {
loadNonUserProfile(username)
}
if (state !== 'notAUserYet') {
showUser(username, false, true)
loadProfile(username)

if (isYou) {
getProofSuggestions()
Expand Down
6 changes: 3 additions & 3 deletions shared/settings/contacts-joined.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ export const FollowButton = (props: FollowProps) => {
const followsYou = useFollowerState(s => s.followers.has(username))
const {guiID} = userDetails

const showUser = useTrackerState(s => s.dispatch.showUser)
const loadProfile = useTrackerState(s => s.dispatch.loadProfile)
const changeFollow = useTrackerState(s => s.dispatch.changeFollow)

React.useEffect(() => {
if (!guiID) {
showUser(username, false, true)
loadProfile(username)
}
}, [username, guiID, showUser])
}, [username, guiID, loadProfile])

const onFollow = () => changeFollow(guiID, true)
const onUnfollow = () => changeFollow(guiID, false)
Expand Down
33 changes: 25 additions & 8 deletions shared/stores/tests/tracker.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,22 +43,17 @@ test('closeTracker removes the shown tracker entry by guiID and updateResult cha
expect(useTrackerState.getState().showTrackerSet.has('alice')).toBe(false)
})

test('showUser delegates to load and the deferred profile callback', () => {
test('loadProfile delegates to load with a profile load', () => {
const load = jest.fn()
const onShowUserProfile = jest.fn()
useTrackerState.setState(s => ({
...s,
dispatch: {
...s.dispatch,
defer: {
...s.dispatch.defer,
onShowUserProfile,
},
load: load as never,
},
}))

useTrackerState.getState().dispatch.showUser('alice', false)
useTrackerState.getState().dispatch.loadProfile('alice')

expect(load).toHaveBeenCalledWith(
expect.objectContaining({
Expand All @@ -69,7 +64,29 @@ test('showUser delegates to load and the deferred profile callback', () => {
reason: '',
})
)
expect(onShowUserProfile).toHaveBeenCalledWith('alice')
})

test('showTracker delegates to load with a tracker load', () => {
const load = jest.fn()
useTrackerState.setState(s => ({
...s,
dispatch: {
...s.dispatch,
load: load as never,
},
}))

useTrackerState.getState().dispatch.showTracker('alice')

expect(load).toHaveBeenCalledWith(
expect.objectContaining({
assertion: 'alice',
forceDisplay: true,
ignoreCache: true,
inTracker: true,
reason: '',
})
Comment thread
chrisnojima-zoom marked this conversation as resolved.
)
})

test('notifySummary and notifyRow enrich an existing tracker entry', () => {
Expand Down
Loading