Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_chatList (showArchivedChats) {
if (!this._dc) return []
const listFlags = showArchivedChats ? C.DC_GCL_ARCHIVED_ONLY : 0
const list = this._dc.getChatList(listFlags, this._query)
const listCount = list.getCount()
const chatList = []
for (let i = 0; i < listCount; i++) {
const chatId = list.getChatId(i)
const chat = this._getChatById(chatId)
if (!chat) continue
if (chat.id === C.DC_CHAT_ID_DEADDROP) {
const messageId = list.getMessageId(i)
chat.deaddrop = this._deadDropMessage(messageId)
}
// This is NOT the Chat Oject, it's a smaller version for use as ChatListItem in the ChatList
chatList.push({
id: chat.id,
summary: list.getSummary(i).toJson(),
name: chat.name,
deaddrop: chat.deaddrop,
freshMessageCounter: chat.freshMessageCounter,
profileImage: chat.profileImage,
color: chat.color,
isVerified: chat.isVerified,
isGroup: chat.isGroup
})
selectChat (chatId) {
this._controller._selectedChatId = chatId
const chat = this.getFullChatById(chatId, true)
if (!chat) {
log.debug(`Error: selected chat not found: ${chatId}`)
return null
}
if (chat.id !== C.DC_CHAT_ID_DEADDROP && chat.freshMessageCounter > 0) {
this._dc.markNoticedChat(chat.id)
chat.freshMessageCounter = 0
const messagIds = this._controller.messageList.getMessageIds(chatId)
log.debug('markSeenMessages', messagIds)
// TODO: move mark seen logic to frontend
this._dc.markSeenMessages(messagIds)
app.setBadgeCount(this._getGeneralFreshMessageCounter())
}
return chat
}
const onClickContactRequest = () => openDialog('DeadDrop', { deaddrop: message })
const onClickSetupMessage = () => openDialog('EnterAutocryptSetupMessage', { message })
props = { ...props, onClickSetupMessage, onClickContactRequest }
message.onForward = () => openDialog('ForwardMessage', { message })
let body
if (message.msg.isSetupmessage) {
body = (
<div>
</div>
)
} else if (message.msg.chatId === C.DC_CHAT_ID_DEADDROP) {
body = (
<div>
</div>
)
} else {
body =
}
return <li>{body}</li>
})
profileImage: chat.profileImage,
archived: chat.archived,
subtitle: chat.subtitle,
type: chat.type,
isUnpromoted: chat.isUnpromoted,
isSelfTalk: chat.isSelfTalk,
contacts: this._dc.getChatContacts(chatId).map(id => this._dc.getContact(id).toJson()),
totalMessages: messageIds.length,
messages: this._messagesToRender(messageIds),
color: this._integerToHexColor(chat.color),
summary: undefined,
freshMessageCounter: this._dc.getFreshMessageCount(chatId),
isGroup: isGroupChat(chat),
isDeaddrop: chatId === C.DC_CHAT_ID_DEADDROP,
draft: chat.draft
}
}
contactRequests () {
this.selectChat(C.DC_CHAT_ID_DEADDROP)
}
const onContactRequests = () => chatStoreDispatch({ type: 'SELECT_CHAT', payload: C.DC_CHAT_ID_DEADDROP })
const logout = () => ipcRenderer.send('logout')
const ChatListItem = React.memo(props => {
const { chatListItem, onClick } = props
if (chatListItem === null) return null
if (typeof chatListItem === 'undefined') return
if (chatListItem.id === C.DC_CHAT_ID_DEADDROP) return
if (chatListItem.id === C.DC_CHAT_ID_ARCHIVED_LINK) return
return
}, (prevProps, nextProps) => {
const shouldRerender = prevProps.chatListItem !== nextProps.chatListItem || prevProps.isSelected !== nextProps.isSelected