mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-06-19 01:25:21 -04:00
feat(clipboard): add type filters to clipboard history (#2640)
* feat(clipboard): add active filter state * feat(clipboard): add clipboard filtering logic * feat(clipboard): wire clipboard filter state to UI * feat(clipboard): add filter dropdown * feat(clipboard): move filter dropdown beside search * refactor(clipboard): update filter defaults --------- Co-authored-by: purian23 <purian23@gmail.com>
This commit is contained in:
@@ -23,6 +23,7 @@ Singleton {
|
||||
property int pinnedCount: 0
|
||||
property int totalCount: 0
|
||||
property string searchText: ""
|
||||
property string activeFilter: "all"
|
||||
property int selectedIndex: 0
|
||||
property bool keyboardNavigationActive: false
|
||||
property int refCount: 0
|
||||
@@ -50,14 +51,21 @@ Singleton {
|
||||
}
|
||||
|
||||
function updateFilteredModel() {
|
||||
const query = searchText.trim();
|
||||
let filtered = [];
|
||||
let filtered = internalEntries;
|
||||
|
||||
if (query.length === 0) {
|
||||
filtered = internalEntries;
|
||||
} else {
|
||||
if (activeFilter !== "all") {
|
||||
filtered = filtered.filter(entry =>
|
||||
getEntryType(entry) === activeFilter
|
||||
);
|
||||
}
|
||||
|
||||
const query = searchText.trim();
|
||||
|
||||
if (query.length > 0) {
|
||||
const lowerQuery = query.toLowerCase();
|
||||
filtered = internalEntries.filter(entry => entry.preview.toLowerCase().includes(lowerQuery));
|
||||
filtered = filtered.filter(entry =>
|
||||
entry.preview.toLowerCase().includes(lowerQuery)
|
||||
);
|
||||
}
|
||||
|
||||
filtered.sort((a, b) => {
|
||||
@@ -72,11 +80,13 @@ Singleton {
|
||||
totalCount = clipboardEntries.length;
|
||||
|
||||
const activeCount = Math.max(unpinnedEntries.length, pinnedEntries.length);
|
||||
|
||||
if (activeCount === 0) {
|
||||
keyboardNavigationActive = false;
|
||||
selectedIndex = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedIndex >= activeCount) {
|
||||
selectedIndex = activeCount - 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user