forked from Shiloh/remnantchat
feat: [closes #46] limit chat transcripts to 10,000 messages
This commit is contained in:
parent
6740d8da3d
commit
bd6f1d5090
@ -6,13 +6,15 @@ import { v4 as uuid } from 'uuid'
|
||||
import { ShellContext } from 'contexts/ShellContext'
|
||||
import { SettingsContext } from 'contexts/SettingsContext'
|
||||
import { PeerActions } from 'models/network'
|
||||
import { ReceivedMessage, UnsentMessage } from 'models/chat'
|
||||
import { ReceivedMessage, UnsentMessage, Message } from 'models/chat'
|
||||
import { funAnimalName } from 'fun-animal-names'
|
||||
import { getPeerName } from 'components/PeerNameDisplay'
|
||||
import { NotificationService } from 'services/Notification'
|
||||
import { Audio } from 'services/Audio'
|
||||
import { PeerRoom } from 'services/PeerRoom'
|
||||
|
||||
import { messageTranscriptSizeLimit } from 'config/messaging'
|
||||
|
||||
import { usePeerRoomAction } from './usePeerRoomAction'
|
||||
|
||||
interface UseRoomConfig {
|
||||
@ -30,13 +32,17 @@ export function useRoom(
|
||||
const shellContext = useContext(ShellContext)
|
||||
const settingsContext = useContext(SettingsContext)
|
||||
const [isMessageSending, setIsMessageSending] = useState(false)
|
||||
const [messageLog, setMessageLog] = useState<
|
||||
const [messageLog, _setMessageLog] = useState<
|
||||
Array<ReceivedMessage | UnsentMessage>
|
||||
>([])
|
||||
const [newMessageAudio] = useState(
|
||||
() => new Audio(process.env.PUBLIC_URL + '/sounds/new-message.aac')
|
||||
)
|
||||
|
||||
const setMessageLog = (messages: Message[]) => {
|
||||
_setMessageLog(messages.slice(-messageTranscriptSizeLimit))
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
peerRoom.leaveRoom()
|
||||
|
@ -1 +1,2 @@
|
||||
export const messageCharacterSizeLimit = 10_000
|
||||
export const messageTranscriptSizeLimit = 10_000
|
||||
|
Loading…
Reference in New Issue
Block a user