Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nheko
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
Container 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
nheko
Commits
72cfb062
Verified
Commit
72cfb062
authored
3 years ago
by
tastytea
Committed by
Nicolas Werner
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Hidden events: Some cleanup
parent
49b313e3
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
resources/qml/dialogs/HiddenEventsDialog.qml
+1
-1
1 addition, 1 deletion
resources/qml/dialogs/HiddenEventsDialog.qml
src/ui/RoomSettings.cpp
+33
-36
33 additions, 36 deletions
src/ui/RoomSettings.cpp
src/ui/RoomSettings.h
+2
-2
2 additions, 2 deletions
src/ui/RoomSettings.h
with
36 additions
and
39 deletions
resources/qml/dialogs/HiddenEventsDialog.qml
+
1
−
1
View file @
72cfb062
...
...
@@ -45,7 +45,7 @@ ApplicationWindow {
return
qsTr
(
"
These events will be be <b>shown</b> in %1:
"
).
arg
(
roomSettings
.
roomName
);
}
else
{
return
qsTr
(
"
These events will be be <b>shown</b>:
"
);
return
qsTr
(
"
These events will be be <b>shown</b>
in all rooms
:
"
);
}
}
font.pixelSize
:
Math
.
floor
(
fontMetrics
.
font
.
pixelSize
*
1.2
)
...
...
This diff is collapsed.
Click to expand it.
src/ui/RoomSettings.cpp
+
33
−
36
View file @
72cfb062
...
...
@@ -12,7 +12,6 @@
#include
<QMimeDatabase>
#include
<QStandardPaths>
#include
<QVBoxLayout>
#include
<algorithm>
#include
<mtx/events/event_type.hpp>
#include
<mtx/events/nheko_extensions/hidden_events.hpp>
#include
<mtx/responses/common.hpp>
...
...
@@ -230,7 +229,6 @@ RoomSettings::RoomSettings(QString roomid, QObject *parent)
}
emit
accessJoinRulesChanged
();
// Get room's hidden events and store it in member variable.
if
(
auto
hiddenEvents
=
cache
::
client
()
->
getAccountData
(
mtx
::
events
::
EventType
::
NhekoHiddenEvents
,
roomid_
.
toStdString
()))
{
if
(
auto
tmp
=
std
::
get_if
<
mtx
::
events
::
EphemeralEvent
<
...
...
@@ -310,12 +308,6 @@ RoomSettings::accessJoinRules()
return
accessRules_
;
}
bool
RoomSettings
::
eventHidden
(
const
QString
event
)
const
{
return
hiddenEvents_
.
contains
(
event
);
}
void
RoomSettings
::
enableEncryption
()
{
...
...
@@ -426,34 +418,6 @@ RoomSettings::openEditModal()
});
}
void
RoomSettings
::
saveHiddenEventsSettings
(
const
QSet
<
QString
>
&
events
,
const
QString
&
roomId
)
{
mtx
::
events
::
account_data
::
nheko_extensions
::
HiddenEvents
hiddenEvents
;
hiddenEvents
.
hidden_event_types
=
{
EventType
::
Reaction
,
EventType
::
CallCandidates
,
EventType
::
Unsupported
};
for
(
const
auto
&
event
:
events
)
{
hiddenEvents
.
hidden_event_types
.
emplace_back
(
mtx
::
events
::
getEventType
(
event
.
toStdString
()));
}
if
(
!
roomId
.
isEmpty
())
{
const
auto
rid
=
roomId
.
toStdString
();
http
::
client
()
->
put_room_account_data
(
rid
,
hiddenEvents
,
[
&
rid
](
mtx
::
http
::
RequestErr
e
)
{
if
(
e
)
{
nhlog
::
net
()
->
error
(
"Failed to update room account data with hidden events in {}: {}"
,
rid
,
*
e
);
}
});
}
else
{
http
::
client
()
->
put_account_data
(
hiddenEvents
,
[](
mtx
::
http
::
RequestErr
e
)
{
if
(
e
)
{
nhlog
::
net
()
->
error
(
"Failed to update account data with hidden events: {}"
,
*
e
);
}
});
}
}
void
RoomSettings
::
changeNotifications
(
int
currentIndex
)
{
...
...
@@ -685,3 +649,36 @@ RoomSettings::updateAvatar()
});
});
}
void
RoomSettings
::
saveHiddenEventsSettings
(
const
QSet
<
QString
>
&
events
,
const
QString
&
roomId
)
{
account_data
::
nheko_extensions
::
HiddenEvents
hiddenEvents
;
hiddenEvents
.
hidden_event_types
=
{
EventType
::
Reaction
,
EventType
::
CallCandidates
,
EventType
::
Unsupported
};
for
(
const
auto
&
event
:
events
)
{
hiddenEvents
.
hidden_event_types
.
emplace_back
(
getEventType
(
event
.
toStdString
()));
}
if
(
!
roomId
.
isEmpty
())
{
const
auto
rid
=
roomId
.
toStdString
();
http
::
client
()
->
put_room_account_data
(
rid
,
hiddenEvents
,
[
&
rid
](
mtx
::
http
::
RequestErr
e
)
{
if
(
e
)
{
nhlog
::
net
()
->
error
(
"Failed to update room account data with hidden events in {}: {}"
,
rid
,
*
e
);
}
});
}
else
{
http
::
client
()
->
put_account_data
(
hiddenEvents
,
[](
mtx
::
http
::
RequestErr
e
)
{
if
(
e
)
{
nhlog
::
net
()
->
error
(
"Failed to update account data with hidden events: {}"
,
*
e
);
}
});
}
}
bool
RoomSettings
::
eventHidden
(
const
QString
event
)
const
{
return
hiddenEvents_
.
contains
(
event
);
}
This diff is collapsed.
Click to expand it.
src/ui/RoomSettings.h
+
2
−
2
View file @
72cfb062
...
...
@@ -109,10 +109,10 @@ public:
Q_INVOKABLE
void
enableEncryption
();
Q_INVOKABLE
void
updateAvatar
();
Q_INVOKABLE
void
openEditModal
();
Q_INVOKABLE
void
saveHiddenEventsSettings
(
const
QSet
<
QString
>
&
events
,
const
QString
&
roomId
=
{});
Q_INVOKABLE
void
changeAccessRules
(
int
index
);
Q_INVOKABLE
void
changeNotifications
(
int
currentIndex
);
Q_INVOKABLE
void
saveHiddenEventsSettings
(
const
QSet
<
QString
>
&
events
,
const
QString
&
roomId
=
{});
Q_INVOKABLE
bool
eventHidden
(
QString
event
)
const
;
signals
:
...
...
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