mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-13 17:20:14 +00:00
feat(dashboard): add filtering by proxy tags
This commit is contained in:
parent
7c7108bd30
commit
2082f76b87
3 changed files with 35 additions and 9 deletions
|
|
@ -50,29 +50,38 @@ function search<T extends Member|Group>(list: T[], options: ListOptions): T[] {
|
|||
|
||||
function filter<T extends Member|Group>(list: T[], options: ListOptions): T[] {
|
||||
let newList = [...list];
|
||||
|
||||
Object.keys(options.filter).forEach(x => {
|
||||
if (options.filter[x] === 'include') {
|
||||
newList = [...list].filter(item => item[x] && true);
|
||||
newList = [...newList].filter(item => item[x] && true);
|
||||
}
|
||||
});
|
||||
|
||||
let newList2 = [...newList]
|
||||
|
||||
Object.keys(options.filter).forEach(x => {
|
||||
if (options.filter[x] === 'exclude') {
|
||||
newList2 = [...newList].filter(item => !item[x] && true)
|
||||
newList = [...newList].filter(item => !item[x] && true)
|
||||
}
|
||||
});
|
||||
|
||||
let anotherList = [...newList2];
|
||||
Object.keys(options.filterArray).forEach(x => {
|
||||
if (options.filterArray[x] === 'include') {
|
||||
newList = [...newList].filter(i => i[x] && i[x].length > 0 ? true : false)
|
||||
}
|
||||
})
|
||||
|
||||
Object.keys(options.filterArray).forEach(x => {
|
||||
if (options.filterArray[x] === 'exclude') {
|
||||
newList = [...newList].filter(i => !i[x] || i[x].length === 0 ? true : false)
|
||||
}
|
||||
})
|
||||
|
||||
if (options.show === 'private') {
|
||||
anotherList = [...newList2].filter(item => item.privacy && item.privacy.visibility === 'private');
|
||||
newList = [...newList].filter(item => item.privacy && item.privacy.visibility === 'private');
|
||||
} else if (options.show === 'public') {
|
||||
anotherList = [...newList2].filter(item => item.privacy && item.privacy.visibility === 'public');
|
||||
newList = [...newList].filter(item => item.privacy && item.privacy.visibility === 'public');
|
||||
}
|
||||
|
||||
return anotherList;
|
||||
return newList;
|
||||
}
|
||||
|
||||
function sort<T extends Member|Group>(list: T[], options: ListOptions): T[] {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue