Make sure that only text messages can be edited

This commit is contained in:
James Graham
2024-02-25 16:57:07 +00:00
parent e95f191dc6
commit 38edad2ac5
4 changed files with 13 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
// SPDX-License-Identifier: GPL-3.0-only
#include "messageeventmodel.h"
#include "messagecomponenttype.h"
#include "messageeventmodel_logging.h"
#include "neochatconfig.h"
@@ -58,6 +59,7 @@ QHash<int, QByteArray> MessageEventModel::roleNames() const
roles[IsPendingRole] = "isPending";
roles[ContentModelRole] = "contentModel";
roles[MediaInfoRole] = "mediaInfo";
roles[IsEditableRole] = "isEditable";
return roles;
}
@@ -618,6 +620,10 @@ QVariant MessageEventModel::data(const QModelIndex &idx, int role) const
return eventHandler.getMediaInfo();
}
if (role == IsEditableRole) {
return eventHandler.messageComponentType() == MessageComponentType::Text && evt.senderId() == m_currentRoom->localUser()->id();
}
return {};
}