1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-08-03 00:18:31 +00:00

Separate simple view logic from filter logic

This commit is contained in:
Dan Salvato 2024-02-06 22:49:45 -07:00
parent 8d2e58500d
commit f4febe6ee0
5 changed files with 56 additions and 55 deletions

View file

@ -147,8 +147,6 @@ export default {
let query = this.query.toLowerCase();
let flags = new Set;
if ( this.context.simple_view )
flags.add('simple_view');
query = query.replace(/(?<=^|\s)@(\S+)(?:\s+|$)/g, (match, flag, index) => {
if ( VALID_FLAGS.includes(flag) ) {
flags.add(flag);

View file

@ -58,20 +58,23 @@ export default {
},
shouldShow(item, is_walking = false) {
if ( ! this.filter || item.no_filter )
if ( item.no_filter )
return true;
if ( this.context.simple_view ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( ! this.filter )
return true;
if ( this.filter.flags ) {
if ( this.filter.flags.has('simple_view') ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( this.filter.flags.has('modified') ) {
// We need to tree walk for this one.
if ( ! is_walking ) {
@ -82,9 +85,6 @@ export default {
return true;
}
if ( this.context.simple_view && ! item.simple )
return false;
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
return false;
}

View file

@ -187,20 +187,23 @@ export default {
methods: {
shouldShow(item, is_walking = false) {
if ( ! this.filter || item.no_filter )
if ( item.no_filter )
return true;
if ( this.context.simple_view ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( ! this.filter )
return true;
if ( this.filter.flags ) {
if ( this.filter.flags.has('simple_view') ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( this.filter.flags.has('modified') ) {
// We need to tree walk for this one.
if ( ! is_walking ) {
@ -211,9 +214,6 @@ export default {
return true;
}
if ( this.context.simple_view && ! item.simple )
return false;
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
return false;
}

View file

@ -112,20 +112,23 @@ export default {
methods: {
shouldShow(item, is_walking = false) {
if ( ! this.filter || this.containsCurrent(item) )
if ( item.no_filter )
return true;
if ( this.context.simple_view ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( ! this.filter )
return true;
if ( this.filter.flags ) {
if ( this.filter.flags.has('simple_view') ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( this.filter.flags.has('modified') ) {
// We need to tree walk for this one.
if ( ! is_walking ) {
@ -136,9 +139,6 @@ export default {
return true;
}
if ( this.context.simple_view && ! item.simple )
return false;
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
return false;
}

View file

@ -210,20 +210,23 @@ export default {
},
shouldShow(item, is_walking = false) {
if ( ! this.filter || item.no_filter )
if ( item.no_filter )
return true;
if ( this.context.simple_view ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( ! this.filter )
return true;
if ( this.filter.flags ) {
if ( this.filter.flags.has('simple_view') ) {
for(const key of ['tabs', 'contents', 'items'])
if ( item[key] )
for(const thing of item[key])
if ( this.shouldShow(thing) )
return true;
if ( ! item.setting || ! item.simple )
return false;
}
if ( this.filter.flags.has('modified') ) {
// We need to tree walk for this one.
if ( ! is_walking ) {