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/app/out-of-date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as React from 'react'
import * as T from '@/constants/types'
import logger from '@/logger'
import {useConfigState} from '@/stores/config'
import {openAppStore} from '@/util/storeless-actions'

const styles = Kb.Styles.styleSheetCreate(() => ({
container: {
Expand Down Expand Up @@ -55,7 +56,6 @@ const OutOfDate = () => {
}
}, [])

const onOpenAppStore = useConfigState(s => s.dispatch.defer.openAppStore)
const critical = C.isMobile ? mobileCritical : outOfDate.critical
const message = C.isMobile ? mobileMessage : outOfDate.message

Expand All @@ -67,7 +67,7 @@ const OutOfDate = () => {
<Kb.Box2 direction="vertical" style={styles.messageContainer} fullWidth={true}>
<Kb.Markdown>{message}</Kb.Markdown>
</Kb.Box2>
{Kb.Styles.isMobile && <Kb.Button label="Update" onClick={onOpenAppStore} />}
{Kb.Styles.isMobile && <Kb.Button label="Update" onClick={openAppStore} />}
</Kb.Box2>
)
}
Expand Down
3 changes: 1 addition & 2 deletions shared/chat/chat-button.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as C from '@/constants'
import * as Styles from '@/styles'
import {useConfigState} from '@/stores/config'
import WaitingButton from '@/common-adapters/waiting-button'
import Icon from '@/common-adapters/icon'
import {showMain} from '@/util/storeless-actions'

// pulled in from common-adapters/profile-card
const Kb = {
Expand All @@ -18,7 +18,6 @@ type Props = {
}

const ChatButton = ({small, style, username, afterClick}: Props) => {
const showMain = useConfigState(s => s.dispatch.showMain)
const previewConversation = C.Router2.previewConversation
const chat = () => {
afterClick?.()
Expand Down
7 changes: 2 additions & 5 deletions shared/chat/conversation/attachment-fullscreen/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Chat from '@/stores/chat'
import * as ConvoState from '@/stores/convostate'
import type * as T from '@/constants/types'
import {maxWidth, maxHeight} from '../messages/attachment/shared'
import {useFSState} from '@/stores/fs'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

const blankMessage = Chat.makeMessageAttachment({})
export const useData = (initialOrdinal: T.Chat.Ordinal) => {
Expand Down Expand Up @@ -35,9 +35,6 @@ export const useData = (initialOrdinal: T.Chat.Ordinal) => {
onSwitchAttachment(true)
}

const openLocalPathInSystemFileManagerDesktop = useFSState(
s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop
)
const navigateUp = C.Router2.navigateUp
const showInfoPanel = ConvoState.useChatContext(s => s.dispatch.showInfoPanel)
const attachmentDownload = ConvoState.useChatContext(s => s.dispatch.attachmentDownload)
Expand All @@ -61,7 +58,7 @@ export const useData = (initialOrdinal: T.Chat.Ordinal) => {
}

const onShowInFinder = downloadPath
? () => openLocalPathInSystemFileManagerDesktop?.(downloadPath)
? () => openLocalPathInSystemFileManagerDesktop(downloadPath)
: undefined

const progress = transferProgress
Expand Down
5 changes: 2 additions & 3 deletions shared/chat/conversation/command-status.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as ConvoState from '@/stores/convostate'
import * as T from '@/constants/types'
import * as Kb from '@/common-adapters'
import {useConfigState} from '@/stores/config'
import {openAppSettings} from '@/util/storeless-actions'

const empty = {
actions: [],
Expand All @@ -13,7 +13,6 @@ const Container = () => {
const info = ConvoState.useChatUIContext(s => s.commandStatus)
const _info = info || empty

const onOpenAppSettings = useConfigState(s => s.dispatch.defer.openAppSettings)
const setCommandStatusInfo = ConvoState.useChatUIContext(s => s.dispatch.setCommandStatusInfo)
const onCancel = () => {
setCommandStatusInfo()
Expand All @@ -24,7 +23,7 @@ const Container = () => {
case T.RPCChat.UICommandStatusActionTyp.appsettings:
return {
displayText: 'View App Settings',
onClick: () => onOpenAppSettings?.(),
onClick: openAppSettings,
}
default:
return {
Expand Down
20 changes: 5 additions & 15 deletions shared/chat/conversation/info-panel/attachments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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 '@/stores/fs'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

type Props = {
commonSections: ReadonlyArray<Section>
Expand Down Expand Up @@ -307,10 +307,7 @@ const LinkTitle = (p: {title: string; url?: string}) => {
<Kb.Text
type="BodySmallPrimaryLink"
{...urlProps}
style={Kb.Styles.collapseStyles([
styles.linkStyle,
{color: Kb.Styles.globalColors.blueDark},
])}
style={Kb.Styles.collapseStyles([styles.linkStyle, {color: Kb.Styles.globalColors.blueDark}])}
>
{p.title}
</Kb.Text>
Expand Down Expand Up @@ -432,9 +429,7 @@ export const useAttachmentSections = (
loadImmediately: boolean,
useFlexWrap: boolean
): {sections: Array<Section>} => {
const [selectedAttachmentView, onSelectAttachmentView] = React.useState(
T.RPCChat.GalleryItemTyp.media
)
const [selectedAttachmentView, onSelectAttachmentView] = React.useState(T.RPCChat.GalleryItemTyp.media)
const [lastSAV, setLastSAV] = React.useState(selectedAttachmentView)
const loadAttachmentView = ConvoState.useChatContext(s => s.dispatch.loadAttachmentView)
const loadMessagesCentered = ConvoState.useChatContext(s => s.dispatch.loadMessagesCentered)
Expand Down Expand Up @@ -492,11 +487,8 @@ export const useAttachmentSections = (
}
}

const openLocalPathInSystemFileManagerDesktop = useFSState(
s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop
)
const onShowInFinder = (message: T.Chat.MessageAttachment) =>
message.downloadPath && openLocalPathInSystemFileManagerDesktop?.(message.downloadPath)
message.downloadPath && openLocalPathInSystemFileManagerDesktop(message.downloadPath)

const avSection = {
data: [{type: 'avselector'}] as const,
Expand Down Expand Up @@ -714,9 +706,7 @@ export const useAttachmentSections = (
{item.snippet}
</Kb.Markdown>
</Kb.Box2>
{!!item.title && (
<LinkTitle title={item.title} url={item.url} />
)}
{!!item.title && <LinkTitle title={item.title} url={item.url} />}
<Kb.Divider />
</Kb.Box2>
</Kb.ClickableBox2>
Expand Down
4 changes: 2 additions & 2 deletions shared/chat/conversation/input-area/location-popup.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {useCurrentUserState} from '@/stores/current-user'
import {requestLocationPermission} from '@/util/platform-specific'
import * as ExpoLocation from 'expo-location'
import {ignorePromise} from '@/constants/utils'
import {openAppSettings} from '@/util/storeless-actions'

const LocationButton = (props: {
disabled: boolean
Expand Down Expand Up @@ -105,7 +106,6 @@ const LocationPopup = () => {
const onClose = () => {
clearModals()
}
const onSettings = useConfigState(s => s.dispatch.defer.openAppSettings)
const sendMessage = ConvoState.useChatContext(s => s.dispatch.sendMessage)
const onLocationShare = (duration: string) => {
onClose()
Expand All @@ -129,7 +129,7 @@ const LocationPopup = () => {
<Kb.Text center={true} type="Body" style={styles.deniedText}>
Enable location for Keybase to see your current position.
</Kb.Text>
<Kb.Button label="Open settings" onClick={onSettings} />
<Kb.Button label="Open settings" onClick={openAppSettings} />
</Kb.Box2>
) : (
<LocationMap mapSrc={mapSrc} height={height} width={width} onLoad={() => setMapLoaded(true)} />
Expand Down
3 changes: 1 addition & 2 deletions shared/chat/conversation/input-area/normal/input.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {launchCameraAsync, launchImageLibraryAsync} from '@/util/expo-image-pick
import {onHWKeyPressed, registerPasteImage, removeOnHWKeyPressed} from 'react-native-kb'
import {pickDocumentsAsync} from '@/util/expo-document-picker.native'
import {standardTransformer} from '../suggestors/common'
import {useConfigState} from '@/stores/config'
import {filePickerError} from '@/util/storeless-actions'
import {usePickerState} from '@/chat/emoji-picker/use-picker'
import {useSuggestors} from '../suggestors'

Expand Down Expand Up @@ -352,7 +352,6 @@ type ChatFilePickerProps = {
const ChatFilePicker = (p: ChatFilePickerProps) => {
const {attachTo, showingPopup, hidePopup} = p
const conversationIDKey = ConvoState.useChatContext(s => s.id)
const filePickerError = useConfigState(s => s.dispatch.filePickerError)
const navigateAppend = ConvoState.useChatNavigateAppend()
const launchNativeImagePicker = (mediaType: 'photo' | 'video' | 'mixed' | 'file', location: string) => {
const f = async () => {
Expand Down
3 changes: 1 addition & 2 deletions shared/chat/conversation/list-area/index.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {FocusContext, ScrollContext} from '../normal/context'
import shallowEqual from '@/util/shallow-equal'
import useResizeObserver from '@/util/use-resize-observer.desktop'
import useIntersectionObserver from '@/util/use-intersection-observer'
import {useConfigState} from '@/stores/config'
import {copyToClipboard} from '@/util/storeless-actions'

// 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
Expand Down Expand Up @@ -489,7 +489,6 @@ const ThreadWrapper = function ThreadWrapper() {
)
const {conversationIDKey, centeredHighlightOrdinal, centeredOrdinal} = data
const {containsLatestMessage, messageOrdinals, loaded} = data
const copyToClipboard = useConfigState(s => s.dispatch.defer.copyToClipboard)
const listRef = React.useRef<HTMLDivElement | null>(null)
const _setListRef = (r: HTMLDivElement | null) => {
listRef.current = r
Expand Down
7 changes: 2 additions & 5 deletions shared/chat/conversation/messages/attachment/audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Chat from '@/stores/chat'
import type * as T from '@/constants/types'
import * as Kb from '@/common-adapters'
import AudioPlayer from '@/chat/audio/audio-player'
import {useFSState} from '@/stores/fs'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

const messageAttachmentHasProgress = (message: T.Chat.MessageAttachment) => {
return (
Expand All @@ -14,11 +14,8 @@ const messageAttachmentHasProgress = (message: T.Chat.MessageAttachment) => {
const AudioAttachment = ({message}: {message: T.Chat.MessageAttachment}) => {
const progressLabel = Chat.messageAttachmentTransferStateToProgressLabel(message.transferState)
const hasProgress = messageAttachmentHasProgress(message)
const openLocalPathInSystemFileManagerDesktop = useFSState(
s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop
)
const onShowInFinder = () => {
message.downloadPath && openLocalPathInSystemFileManagerDesktop?.(message.downloadPath)
message.downloadPath && openLocalPathInSystemFileManagerDesktop(message.downloadPath)
}
const url = !message.submitState && message.fileURL.length > 0 ? `${message.fileURL}&contentforce=true` : ''
const showInFinder = !!message.downloadPath && !Kb.Styles.isMobile
Expand Down
7 changes: 2 additions & 5 deletions shared/chat/conversation/messages/attachment/file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ 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 '@/stores/fs'
import {makeUUID} from '@/util/uuid'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

type OwnProps = {
isEditing: boolean
Expand Down Expand Up @@ -56,11 +56,8 @@ function FileContainer(p: OwnProps) {
true
)
}
const openLocalPathInSystemFileManagerDesktop = useFSState(
s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop
)
const _onShowInFinder = () => {
downloadPath && openLocalPathInSystemFileManagerDesktop?.(downloadPath)
downloadPath && openLocalPathInSystemFileManagerDesktop(downloadPath)
}

const onDownload = () => {
Expand Down
5 changes: 2 additions & 3 deletions shared/chat/conversation/messages/attachment/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as Kb from '@/common-adapters'
import * as React from 'react'
import * as T from '@/constants/types'
import {sharedStyles} from '../shared-styles'
import {useFSState} from '@/stores/fs'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

type Props = {
transferState: T.Chat.MessageAttachmentTransferState
Expand Down Expand Up @@ -87,9 +87,8 @@ export const TransferIcon = (p: {
download(ordinal)
}

const openFinder = useFSState(s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop)
const onFinder = () => {
downloadPath && openFinder?.(downloadPath)
downloadPath && openLocalPathInSystemFileManagerDesktop(downloadPath)
}

switch (state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,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 '@/stores/fs'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

type OwnProps = {
attachTo?: React.RefObject<Kb.MeasureRef | null>
Expand Down Expand Up @@ -85,11 +85,8 @@ const PopAttach = (ownProps: OwnProps) => {
}
const onShareAttachment = C.isMobile ? _onShareAttachment : undefined

const openLocalPathInSystemFileManagerDesktop = useFSState(
s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop
)
const _onShowInFinder = () => {
downloadPath && openLocalPathInSystemFileManagerDesktop?.(downloadPath)
downloadPath && openLocalPathInSystemFileManagerDesktop(downloadPath)
}
const onShowInFinder = !C.isMobile && message.downloadPath ? _onShowInFinder : undefined

Expand Down
3 changes: 1 addition & 2 deletions shared/chat/conversation/messages/message-popup/hooks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import * as C from '@/constants'
import * as Chat from '@/stores/chat'
import * as ConvoState from '@/stores/convostate'
import * as Teams from '@/stores/teams'
import {useConfigState} from '@/stores/config'
import {useCurrentUserState} from '@/stores/current-user'
import {linkFromConvAndMessage} from '@/constants/deeplinks'
import ReactionItem from './reactionitem'
import MessagePopupHeader from './header'
import ExplodingPopupHeader from './exploding-header'
import {formatTimeForPopup, formatTimeForRevoked} from '@/util/timestamp'
import {navToProfile} from '@/constants/router'
import {copyToClipboard} from '@/util/storeless-actions'

const emptyText = Chat.makeMessageText({})

Expand Down Expand Up @@ -101,7 +101,6 @@ export const useItems = (ordinal: T.Chat.Ordinal, onHidden: () => void) => {
: []

const convLabel = getConversationLabel(participantInfo, meta, true)
const copyToClipboard = useConfigState(s => s.dispatch.defer.copyToClipboard)
const onCopyLink = () => {
copyToClipboard(linkFromConvAndMessage(convLabel, id))
}
Expand Down
3 changes: 1 addition & 2 deletions shared/chat/conversation/messages/message-popup/text.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import * as C from '@/constants'
import * as Chat from '@/stores/chat'
import * as ConvoState from '@/stores/convostate'
import {useConfigState} from '@/stores/config'
import type * 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/misc'
import {useCurrentUserState} from '@/stores/current-user'
import {copyToClipboard} from '@/util/storeless-actions'

type OwnProps = {
attachTo?: React.RefObject<Kb.MeasureRef | null>
Expand Down Expand Up @@ -77,7 +77,6 @@ const PopText = (ownProps: OwnProps) => {
// you can reply privately *if* text message, someone else's message, and not in a 1-on-1 chat
const canReplyPrivately = ['small', 'big'].includes(teamType) || numPart > 2
const navigateAppend = C.Router2.navigateAppend
const copyToClipboard = useConfigState(s => s.dispatch.defer.copyToClipboard)
const onCopy = () => {
text && copyToClipboard(text)
}
Expand Down
7 changes: 2 additions & 5 deletions shared/chat/pdf/index.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,19 @@ import * as ConvoState from '@/stores/convostate'
import * as Kb from '@/common-adapters'
import * as React from 'react'
import type {Props} from '.'
import {useFSState} from '@/stores/fs'
import {useModalHeaderState} from '@/stores/modal-header'
import {openLocalPathInSystemFileManagerDesktop} from '@/util/fs-storeless-actions'

const ChatPDF = (props: Props) => {
const {ordinal} = props
const message = ConvoState.useChatContext(s => s.messageMap.get(ordinal))
const title = message?.title || message?.fileName || 'PDF'
const url = message?.fileURL
const openLocalPathInSystemFileManagerDesktop = useFSState(
s => s.dispatch.defer.openLocalPathInSystemFileManagerDesktop
)

const attachmentDownload = ConvoState.useChatContext(s => s.dispatch.attachmentDownload)
const onDownload = () => {
message && attachmentDownload(message.ordinal)
openLocalPathInSystemFileManagerDesktop?.(C.downloadFolder)
openLocalPathInSystemFileManagerDesktop(C.downloadFolder)
}

React.useEffect(() => {
Expand Down
5 changes: 2 additions & 3 deletions shared/chat/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import type * as T from '@/constants/types'
import chatNewChat from '../team-building/page'
import {TeamBuilderScreen} from '../team-building/page'
import {headerNavigationOptions} from './conversation/header-area'
import {useConfigState} from '@/stores/config'
import {useModalHeaderState} from '@/stores/modal-header'
import {ModalTitle} from '@/teams/common'
import inboxGetOptions from './inbox/get-options'
Expand All @@ -17,6 +16,7 @@ import {defineRouteMap} from '@/constants/types/router'
import type {BlockModalContext} from './blocking/block-modal'
import type {ChatRootRouteParams} from './inbox-and-conversation'
import {onTeamBuildingFinished} from '@/stores/convostate'
import {showShareActionSheet} from '@/util/storeless-actions'
const Convo = React.lazy(async () => import('./conversation/container'))

type ChatBlockingRouteParams = {
Expand Down Expand Up @@ -47,9 +47,8 @@ const ChatTeamBuilderScreen = (p: Parameters<typeof TeamBuilderScreen>[0]) => (
)

const PDFShareButton = ({url}: {url?: string}) => {
const showShareActionSheet = useConfigState(s => s.dispatch.defer.showShareActionSheet)
return (
<Kb.Icon type="iconfont-share" onClick={() => showShareActionSheet?.(url ?? '', '', 'application/pdf')} />
<Kb.Icon type="iconfont-share" onClick={() => showShareActionSheet(url ?? '', '', 'application/pdf')} />
)
}

Expand Down
Loading