Cherrypick 24.02 Readonly Room
Add readonly property to a room and use it to decide whether to show chatbar, replies and edits
BUG: 479590
(cherry picked from commit ec4aa73e37)
This commit is contained in:
@@ -114,6 +114,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
|||||||
Q_EMIT parentIdsChanged();
|
Q_EMIT parentIdsChanged();
|
||||||
Q_EMIT canonicalParentChanged();
|
Q_EMIT canonicalParentChanged();
|
||||||
Q_EMIT joinRuleChanged();
|
Q_EMIT joinRuleChanged();
|
||||||
|
Q_EMIT readOnlyChanged();
|
||||||
});
|
});
|
||||||
connect(connection, &Connection::capabilitiesLoaded, this, &NeoChatRoom::maxRoomVersionChanged);
|
connect(connection, &Connection::capabilitiesLoaded, this, &NeoChatRoom::maxRoomVersionChanged);
|
||||||
connect(this, &Room::changed, this, [this]() {
|
connect(this, &Room::changed, this, [this]() {
|
||||||
@@ -662,6 +663,11 @@ bool NeoChatRoom::isInvite() const
|
|||||||
return joinState() == JoinState::Invite;
|
return joinState() == JoinState::Invite;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool NeoChatRoom::readOnly() const
|
||||||
|
{
|
||||||
|
return !canSendEvent("m.room.message"_ls);
|
||||||
|
}
|
||||||
|
|
||||||
bool NeoChatRoom::isUserBanned(const QString &user) const
|
bool NeoChatRoom::isUserBanned(const QString &user) const
|
||||||
{
|
{
|
||||||
auto roomMemberEvent = currentState().get<RoomMemberEvent>(user);
|
auto roomMemberEvent = currentState().get<RoomMemberEvent>(user);
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ class NeoChatRoom : public Quotient::Room
|
|||||||
*/
|
*/
|
||||||
Q_PROPERTY(bool isInvite READ isInvite NOTIFY isInviteChanged)
|
Q_PROPERTY(bool isInvite READ isInvite NOTIFY isInviteChanged)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Whether the local user can send messages in the room.
|
||||||
|
*/
|
||||||
|
Q_PROPERTY(bool readOnly READ readOnly NOTIFY readOnlyChanged)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The current join rule for the room as a QString.
|
* @brief The current join rule for the room as a QString.
|
||||||
*
|
*
|
||||||
@@ -552,6 +557,8 @@ public:
|
|||||||
|
|
||||||
bool isInvite() const;
|
bool isInvite() const;
|
||||||
|
|
||||||
|
bool readOnly() const;
|
||||||
|
|
||||||
Q_INVOKABLE void clearInvitationNotification();
|
Q_INVOKABLE void clearInvitationNotification();
|
||||||
|
|
||||||
[[nodiscard]] QString joinRule() const;
|
[[nodiscard]] QString joinRule() const;
|
||||||
@@ -809,6 +816,7 @@ Q_SIGNALS:
|
|||||||
void canonicalParentChanged();
|
void canonicalParentChanged();
|
||||||
void lastActiveTimeChanged();
|
void lastActiveTimeChanged();
|
||||||
void isInviteChanged();
|
void isInviteChanged();
|
||||||
|
void readOnlyChanged();
|
||||||
void displayNameChanged();
|
void displayNameChanged();
|
||||||
void pushNotificationStateChanged(PushNotificationState::State state);
|
void pushNotificationStateChanged(PushNotificationState::State state);
|
||||||
void showMessage(MessageType messageType, const QString &message);
|
void showMessage(MessageType messageType, const QString &message);
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ QQC2.Control {
|
|||||||
onTriggered: emojiDialog.open()
|
onTriggered: emojiDialog.open()
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
visible: root.delegate && root.delegate.author.isLocalUser && (root.delegate.delegateType === DelegateType.Emote || root.delegate.delegateType === DelegateType.Message)
|
visible: root.delegate && root.delegate.author.isLocalUser && (root.delegate.delegateType === DelegateType.Emote || root.delegate.delegateType === DelegateType.Message) && !root.currentRoom.readOnly
|
||||||
text: i18n("Edit")
|
text: i18n("Edit")
|
||||||
icon.name: "document-edit"
|
icon.name: "document-edit"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
@@ -98,6 +98,7 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
|
visible: !root.currentRoom.readOnly
|
||||||
text: i18n("Reply")
|
text: i18n("Reply")
|
||||||
icon.name: "mail-replied-symbolic"
|
icon.name: "mail-replied-symbolic"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
@@ -107,6 +108,7 @@ QQC2.Control {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
Kirigami.Action {
|
Kirigami.Action {
|
||||||
|
visible: !root.currentRoom.readOnly
|
||||||
text: i18n("Reply in Thread")
|
text: i18n("Reply in Thread")
|
||||||
icon.name: "dialog-messages"
|
icon.name: "dialog-messages"
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ Kirigami.Page {
|
|||||||
|
|
||||||
footer: Loader {
|
footer: Loader {
|
||||||
id: chatBarLoader
|
id: chatBarLoader
|
||||||
active: timelineViewLoader.active && root.currentRoom.canSendEvent("m.room.message") // TODO make this update in real time
|
active: timelineViewLoader.active && !root.currentRoom.readOnly
|
||||||
sourceComponent: ChatBar {
|
sourceComponent: ChatBar {
|
||||||
id: chatBar
|
id: chatBar
|
||||||
width: parent.width
|
width: parent.width
|
||||||
|
|||||||
Reference in New Issue
Block a user