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: 3 additions & 1 deletion shared/app/global-errors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ const useData = () => {
const size: Size = error ? (expandedError === error ? 'Big' : 'Small') : 'Closed'

const clearCountdown = () => {
countdownTimerRef.current && clearTimeout(countdownTimerRef.current)
if (countdownTimerRef.current) {
clearTimeout(countdownTimerRef.current)
}
countdownTimerRef.current = undefined
}

Expand Down
4 changes: 3 additions & 1 deletion shared/app/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ const useDarkHookup = () => {
React.useEffect(() => {
const appStateChangeSub = AppState.addEventListener('change', nextAppState => {
appStateRef.current = nextAppState
nextAppState !== 'unknown' && nextAppState !== 'extension' && setMobileAppState(nextAppState)
if (nextAppState !== 'unknown' && nextAppState !== 'extension') {
setMobileAppState(nextAppState)
}

if (nextAppState === 'active') {
setSystemDarkMode(Appearance.getColorScheme() === 'dark')
Expand Down
2 changes: 2 additions & 0 deletions shared/app/out-of-date.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ const OutOfDate = () => {
setMobileCritical(false)
setMobileMessage('')
}
return undefined
})
.catch(e => {
logger.warn("Can't call critical check", e)
return undefined
})
)
}, 60_000) // don't bother checking during startup
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,12 @@ const Fullscreen = function Fullscreen(p: Props) {

const vidRef = React.useRef<HTMLVideoElement>(null)
const onHotKey = (cmd: string) => {
cmd === 'left' && onPreviousAttachment()
cmd === 'right' && onNextAttachment()
if (cmd === 'left') {
onPreviousAttachment()
}
if (cmd === 'right') {
onNextAttachment()
}
}
Kb.useHotKey(['left', 'right'], onHotKey)
const isDownloadError = !!message.transferErrMsg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,13 @@ const Fullscreen = function Fullscreen(p: Props) {
}, [])

React.useEffect(() => {
fadeAnim &&
if (fadeAnim) {
Animated.timing(fadeAnim, {
duration: 240,
toValue: showHeader ? 1 : 0,
useNativeDriver: true,
}).start()
}
}, [showHeader, fadeAnim])

return (
Expand Down
19 changes: 6 additions & 13 deletions shared/chat/conversation/attachment-get-titles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ const Container = (ownProps: OwnProps) => {
const attachFromDragAndDrop = ConvoState.useChatContext(s => s.dispatch.attachFromDragAndDrop)

const _onSubmit = (titles: Array<string>, spoiler: boolean) => {
tlfName || noDragDrop
? attachmentsUpload(pathAndOutboxIDs, titles, tlfName, spoiler)
: attachFromDragAndDrop(pathAndOutboxIDs, titles)
if (tlfName || noDragDrop) {
attachmentsUpload(pathAndOutboxIDs, titles, tlfName, spoiler)
} else {
attachFromDragAndDrop(pathAndOutboxIDs, titles)
}
clearModals()

if (selectConversationWithReason) {
Expand All @@ -85,8 +87,7 @@ const Container = (ownProps: OwnProps) => {

const [index, setIndex] = React.useState(0)
const [titles, setTitles] = React.useState(pathAndInfos.map((_, idx) => _titles?.[idx] ?? ''))
const [spoiler, setSpoiler] = React.useState(false)
setSpoiler // TODO commented out
const spoiler = false

const onNext = (e?: React.BaseSyntheticEvent) => {
e?.preventDefault()
Expand Down Expand Up @@ -204,14 +205,6 @@ const Container = (ownProps: OwnProps) => {
containerStyle={styles.inputBare}
inputStyle={styles.input}
/>
{/* (
<Kb.Checkbox
style={{alignSelf: 'flex-end'}}
label="Spoiler?"
checked={spoiler}
onCheck={setSpoiler}
/>
)*/}
</Kb.Box2>
</Kb.Box2>
</Kb.ClickableBox2>
Expand Down
6 changes: 5 additions & 1 deletion shared/chat/conversation/bot/install.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,11 @@ const InstallBotPopup = (props: Props) => {
} else if (installScreen) {
setInstallScreen(false)
} else {
Kb.Styles.isMobile ? navigateUp() : clearModals()
if (Kb.Styles.isMobile) {
navigateUp()
} else {
clearModals()
}
}
}
useModalHeaderState.setState({
Expand Down
18 changes: 4 additions & 14 deletions shared/chat/conversation/command-status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,10 @@ const Container = () => {
setCommandStatusInfo()
}
const props = {
actions: _info.actions.map((a: T.RPCChat.UICommandStatusActionTyp | unknown) => {
switch (a) {
case T.RPCChat.UICommandStatusActionTyp.appsettings:
return {
displayText: 'View App Settings',
onClick: openAppSettings,
}
default:
return {
displayText: '???',
onClick: () => {},
}
}
}),
actions: _info.actions.map(() => ({
displayText: 'View App Settings',
onClick: openAppSettings,
})),
displayText: _info.displayText,
displayType: _info.displayType,
onCancel,
Expand Down
6 changes: 3 additions & 3 deletions shared/chat/conversation/info-panel/add-people.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ const AddPeople = (p: Props) => {
const teamID = ConvoState.useChatContext(s => s.meta.teamID)
const navigateAppend = ConvoState.useChatNavigateAppend()
const onAddPeople = () => {
teamID &&
if (teamID) {
C.Router2.navigateAppend({name: 'teamAddToTeamFromWhere', params: {wizard: makeAddMembersWizard(teamID)}})
}
}
const onAddToChannel = () => {
navigateAppend(conversationIDKey => ({name: 'chatAddToChannel', params: {conversationIDKey, teamID}}))
}

let directAction: undefined | (() => void)
let directLabel: string | undefined
if (!isGeneralChannel) {
} else {
if (isGeneralChannel) {
directAction = onAddPeople
directLabel = 'Add people to team'
}
Expand Down
6 changes: 4 additions & 2 deletions shared/chat/conversation/info-panel/menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,12 @@ const InfoPanelMenuConnector = function InfoPanelMenuConnector(p: OwnProps) {
const routerNavigateAppend = C.Router2.navigateAppend
const canAddPeople = yourOperations.manageMembers
const onAddPeople = () => {
teamID &&
if (teamID) {
routerNavigateAppend({
name: 'teamAddToTeamFromWhere',
params: {wizard: makeAddMembersWizard(teamID)},
})
}
}
const chatNavigateAppend = ConvoState.useChatNavigateAppend()
const onBlockConv = () => {
Expand Down Expand Up @@ -294,13 +295,14 @@ const InfoPanelMenuConnector = function InfoPanelMenuConnector(p: OwnProps) {
onClick: onBlockConv,
title: 'Block',
} as const)
conversationIDKey &&
if (conversationIDKey) {
items.push({
icon: 'iconfont-folder-downloads',
iconIsVisible: false,
onClick: onArchive,
title: 'Backup conversation',
} as const)
}
} else {
if (hasChannelSection) {
items.push(channelHeader)
Expand Down
5 changes: 3 additions & 2 deletions shared/chat/conversation/input-area/location-popup.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,11 @@ const useWatchPosition = (
unsub = () => sub.remove()
} catch (_error) {
const error = _error as {message?: string}
logger.info('failed to get location: ' + error.message)
const errorMessage = String(error.message)
logger.info('failed to get location: ' + errorMessage)
setCommandStatusInfo({
actions: [T.RPCChat.UICommandStatusActionTyp.appsettings],
displayText: `Failed to access location. ${error.message}`,
displayText: `Failed to access location. ${errorMessage}`,
displayType: T.RPCChat.UICommandStatusDisplayTyp.error,
})
}
Expand Down
8 changes: 6 additions & 2 deletions shared/chat/conversation/input-area/normal/input.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,9 @@ const FileButton = function FileButton(p: {setHtmlInputRef: (i: HTMLInputElement
const pickFile = () => {
const paths = htmlInputRef.current?.files ? fileListToPaths(htmlInputRef.current.files) : undefined
const pathAndOutboxIDs = paths?.reduce<Array<{path: string}>>((arr, path: string) => {
path && arr.push({path})
if (path) {
arr.push({path})
}
return arr
}, [])
if (pathAndOutboxIDs?.length) {
Expand Down Expand Up @@ -493,7 +495,9 @@ const PlatformInput = function PlatformInput(p: Props) {
const checkEnterOnKeyDown = (e: React.KeyboardEvent) => {
if (e.key === 'Enter' && !(e.altKey || e.shiftKey || e.metaKey)) {
e.preventDefault()
inputRef.current && onSubmit(inputRef.current.value)
if (inputRef.current) {
onSubmit(inputRef.current.value)
}
}
}

Expand Down
8 changes: 4 additions & 4 deletions shared/chat/conversation/input-area/suggestors/channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ const getChannelSuggestions = (
const suggestions = (Chat.useChatState.getState().inboxLayout?.bigTeams ?? []).reduce<
Array<{channelname: string; teamname: string}>
>((arr, t) => {
t.state === T.RPCChat.UIInboxBigTeamRowTyp.channel &&
mutualTeams.has(t.channel.teamname) &&
if (t.state === T.RPCChat.UIInboxBigTeamRowTyp.channel && mutualTeams.has(t.channel.teamname)) {
arr.push({channelname: t.channel.channelname, teamname: t.channel.teamname})
}
return arr
}, [])

Expand All @@ -75,9 +75,9 @@ const getChannelSuggestions = (
const suggestions = (Chat.useChatState.getState().inboxLayout?.bigTeams ?? []).reduce<
Array<{channelname: string}>
>((arr, t) => {
t.state === T.RPCChat.UIInboxBigTeamRowTyp.channel &&
t.channel.teamname === teamname &&
if (t.state === T.RPCChat.UIInboxBigTeamRowTyp.channel && t.channel.teamname === teamname) {
arr.push({channelname: t.channel.channelname})
}
return arr
}, [])

Expand Down
6 changes: 4 additions & 2 deletions shared/chat/conversation/input-area/suggestors/commands.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const transformer = (
return Common.standardTransformer(`${prefix}${command.name}`, tData, preview)
}

const keyExtractor = (c: T.RPCChat.ConversationCommand) => c.name + c.username
const keyExtractor = (c: T.RPCChat.ConversationCommand) => c.name + String(c.username)

const getBotRestrictBlockMap = (
settings: ReadonlyMap<string, T.RPCChat.Keybase1.TeamBotSettings | undefined>,
Expand Down Expand Up @@ -55,7 +55,9 @@ const ItemRenderer = (p: Common.ItemRendererProps<CommandType>) => {
const botRestrictMap = getBotRestrictBlockMap(botSettings, s.id, [
...suggestBotCommands
.reduce((s, c) => {
c.username && s.add(c.username)
if (c.username) {
s.add(c.username)
}
return s
}, new Set<string>())
.values(),
Expand Down
4 changes: 3 additions & 1 deletion shared/chat/conversation/input-area/suggestors/common.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ export function List<T>(p: ListProps<T>) {

const onSubmit = () => {
const sel = items[selectedIndex]
sel && onSelected(sel, true)
if (sel) {
onSelected(sel, true)
}
return !!sel
}

Expand Down
8 changes: 6 additions & 2 deletions shared/chat/conversation/input-area/suggestors/users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,16 @@ const filterAndJoin = (
const getTeams = (layout?: T.RPCChat.UIInboxLayout) => {
const bigTeams =
layout?.bigTeams?.reduce<Array<string>>((arr, l) => {
l.state === T.RPCChat.UIInboxBigTeamRowTyp.label && arr.push(l.label.name)
if (l.state === T.RPCChat.UIInboxBigTeamRowTyp.label) {
arr.push(l.label.name)
}
return arr
}, []) ?? []
const smallTeams =
layout?.smallTeams?.reduce<Array<string>>((arr, l) => {
l.isTeam && arr.push(l.name)
if (l.isTeam) {
arr.push(l.name)
}
return arr
}, []) ?? []
return bigTeams.concat(smallTeams).map(teamname => ({channelname: '', teamname}))
Expand Down
10 changes: 7 additions & 3 deletions shared/chat/conversation/list-area/index.desktop.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,20 +133,22 @@ const useScrolling = (p: {

const [scrollDown] = React.useState(() => () => {
const list = listRef.current
list &&
if (list) {
adjustScrollAndIgnoreOnScroll(() => {
list.scrollTop += list.clientHeight
})
}
})

const [scrollUp] = React.useState(() => () => {
lockedToBottomRef.current = false
const list = listRef.current
list &&
if (list) {
adjustScrollAndIgnoreOnScroll(() => {
list.scrollTop -= list.clientHeight
checkForLoadMoreThrottled()
})
}
})

const scrollCheckRef = React.useRef<ReturnType<typeof setTimeout>>(undefined)
Expand Down Expand Up @@ -505,7 +507,9 @@ const ThreadWrapper = function ThreadWrapper() {
})

const tc = tempDiv.textContent
tc && copyToClipboard(tc)
if (tc) {
copyToClipboard(tc)
}
tempDiv.remove()
}
const {focusInput} = React.useContext(FocusContext)
Expand Down
2 changes: 1 addition & 1 deletion shared/chat/conversation/list-area/index.native.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ const ConversationList = function ConversationList() {
key={conversationIDKey}
testID="messageList"
onScrollToIndexFailed={noop}
// @ts-ignore LegendList/FlashList prop; ignored by FlatList
// @ts-expect-error LegendList/FlashList prop; ignored by FlatList
estimatedItemSize={72}
ListHeaderComponent={SpecialBottomMessage}
ListFooterComponent={SpecialTopMessage}
Expand Down
4 changes: 3 additions & 1 deletion shared/chat/conversation/messages/attachment/audio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const AudioAttachment = ({message}: {message: T.Chat.MessageAttachment}) => {
const progressLabel = Chat.messageAttachmentTransferStateToProgressLabel(message.transferState)
const hasProgress = messageAttachmentHasProgress(message)
const onShowInFinder = () => {
message.downloadPath && openLocalPathInSystemFileManagerDesktop(message.downloadPath)
if (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
4 changes: 3 additions & 1 deletion shared/chat/conversation/messages/attachment/file.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function FileContainer(p: OwnProps) {
)
}
const _onShowInFinder = () => {
downloadPath && openLocalPathInSystemFileManagerDesktop(downloadPath)
if (downloadPath) {
openLocalPathInSystemFileManagerDesktop(downloadPath)
}
}

const onDownload = () => {
Expand Down
4 changes: 3 additions & 1 deletion shared/chat/conversation/messages/attachment/shared.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,9 @@ export const TransferIcon = (p: {
}

const onFinder = () => {
downloadPath && openLocalPathInSystemFileManagerDesktop(downloadPath)
if (downloadPath) {
openLocalPathInSystemFileManagerDesktop(downloadPath)
}
}

switch (state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ const PopAttach = (ownProps: OwnProps) => {
const onShareAttachment = C.isMobile ? _onShareAttachment : undefined

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

Expand Down
Loading