mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-18 20:08:11 +00:00
54 lines
1.2 KiB
JavaScript
54 lines
1.2 KiB
JavaScript
// =============================================================================
|
|
// `Chat.qml` Logic.
|
|
// =============================================================================
|
|
|
|
function initView () {
|
|
chat.tryToLoadMoreEntries = false
|
|
chat.bindToEnd = true
|
|
}
|
|
|
|
function loadMoreEntries () {
|
|
if (chat.atYBeginning && !chat.tryToLoadMoreEntries) {
|
|
chat.tryToLoadMoreEntries = true
|
|
chat.positionViewAtBeginning()
|
|
proxyModel.loadMoreEntries()
|
|
}
|
|
}
|
|
|
|
function getComponentFromEntry (chatEntry) {
|
|
if (chatEntry.fileName) {
|
|
return 'FileMessage.qml'
|
|
}
|
|
|
|
if (chatEntry.type === ChatModel.CallEntry) {
|
|
return 'Event.qml'
|
|
}
|
|
|
|
return chatEntry.isOutgoing ? 'OutgoingMessage.qml' : 'IncomingMessage.qml'
|
|
}
|
|
|
|
function handleFilesDropped (files) {
|
|
chat.bindToEnd = true
|
|
files.forEach(proxyModel.sendFileMessage)
|
|
}
|
|
|
|
function handleMoreEntriesLoaded (n) {
|
|
chat.positionViewAtIndex(n - 1, ListView.Beginning)
|
|
chat.tryToLoadMoreEntries = false
|
|
}
|
|
|
|
function handleMovementEnded () {
|
|
if (chat.atYEnd) {
|
|
chat.bindToEnd = true
|
|
}
|
|
}
|
|
|
|
function handleMovementStarted () {
|
|
chat.bindToEnd = false
|
|
}
|
|
|
|
function sendMessage (text) {
|
|
textArea.text = ''
|
|
chat.bindToEnd = true
|
|
proxyModel.sendMessage(text)
|
|
}
|