Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import * as marked from 'marked'
import { emojify } from 'node-emoji'
import { store } from '..'
import { MAX_LENGTH_USERNAME } from '../components/views/SettingsView'
import { addGlobalChatMessage, clearGlobalChatMessages } from '../actions/chat'
import { ChatMessage } from '../../models/State.model'
const { sanitize } = require('dompurify').default
export function addGlobalMessage (message: string, username: string, isTrusted = false) {
const date = new Date()
const sanitizedMessage = isTrusted
? sanitize(emojify(marked(message)))
: emojify(message)
const chatMessage: ChatMessage = {
key: date.getUTCMilliseconds(),
time: `${String(date.getHours()).padStart(2, '00')}:${String(date.getMinutes()).padStart(2, '00')}:${String(date.getSeconds()).padStart(2, '00')}`,
message: sanitizedMessage,
username: sanitize(username).substr(0, MAX_LENGTH_USERNAME),
isTrusted
}
store.dispatch(addGlobalChatMessage(chatMessage))
}
import * as React from 'react'
import { Dispatch } from 'redux'
import { connect } from 'react-redux'
import { shell } from 'electron'
import * as marked from 'marked'
import { emojify } from 'node-emoji'
import { connector } from '../..'
import { SMMButton } from '../buttons/SMMButton'
import { WarningPanel } from '../panels/WarningPanel'
import { disconnect, setConnectionError } from '../../actions/connection'
import { State } from '../../../models/State.model'
import { Server } from '../../../models/Server.model'
import { IPlayer, GameModeType } from '../../../../proto/ServerClientMessage'
const { sanitize } = require('dompurify').default
interface ServerPanelProps {
dispatch: Dispatch
server: Server
username: string
characterId: number
connectionError: string
onConnect?: () => void
isConnected?: boolean
}
interface ServerPanelState {
display: boolean
displayDescription: boolean
warning: string
}