Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: New event store #251

Merged
merged 45 commits into from
Aug 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
233b3c0
Store events in room specific db
deepbluev7 Jul 1, 2020
79a2995
Persist event order
deepbluev7 Jul 4, 2020
c79205c
Use new timeline cache structure
deepbluev7 Jul 5, 2020
82eff09
Fetch event from db and use string_view where possible
deepbluev7 Jul 6, 2020
0da1a6d
Add relations and order without hidden events to db
deepbluev7 Jul 8, 2020
fe12e63
Fix parent undefined warning
deepbluev7 Jul 8, 2020
530c531
WIP: Event Store split out
deepbluev7 Jul 9, 2020
3421728
Fetch missing events
deepbluev7 Jul 9, 2020
da2f80d
Fix translation loading
deepbluev7 Jul 10, 2020
9479fcd
Initialize Profile later
deepbluev7 Jul 11, 2020
9ae7d0d
Readd pagination and fix redactions
deepbluev7 Jul 12, 2020
56ea89a
Reenable sending messages
deepbluev7 Jul 18, 2020
a5dda86
Fix encryption indicator
deepbluev7 Jul 18, 2020
36e4405
Fix flickering of encrypted messages when sending using new store
deepbluev7 Jul 18, 2020
046b3f4
Mark own events as read again after sending
deepbluev7 Jul 18, 2020
5695f00
Fix race condition between /messages and /sync
deepbluev7 Jul 18, 2020
8261446
Fix reply scrolling
deepbluev7 Jul 18, 2020
d467568
Close cursor we don't need and where we overwrite the contents
deepbluev7 Jul 18, 2020
6f2bc90
Fix reaction display
deepbluev7 Jul 19, 2020
19f2723
Fix reactions
deepbluev7 Jul 19, 2020
f23d733
Fix room joins
deepbluev7 Jul 20, 2020
147ae68
Don't send url, if we send an encrypted file
deepbluev7 Jul 23, 2020
b294430
Return to redacted messages instead of just storing the redaction
deepbluev7 Jul 25, 2020
4e7bd20
Reset fetch in progress when fetch failed
deepbluev7 Jul 25, 2020
fdcf91f
Fix binding loop and non integer text height
deepbluev7 Jul 25, 2020
cbb4356
Fix more non integer heights
deepbluev7 Jul 25, 2020
6f557c1
Optimize scrolling a little bit
deepbluev7 Jul 25, 2020
8bf2691
Make long press menu actually work
deepbluev7 Jul 26, 2020
28e7ea4
Bump mtxclient and use git dependency in flatpak
deepbluev7 Jul 26, 2020
a00b11d
Rename EventStore::event to get to remove ambiguity with QObject::event
deepbluev7 Jul 26, 2020
ade905c
Fix shadowing variable
deepbluev7 Jul 26, 2020
720bb16
Fix migration (hopefully)
deepbluev7 Jul 26, 2020
12090c0
Add workaround for duplicate syncs
deepbluev7 Jul 27, 2020
7f3d975
Fix double free by closing cursor at the right time
deepbluev7 Jul 30, 2020
dbaddb0
Further tweak text element
deepbluev7 Aug 6, 2020
1f9215a
Split error messages from event decryption
deepbluev7 Aug 6, 2020
7eb0c4e
Also request keys from own devices
deepbluev7 Aug 6, 2020
b972d82
Try to fix issue of pagination interfering with limited: true
deepbluev7 Aug 7, 2020
1e9efa3
Try to fix variable timestamp width
deepbluev7 Aug 7, 2020
14a0aac
Add /clear-timeline command
deepbluev7 Aug 9, 2020
de7ec4d
Merge remote-tracking branch 'origin/master' into new-event-store
deepbluev7 Aug 17, 2020
7f71081
Hide CallCandidates again in new store
deepbluev7 Aug 17, 2020
d6bc05f
Bump mtxclient
deepbluev7 Aug 17, 2020
9f79b85
Speedup db a bit, but loose some crash resiliency
deepbluev7 Aug 25, 2020
3df4bde
Add some log messages, that migrations are in progress
deepbluev7 Aug 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ set(SRC_FILES


# Timeline
src/timeline/ReactionsModel.cpp
src/timeline/EventStore.cpp
src/timeline/Reaction.cpp
src/timeline/TimelineViewManager.cpp
src/timeline/TimelineModel.cpp
src/timeline/DelegateChooser.cpp
Expand Down Expand Up @@ -340,7 +341,7 @@ if(USE_BUNDLED_MTXCLIENT)
FetchContent_Declare(
MatrixClient
GIT_REPOSITORY https://github.com/Nheko-Reborn/mtxclient.git
GIT_TAG 744018c86a8094acbda9821d6d7b5a890d4aac47
GIT_TAG d8666a3f1a5b709b78ccea2b545d540a8cb502ca
)
FetchContent_MakeAvailable(MatrixClient)
else()
Expand Down Expand Up @@ -463,7 +464,8 @@ qt5_wrap_cpp(MOC_HEADERS
src/emoji/Provider.h

# Timeline
src/timeline/ReactionsModel.h
src/timeline/EventStore.h
src/timeline/Reaction.h
src/timeline/TimelineViewManager.h
src/timeline/TimelineModel.h
src/timeline/DelegateChooser.h
Expand Down
2 changes: 1 addition & 1 deletion io.github.NhekoReborn.Nheko.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
"name": "mtxclient",
"sources": [
{
"commit": "744018c86a8094acbda9821d6d7b5a890d4aac47",
"commit": "d8666a3f1a5b709b78ccea2b545d540a8cb502ca",
"type": "git",
"url": "https://github.com/Nheko-Reborn/mtxclient.git"
}
Expand Down
1 change: 1 addition & 0 deletions resources/qml/MatrixText.qml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ TextEdit {
readOnly: true
wrapMode: Text.Wrap
selectByMouse: true
activeFocusOnPress: false
color: colors.text

onLinkActivated: {
Expand Down
18 changes: 9 additions & 9 deletions resources/qml/Reactions.qml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Flow {
implicitHeight: contentItem.childrenRect.height

ToolTip.visible: hovered
ToolTip.text: model.users
ToolTip.text: modelData.users

onClicked: {
console.debug("Picked " + model.key + "in response to " + reactionFlow.eventId + " in room " + reactionFlow.roomId + ". selfReactedEvent: " + model.selfReactedEvent)
timelineManager.reactToMessage(reactionFlow.roomId, reactionFlow.eventId, model.key, model.selfReactedEvent)
console.debug("Picked " + modelData.key + "in response to " + reactionFlow.eventId + " in room " + reactionFlow.roomId + ". selfReactedEvent: " + modelData.selfReactedEvent)
timelineManager.queueReactionMessage(reactionFlow.eventId, modelData.key)
}


Expand All @@ -49,13 +49,13 @@ Flow {
font.family: settings.emojiFont
elide: Text.ElideRight
elideWidth: 150
text: model.key
text: modelData.key
}

Text {
anchors.baseline: reactionCounter.baseline
id: reactionText
text: textMetrics.elidedText + (textMetrics.elidedText == model.key ? "" : "…")
text: textMetrics.elidedText + (textMetrics.elidedText == modelData.key ? "" : "…")
font.family: settings.emojiFont
color: reaction.hovered ? colors.highlight : colors.text
maximumLineCount: 1
Expand All @@ -65,13 +65,13 @@ Flow {
id: divider
height: Math.floor(reactionCounter.implicitHeight * 1.4)
width: 1
color: (reaction.hovered || model.selfReactedEvent !== '') ? colors.highlight : colors.text
color: (reaction.hovered || modelData.selfReactedEvent !== '') ? colors.highlight : colors.text
}

Text {
anchors.verticalCenter: divider.verticalCenter
id: reactionCounter
text: model.counter
text: modelData.count
font: reaction.font
color: reaction.hovered ? colors.highlight : colors.text
}
Expand All @@ -82,8 +82,8 @@ Flow {

implicitWidth: reaction.implicitWidth
implicitHeight: reaction.implicitHeight
border.color: (reaction.hovered || model.selfReactedEvent !== '') ? colors.highlight : colors.text
color: model.selfReactedEvent !== '' ? Qt.hsla(highlightHue, highlightSat, highlightLight, 0.20) : colors.base
border.color: (reaction.hovered || modelData.selfReactedEvent !== '') ? colors.highlight : colors.text
color: modelData.selfReactedEvent !== '' ? Qt.hsla(highlightHue, highlightSat, highlightLight, 0.20) : colors.base
border.width: 1
radius: reaction.height / 2.0
}
Expand Down
2 changes: 1 addition & 1 deletion resources/qml/ScrollHelper.qml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,6 @@ MouseArea {
//How long the scrollbar will remain visible
interval: 500
// Hide the scrollbars
onTriggered: flickable.cancelFlick();
onTriggered: { flickable.cancelFlick(); flickable.movementEnded(); }
}
}
33 changes: 18 additions & 15 deletions resources/qml/TimelineRow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,25 @@ import im.nheko 1.0
import "./delegates"
import "./emoji"

MouseArea {
Item {
anchors.left: parent.left
anchors.right: parent.right
height: row.height
propagateComposedEvents: true
preventStealing: true
hoverEnabled: true

acceptedButtons: Qt.LeftButton | Qt.RightButton
onClicked: {
if (mouse.button === Qt.RightButton)
messageContextMenu.show(model.id, model.type, model.isEncrypted, row)
}
onPressAndHold: {
if (mouse.source === Qt.MouseEventNotSynthesized)
messageContextMenu.show(model.id, model.type, model.isEncrypted, row)

MouseArea {
anchors.fill: parent
propagateComposedEvents: true
preventStealing: true
hoverEnabled: true

acceptedButtons: Qt.AllButtons
onClicked: {
if (mouse.button === Qt.RightButton)
messageContextMenu.show(model.id, model.type, model.isEncrypted, row)
}
onPressAndHold: {
messageContextMenu.show(model.id, model.type, model.isEncrypted, row, mapToItem(timelineRoot, mouse.x, mouse.y))
}
}
Rectangle {
color: (settings.messageHoverHighlight && parent.containsMouse) ? colors.base : "transparent"
Expand All @@ -45,7 +48,7 @@ MouseArea {
// fancy reply, if this is a reply
Reply {
visible: model.replyTo
modelData: chat.model.getDump(model.replyTo)
modelData: chat.model.getDump(model.replyTo, model.id)
userColor: timelineManager.userColor(modelData.userId, colors.window)
}

Expand Down Expand Up @@ -90,7 +93,6 @@ MouseArea {
ToolTip.visible: hovered
ToolTip.text: qsTr("React")
emojiPicker: emojiPopup
room_id: model.roomId
event_id: model.id
}
ImageButton {
Expand Down Expand Up @@ -128,6 +130,7 @@ MouseArea {
Label {
Layout.alignment: Qt.AlignRight | Qt.AlignTop
text: model.timestamp.toLocaleTimeString("HH:mm")
width: Math.max(implicitWidth, text.length*fontMetrics.maximumCharacterWidth)
color: inactiveColors.text

MouseArea{
Expand Down
68 changes: 36 additions & 32 deletions resources/qml/TimelineView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import "./delegates"
import "./emoji"

Page {
id: timelineRoot

property var colors: currentActivePalette
property var systemInactive: SystemPalette { colorGroup: SystemPalette.Disabled }
property var inactiveColors: currentInactivePalette ? currentInactivePalette : systemInactive
Expand All @@ -25,34 +27,39 @@ Page {
id: fontMetrics
}

EmojiPicker {
id: emojiPopup
width: 7 * 52 + 20
height: 6 * 52
colors: palette
model: EmojiProxyModel {
category: EmojiCategory.People
sourceModel: EmojiModel {}
}
}
EmojiPicker {
id: emojiPopup
width: 7 * 52 + 20
height: 6 * 52
colors: palette
model: EmojiProxyModel {
category: EmojiCategory.People
sourceModel: EmojiModel {}
}
}

Menu {
id: messageContextMenu
modal: true

function show(eventId_, eventType_, isEncrypted_, showAt) {
function show(eventId_, eventType_, isEncrypted_, showAt_, position) {
eventId = eventId_
eventType = eventType_
isEncrypted = isEncrypted_
popup(showAt)

if (position)
popup(position, showAt_)
else
popup(showAt_)
}

property string eventId
property int eventType
property bool isEncrypted

MenuItem {
text: qsTr("React")
onClicked: chat.model.reactAction(messageContextMenu.eventId)
onClicked: emojiPopup.show(messageContextMenu.parent, messageContextMenu.eventId)
}
MenuItem {
text: qsTr("Reply")
Expand Down Expand Up @@ -87,8 +94,6 @@ Page {
}
}

id: timelineRoot

Rectangle {
anchors.fill: parent
color: colors.window
Expand All @@ -113,7 +118,7 @@ Page {
ListView {
id: chat

visible: timelineManager.timeline != null
visible: !!timelineManager.timeline

cacheBuffer: 400

Expand Down Expand Up @@ -181,7 +186,7 @@ Page {

id: wrapper
property Item section
anchors.horizontalCenter: parent.horizontalCenter
anchors.horizontalCenter: parent ? parent.horizontalCenter : undefined
width: chat.delegateMaxWidth
height: section ? section.height + timelinerow.height : timelinerow.height
color: "transparent"
Expand All @@ -205,14 +210,13 @@ Page {
}
}

Binding {
target: chat.model
property: "currentIndex"
when: y + height + 2 * chat.spacing > chat.contentY + chat.height && y < chat.contentY + chat.height
value: index
delayed: true
Connections {
target: chat
function onMovementEnded() {
if (y + height + 2 * chat.spacing > chat.contentY + chat.height && y < chat.contentY + chat.height)
chat.model.currentIndex = index;
}
}

}

section {
Expand Down Expand Up @@ -296,13 +300,13 @@ Page {
}
}

footer: BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
running: chat.model && chat.model.paginationInProgress
height: 50
width: 50
z: 3
}
footer: BusyIndicator {
anchors.horizontalCenter: parent.horizontalCenter
running: chat.model && chat.model.paginationInProgress
height: 50
width: 50
z: 3
}
}

Rectangle {
Expand Down Expand Up @@ -354,7 +358,7 @@ Page {
anchors.rightMargin: 20
anchors.bottom: parent.bottom

modelData: chat.model ? chat.model.getDump(chat.model.reply) : {}
modelData: chat.model ? chat.model.getDump(chat.model.reply, chat.model.id) : {}
userColor: timelineManager.userColor(modelData.userId, colors.window)
}

Expand Down
4 changes: 2 additions & 2 deletions resources/qml/delegates/ImageMessage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ Item {
property double divisor: model.isReply ? 4 : 2
property bool tooHigh: tempHeight > timelineRoot.height / divisor

height: tooHigh ? timelineRoot.height / divisor : tempHeight
width: tooHigh ? (timelineRoot.height / divisor) / model.data.proportionalHeight : tempWidth
height: Math.round(tooHigh ? timelineRoot.height / divisor : tempHeight)
width: Math.round(tooHigh ? (timelineRoot.height / divisor) / model.data.proportionalHeight : tempWidth)

Image {
id: blurhash
Expand Down
12 changes: 12 additions & 0 deletions resources/qml/delegates/MessageDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,12 @@ Item {
text: qsTr("redacted")
}
}
DelegateChoice {
roleValue: MtxEvent.Redaction
Pill {
text: qsTr("redacted")
}
}
DelegateChoice {
roleValue: MtxEvent.Encryption
Pill {
Expand Down Expand Up @@ -108,6 +114,12 @@ Item {
text: qsTr("%1 ended the call.").arg(model.data.userName)
}
}
DelegateChoice {
roleValue: MtxEvent.CallCandidates
NoticeMessage {
text: qsTr("Negotiating call...")
}
}
DelegateChoice {
// TODO: make a more complex formatter for the power levels.
roleValue: MtxEvent.PowerLevels
Expand Down
2 changes: 1 addition & 1 deletion resources/qml/delegates/PlayableMediaMessage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Rectangle {
id: bg
radius: 10
color: colors.dark
height: content.height + 24
height: Math.round(content.height + 24)
width: parent ? parent.width : undefined

Column {
Expand Down
2 changes: 1 addition & 1 deletion resources/qml/delegates/TextMessage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ MatrixText {
property string formatted: model.data.formattedBody
text: "<style type=\"text/css\">a { color:"+colors.link+";}</style>" + formatted.replace("<pre>", "<pre style='white-space: pre-wrap'>")
width: parent ? parent.width : undefined
height: isReply ? Math.min(chat.height / 8, implicitHeight) : undefined
height: isReply ? Math.round(Math.min(timelineRoot.height / 8, implicitHeight)) : undefined
clip: true
font.pointSize: (settings.enlargeEmojiOnlyMessages && model.data.isOnlyEmoji > 0 && model.data.isOnlyEmoji < 4) ? settings.fontSize * 3 : settings.fontSize
}
3 changes: 1 addition & 2 deletions resources/qml/emoji/EmojiButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ import "../"
ImageButton {
property var colors: currentActivePalette
property var emojiPicker
property string room_id
property string event_id

image: ":/icons/icons/ui/smile.png"
id: emojiButton
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, room_id, event_id)
onClicked: emojiPicker.visible ? emojiPicker.close() : emojiPicker.show(emojiButton, event_id)

}
Loading