Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Konheko
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nheko Reborn
Konheko
Commits
e5e90fc9
Commit
e5e90fc9
authored
5 years ago
by
Nicolas Werner
Browse files
Options
Downloads
Patches
Plain Diff
Implement sending read notifications
parent
365efaa5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
qml/pages/ChatPage.qml
+19
-0
19 additions, 0 deletions
qml/pages/ChatPage.qml
src/models/roommodel.cpp
+15
-2
15 additions, 2 deletions
src/models/roommodel.cpp
src/models/roommodel.h
+1
-0
1 addition, 0 deletions
src/models/roommodel.h
with
35 additions
and
2 deletions
qml/pages/ChatPage.qml
+
19
−
0
View file @
e5e90fc9
...
...
@@ -63,12 +63,31 @@ Page {
console
.
log
(
"
at end
"
)
atEnd
=
true
}
var
lastIndex
=
maxIndex
for
(
var
child
in
chatView
.
contentItem
.
children
)
{
if
(
chatView
.
contentItem
.
children
[
child
].
isFullyVisible
&&
chatView
.
contentItem
.
children
[
child
].
index
>
maxIndex
)
lastIndex
=
chatView
.
contentItem
.
children
[
child
].
index
;
}
if
(
lastIndex
>
maxIndex
)
{
maxIndex
=
lastIndex
}
}
property
int
maxIndex
:
-
1
onMaxIndexChanged
:
{
console
.
log
(
"
max index:
"
+
maxIndex
)
room
.
markRead
(
maxIndex
)
}
delegate
:
ListItem
{
id
:
messageItem
contentHeight
:
loader
.
item
.
height
property
int
yoff
:
Math
.
round
(
messageItem
.
y
-
chatView
.
contentY
-
1
)
property
bool
isFullyVisible
:
yoff
+
messageItem
.
height
<
chatView
.
height
property
int
index
:
model
.
index
Loader
{
id
:
loader
source
:
switch
(
model
.
Type
)
{
...
...
This diff is collapsed.
Click to expand it.
src/models/roommodel.cpp
+
15
−
2
View file @
e5e90fc9
...
...
@@ -75,8 +75,8 @@ template <class T> auto eventUserId(const mtx::events::RoomEvent<T> &e) -> std::
template
<
class
T
>
auto
eventTimestamp
(
const
mtx
::
events
::
Event
<
T
>
&
e
)
->
uint64_t
{
return
0
;
}
template
<
class
T
>
auto
eventTimestamp
(
const
mtx
::
events
::
RoomEvent
<
T
>
&
e
)
->
uint64_t
{
return
e
.
origin_server_ts
;
}
template
<
class
T
>
auto
eventEventId
(
const
mtx
::
events
::
Event
<
T
>
&
e
)
->
std
::
string
{
return
""
;
}
template
<
class
T
>
auto
eventEventId
(
const
mtx
::
events
::
State
Event
<
T
>
&
e
)
->
std
::
string
{
return
e
.
event_id
;
}
//
template <class T> auto eventEventId(const mtx::events::Event<T> &e) -> std::string { return ""; }
template
<
class
T
>
auto
eventEventId
(
const
mtx
::
events
::
Room
Event
<
T
>
&
e
)
->
std
::
string
{
return
e
.
event_id
;
}
template
<
class
T
>
::
EventType
::
Type
toRoomEventType
(
const
Event
<
T
>
&
e
)
{
using
mtx
::
events
::
EventType
;
...
...
@@ -497,3 +497,16 @@ QColor Room::userColor(QString id, QColor background) {
return
inputColor
;
}
void
Room
::
markRead
(
int
index
)
{
if
(
index
<
0
||
index
>=
events
.
size
())
return
;
auto
event_id
=
boost
::
apply_visitor
([](
const
auto
&
e
)
->
std
::
string
{
return
eventEventId
(
e
);
},
events
[
index
]);
http
::
client
().
read_event
(
id
,
event_id
,
[](
mtx
::
http
::
RequestErr
e
)
{
if
(
e
)
qDebug
()
<<
"Error marking event as read: "
<<
*
e
;
});
qDebug
()
<<
"marked "
<<
QString
::
fromStdString
(
event_id
)
<<
" as read"
;
}
This diff is collapsed.
Click to expand it.
src/models/roommodel.h
+
1
−
0
View file @
e5e90fc9
...
...
@@ -157,6 +157,7 @@ struct Room : public QAbstractListModel {
void
setUnread
(
int
unread
)
{
this
->
unreadNotifications
=
unread
;
}
void
fetchOlderMessages
();
void
sendTextMessage
(
QString
message
);
void
markRead
(
int
index
);
private
:
std
::
vector
<
mtx
::
events
::
collections
::
TimelineEvents
>
events
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment