From f4febe6ee092411b12438e5d8e956fcb43c86bfa Mon Sep 17 00:00:00 2001 From: Dan Salvato Date: Tue, 6 Feb 2024 22:49:45 -0700 Subject: [PATCH] Separate simple view logic from filter logic --- .../main_menu/components/main-menu.vue | 2 -- .../main_menu/components/menu-container.vue | 28 +++++++++---------- .../main_menu/components/menu-page.vue | 28 +++++++++---------- .../main_menu/components/menu-tree.vue | 28 +++++++++---------- src/std-components/tab-container.vue | 25 +++++++++-------- 5 files changed, 56 insertions(+), 55 deletions(-) diff --git a/src/modules/main_menu/components/main-menu.vue b/src/modules/main_menu/components/main-menu.vue index 3def71eb..04deac31 100644 --- a/src/modules/main_menu/components/main-menu.vue +++ b/src/modules/main_menu/components/main-menu.vue @@ -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); diff --git a/src/modules/main_menu/components/menu-container.vue b/src/modules/main_menu/components/menu-container.vue index a3b49099..cd0a2dd1 100644 --- a/src/modules/main_menu/components/menu-container.vue +++ b/src/modules/main_menu/components/menu-container.vue @@ -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; } diff --git a/src/modules/main_menu/components/menu-page.vue b/src/modules/main_menu/components/menu-page.vue index fbd7cf19..c379b851 100644 --- a/src/modules/main_menu/components/menu-page.vue +++ b/src/modules/main_menu/components/menu-page.vue @@ -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; } diff --git a/src/modules/main_menu/components/menu-tree.vue b/src/modules/main_menu/components/menu-tree.vue index f403eaaf..398838e0 100644 --- a/src/modules/main_menu/components/menu-tree.vue +++ b/src/modules/main_menu/components/menu-tree.vue @@ -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; } diff --git a/src/std-components/tab-container.vue b/src/std-components/tab-container.vue index 6dffb96c..73769d6c 100644 --- a/src/std-components/tab-container.vue +++ b/src/std-components/tab-container.vue @@ -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 ) {