Skip to content

Instantly share code, notes, and snippets.

@jbis9051
Last active December 2, 2019 20:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbis9051/e73930131f25d9043c4c12daf751a56c to your computer and use it in GitHub Desktop.
Save jbis9051/e73930131f25d9043c4c12daf751a56c to your computer and use it in GitHub Desktop.
function switchThread(convo) {
selectedConvo = convo;
document.querySelectorAll('.thread').forEach(el => {
if (el === convo.selector) {
el.setAttribute("selected", "")
} else {
el.removeAttribute("selected")
}
});
convo.conversation.getMessages();
convo.getTargetedMessages();
updateMessagesView();
scrollMessageNodeToMiddle(messagesView.querySelector('.target'));
contact_name.innerText = convo.conversation.getDisplayName();
}
// Conversation.js
getMessages(limit, offset) {
if (typeof limit !== "undefined") {
this.limit = limit;
this.offset = offset;
}
this.messages =
db.execute(`
SELECT *
FROM chat_message_join
INNER JOIN message ON chat_message_join.message_id = message.ROWID
WHERE chat_message_join.chat_id = ${this.chat.ROWID}
ORDER BY message.date DESC
LIMIT ${this.limit} OFFSET ${this.offset}
`)
.map(msg => new Message(msg)).filter(msg => msg.text().length > 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment