mirror of
https://gitlab.com/MrFry/qmining-page
synced 2025-04-01 20:23:44 +02:00
Empty msg fix, unread after opening msg fix
This commit is contained in:
parent
02954e0d01
commit
98164ff4fa
2 changed files with 13 additions and 15 deletions
|
@ -1,11 +1,12 @@
|
|||
import React from 'react'
|
||||
import Head from 'next/head'
|
||||
import io from 'socket.io-client'
|
||||
|
||||
import linkifyString from 'linkify-string'
|
||||
|
||||
import constants from '../constants.json'
|
||||
import LoadingIndicator from '../components/LoadingIndicator'
|
||||
import { queryClient } from '../pages/_app'
|
||||
|
||||
import styles from './chat.module.css'
|
||||
|
||||
const byDate = (a, b) => {
|
||||
|
@ -277,7 +278,8 @@ export default class Chat extends React.Component {
|
|||
sendMsg(currMsg, type) {
|
||||
this.chatInputRef.current.style.height = '40px'
|
||||
const { msgs, selectedUser, user } = this.state
|
||||
if (!currMsg) {
|
||||
|
||||
if (!currMsg || !currMsg.trim()) {
|
||||
return
|
||||
}
|
||||
if (this.socket && selectedUser) {
|
||||
|
@ -386,6 +388,10 @@ export default class Chat extends React.Component {
|
|||
} catch (e) {
|
||||
// e
|
||||
}
|
||||
queryClient.setQueryData('infos', (oldData) => ({
|
||||
...oldData,
|
||||
unreads: oldData.unreads.filter((x) => x !== val),
|
||||
}))
|
||||
}
|
||||
|
||||
renderChatInput() {
|
||||
|
@ -649,7 +655,7 @@ export default class Chat extends React.Component {
|
|||
)
|
||||
}
|
||||
|
||||
renderSidebarEntryes() {
|
||||
renderSidebarEntries() {
|
||||
const { msgs } = this.state
|
||||
const sorted = Object.keys(msgs).sort((a, b) => {
|
||||
return msgs[b].lastMessage.date - msgs[a].lastMessage.date
|
||||
|
@ -692,7 +698,7 @@ export default class Chat extends React.Component {
|
|||
<div>Új beszélgetés</div>
|
||||
</div>
|
||||
<hr />
|
||||
{msgs && this.renderSidebarEntryes()}
|
||||
{msgs && this.renderSidebarEntries()}
|
||||
</div>
|
||||
<span className={styles.spacer} />
|
||||
<div></div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue