mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 17:10:23 +00:00
ClipboardHistoryModel: Prevent duplicate rows (#4073)
Prevents the adding of items to the ClipboardHistoryModel if the raw data and mime_type of the item being added is the same as another item already in the list.
This commit is contained in:
parent
d6a4c0c79e
commit
7ef8835e5a
Notes:
sideshowbarker
2024-07-19 01:21:39 +09:00
Author: https://github.com/supex0fan Commit: https://github.com/SerenityOS/serenity/commit/7ef8835e5aa Pull-request: https://github.com/SerenityOS/serenity/pull/4073 Issue: https://github.com/SerenityOS/serenity/issues/4033 Reviewed-by: https://github.com/awesomekling
1 changed files with 5 additions and 0 deletions
|
@ -89,8 +89,13 @@ void ClipboardHistoryModel::update()
|
|||
|
||||
void ClipboardHistoryModel::add_item(const GUI::Clipboard::DataAndType& item)
|
||||
{
|
||||
m_history_items.remove_first_matching([&](GUI::Clipboard::DataAndType& existing) {
|
||||
return existing.data == item.data && existing.mime_type == item.mime_type;
|
||||
});
|
||||
|
||||
if (m_history_items.size() == m_history_limit)
|
||||
m_history_items.take_last();
|
||||
|
||||
m_history_items.prepend(item);
|
||||
update();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue