Skip to content

Commit

Permalink
fix(regression): wasn't possible to open chat on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Jan 4, 2024
1 parent 28a40c6 commit 64bbb6e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/menus/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { f3Keybinds } from '../controls'
import { showOptionsModal } from '../react/SelectOption'

const { LitElement, html, css, unsafeCSS } = require('lit')
const { showModal, miscUiState } = require('../globalState')
const { showModal, miscUiState, activeModalStack, hideCurrentModal } = require('../globalState')
const { options, watchValue } = require('../optionsStorage')
const { getGamemodeNumber } = require('../utils')
const { isMobile } = require('./components/common')
Expand Down Expand Up @@ -231,7 +231,11 @@ class Hud extends LitElement {
}}>F3</div>
<div class="chat-btn" @pointerdown=${(e) => {
e.stopPropagation()
this.shadowRoot.querySelector('#chat').enableChat()
if (activeModalStack.at(-1)?.reactType === 'chat') {
hideCurrentModal()
} else {
showModal({ reactType: 'chat' })
}
}}></div>
<div class="pause-btn" @pointerdown=${(e) => {
e.stopPropagation()
Expand Down
7 changes: 6 additions & 1 deletion src/react/ChatContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { isCypress } from '../standaloneUtils'
import { MessageFormatPart } from '../botUtils'
import { MessagePart } from './MessageFormatted'
import './ChatContainer.css'
import { useUsingTouch } from '@dimaka/interface'

export type Message = {
parts: MessageFormatPart[],
Expand Down Expand Up @@ -51,6 +52,8 @@ export const fadeMessage = (message: Message, initialTimeout: boolean, requestUp
}

export default ({ messages, touch, opacity, fetchCompletionItems, opened, interceptMessage, onClose }: Props) => {
const usingTouch = useUsingTouch()

const [sendHistory, _setSendHistory] = useState(JSON.parse(window.sessionStorage.chatHistory || '[]'))

const [completePadText, setCompletePadText] = useState('')
Expand Down Expand Up @@ -114,7 +117,9 @@ export default ({ messages, touch, opacity, fetchCompletionItems, opened, interc
chatHistoryPos.current = messages.length
updateInputValue(initialChatOpenValue.value)
initialChatOpenValue.value = ''
chatInput.current.focus()
if (!usingTouch) {
chatInput.current.focus()
}
}
if (!opened) {
chatMessages.current.scrollTop = chatMessages.current.scrollHeight
Expand Down

0 comments on commit 64bbb6e

Please sign in to comment.