mirror of
https://git.jami.net/savoirfairelinux/jami-client-qt.git
synced 2025-08-21 07:05:59 +02:00
chatview: fix message styling and timestamps after removing a msg
https://git.jami.net/savoirfairelinux/jami-daemon/-/issues/316 Change-Id: I26cd21f91571021de960f83f189d7323336fa41b
This commit is contained in:
parent
9195cb0bc5
commit
4245c13a42
1 changed files with 44 additions and 24 deletions
|
@ -66,24 +66,24 @@ JamiListView {
|
||||||
var pItemIndex = itemIndex - 1
|
var pItemIndex = itemIndex - 1
|
||||||
var nItem = root.itemAtIndex(itemIndex + 1)
|
var nItem = root.itemAtIndex(itemIndex + 1)
|
||||||
var nItemIndex = itemIndex + 1
|
var nItemIndex = itemIndex + 1
|
||||||
//Middle insertion
|
// middle insertion
|
||||||
if (pItem && nItem) {
|
if (pItem && nItem) {
|
||||||
computeTimestampVisibility(item, itemIndex, nItem, nItemIndex)
|
computeTimestampVisibility(item, itemIndex, nItem, nItemIndex)
|
||||||
computeSequencing(nItemIndex, nItem, root.itemAtIndex(itemIndex + 2), item)
|
computeSequencing(item, nItem, root.itemAtIndex(itemIndex + 2))
|
||||||
}
|
}
|
||||||
// top buffer insertion = scroll up
|
// top buffer insertion = scroll up
|
||||||
if (pItem && !nItem) {
|
if (pItem && !nItem) {
|
||||||
computeTimestampVisibility(item, itemIndex, pItem, pItemIndex)
|
computeTimestampVisibility(item, itemIndex, pItem, pItemIndex)
|
||||||
computeSequencing(pItemIndex, pItem, item, root.itemAtIndex(itemIndex - 2))
|
computeSequencing(root.itemAtIndex(itemIndex - 2), pItem, item)
|
||||||
}
|
}
|
||||||
// bottom buffer insertion = scroll down
|
// bottom buffer insertion = scroll down
|
||||||
if (!pItem && nItem) {
|
if (!pItem && nItem) {
|
||||||
computeTimestampVisibility(item, itemIndex, nItem, nItemIndex)
|
computeTimestampVisibility(item, itemIndex, nItem, nItemIndex)
|
||||||
computeSequencing(nItemIndex, nItem, root.itemAtIndex(itemIndex + 2), item)
|
computeSequencing(item, nItem, root.itemAtIndex(itemIndex + 2))
|
||||||
}
|
}
|
||||||
// index 0 insertion = new message
|
// index 0 insertion = new message
|
||||||
if (itemIndex === 0) {
|
if (itemIndex === 0) {
|
||||||
Qt.callLater(computeSequencing, itemIndex, item, root.itemAtIndex(itemIndex + 1), null)
|
Qt.callLater(computeSequencing, null, item, root.itemAtIndex(itemIndex + 1))
|
||||||
if (!computeTimestampVisibility(item, itemIndex, nItem, nItemIndex)) {
|
if (!computeTimestampVisibility(item, itemIndex, nItem, nItemIndex)) {
|
||||||
Qt.callLater(computeChatview, item, itemIndex)
|
Qt.callLater(computeChatview, item, itemIndex)
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ JamiListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function computeSequencing(index, item, nItem, pItem) {
|
function computeSequencing(pItem, item, nItem) {
|
||||||
if (root === undefined || !item)
|
if (root === undefined || !item)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -104,8 +104,7 @@ JamiListView {
|
||||||
else {
|
else {
|
||||||
if (item.showTime) {
|
if (item.showTime) {
|
||||||
return true
|
return true
|
||||||
}
|
} else if (nItem.author !== item.author) {
|
||||||
if (nItem.author !== item.author) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,8 +116,7 @@ JamiListView {
|
||||||
else {
|
else {
|
||||||
if (pItem.showTime) {
|
if (pItem.showTime) {
|
||||||
return true
|
return true
|
||||||
}
|
} else if (pItem.author !== item.author) {
|
||||||
if (pItem.author !== item.author) {
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -184,7 +182,29 @@ JamiListView {
|
||||||
boundsBehavior: Flickable.StopAtBounds
|
boundsBehavior: Flickable.StopAtBounds
|
||||||
currentIndex: -1
|
currentIndex: -1
|
||||||
|
|
||||||
|
// This connection to dataChanged resolves the styling for
|
||||||
|
// messages before and after an erased message.
|
||||||
|
Connections {
|
||||||
|
target: MessagesAdapter.messageListModel
|
||||||
|
function onDataChanged(tl, br, roles) {
|
||||||
|
if (!(roles.includes(MessageList.Body) &&
|
||||||
|
roles.includes(MessageList.PreviousBodies))) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const staleIndex = proxyModel.mapFromSource(tl).row
|
||||||
|
var pItem = root.itemAtIndex(staleIndex - 1)
|
||||||
|
var nItem = root.itemAtIndex(staleIndex + 1)
|
||||||
|
var ppItem = root.itemAtIndex(staleIndex + 2)
|
||||||
|
var nnItem = root.itemAtIndex(staleIndex + 2)
|
||||||
|
computeTimestampVisibility(ppItem, staleIndex - 2, pItem, staleIndex - 1)
|
||||||
|
computeSequencing(ppItem, pItem, nItem)
|
||||||
|
computeTimestampVisibility(nItem, staleIndex + 1, nnItem, staleIndex + 2)
|
||||||
|
computeSequencing(pItem, nItem, nnItem)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
model: SortFilterProxyModel {
|
model: SortFilterProxyModel {
|
||||||
|
id: proxyModel
|
||||||
// There doesn't seem to a subscription to property change
|
// There doesn't seem to a subscription to property change
|
||||||
// events in the expression for sourceModel. This was originally
|
// events in the expression for sourceModel. This was originally
|
||||||
// masked behind an unchanging QSortFilterProxyModel object that
|
// masked behind an unchanging QSortFilterProxyModel object that
|
||||||
|
|
Loading…
Add table
Reference in a new issue