mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-08 07:10:54 +00:00
Add "simple view" context, setting, and Vue component filters
This commit is contained in:
parent
3ca8f2f6f3
commit
8d2e58500d
6 changed files with 68 additions and 4 deletions
|
@ -147,6 +147,8 @@ export default {
|
||||||
let query = this.query.toLowerCase();
|
let query = this.query.toLowerCase();
|
||||||
|
|
||||||
let flags = new Set;
|
let flags = new Set;
|
||||||
|
if ( this.context.simple_view )
|
||||||
|
flags.add('simple_view');
|
||||||
query = query.replace(/(?<=^|\s)@(\S+)(?:\s+|$)/g, (match, flag, index) => {
|
query = query.replace(/(?<=^|\s)@(\S+)(?:\s+|$)/g, (match, flag, index) => {
|
||||||
if ( VALID_FLAGS.includes(flag) ) {
|
if ( VALID_FLAGS.includes(flag) ) {
|
||||||
flags.add(flag);
|
flags.add(flag);
|
||||||
|
|
|
@ -62,6 +62,16 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( this.filter.flags ) {
|
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') ) {
|
if ( this.filter.flags.has('modified') ) {
|
||||||
// We need to tree walk for this one.
|
// We need to tree walk for this one.
|
||||||
if ( ! is_walking ) {
|
if ( ! is_walking ) {
|
||||||
|
@ -72,6 +82,9 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this.context.simple_view && ! item.simple )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
|
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,6 +191,16 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( this.filter.flags ) {
|
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') ) {
|
if ( this.filter.flags.has('modified') ) {
|
||||||
// We need to tree walk for this one.
|
// We need to tree walk for this one.
|
||||||
if ( ! is_walking ) {
|
if ( ! is_walking ) {
|
||||||
|
@ -201,6 +211,9 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this.context.simple_view && ! item.simple )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
|
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,16 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( this.filter.flags ) {
|
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') ) {
|
if ( this.filter.flags.has('modified') ) {
|
||||||
// We need to tree walk for this one.
|
// We need to tree walk for this one.
|
||||||
if ( ! is_walking ) {
|
if ( ! is_walking ) {
|
||||||
|
@ -126,6 +136,9 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( this.context.simple_view && ! item.simple )
|
||||||
|
return false;
|
||||||
|
|
||||||
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
|
if ( ! item.setting || ! this.context.currentProfile.has(item.setting) )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,6 +215,15 @@ export default class MainMenu extends Module {
|
||||||
force_seen: true
|
force_seen: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.settings.add('ffz.simple-view', {
|
||||||
|
default: false,
|
||||||
|
ui: {
|
||||||
|
path: 'Appearance > Control Center >> Simple View',
|
||||||
|
title: 'Show simple view.',
|
||||||
|
component: 'setting-check-box'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
this.settings.add('ffz.search.matches-only', {
|
this.settings.add('ffz.search.matches-only', {
|
||||||
default: true,
|
default: true,
|
||||||
ui: {
|
ui: {
|
||||||
|
@ -939,6 +948,7 @@ export default class MainMenu extends Module {
|
||||||
proxied: context._context.proxied,
|
proxied: context._context.proxied,
|
||||||
has_update: this.has_update,
|
has_update: this.has_update,
|
||||||
matches_only: settings.get('ffz.search.matches-only'),
|
matches_only: settings.get('ffz.search.matches-only'),
|
||||||
|
simple_view: settings.get('ffz.simple-view'),
|
||||||
mod_icons: context.get('context.chat.showModIcons'),
|
mod_icons: context.get('context.chat.showModIcons'),
|
||||||
|
|
||||||
setProxied: val => {
|
setProxied: val => {
|
||||||
|
@ -1053,12 +1063,14 @@ export default class MainMenu extends Module {
|
||||||
|
|
||||||
_update_settings() {
|
_update_settings() {
|
||||||
_c.matches_only = settings.get('ffz.search.matches-only');
|
_c.matches_only = settings.get('ffz.search.matches-only');
|
||||||
|
_c.simple_view = settings.get('ffz.simple-view');
|
||||||
},
|
},
|
||||||
|
|
||||||
_add_user() {
|
_add_user() {
|
||||||
this._users++;
|
this._users++;
|
||||||
if ( this._users === 1 ) {
|
if ( this._users === 1 ) {
|
||||||
settings.on(':changed:ffz.search.matches-only', this._update_settings, this);
|
settings.on(':changed:ffz.search.matches-only', this._update_settings, this);
|
||||||
|
settings.on(':changed:ffz.simple-view', this._update_settings, this);
|
||||||
settings.on(':profile-toggled', this._profile_toggled, this);
|
settings.on(':profile-toggled', this._profile_toggled, this);
|
||||||
settings.on(':profile-created', this._profile_created, this);
|
settings.on(':profile-created', this._profile_created, this);
|
||||||
settings.on(':profile-changed', this._profile_changed, this);
|
settings.on(':profile-changed', this._profile_changed, this);
|
||||||
|
@ -1074,6 +1086,7 @@ export default class MainMenu extends Module {
|
||||||
this._users--;
|
this._users--;
|
||||||
if ( this._users === 0 ) {
|
if ( this._users === 0 ) {
|
||||||
settings.off(':changed:ffz.search.matches-only', this._update_settings, this);
|
settings.off(':changed:ffz.search.matches-only', this._update_settings, this);
|
||||||
|
settings.off(':changed:ffz.simple-view', this._update_settings, this);
|
||||||
settings.off(':profile-toggled', this._profile_toggled, this);
|
settings.off(':profile-toggled', this._profile_toggled, this);
|
||||||
settings.off(':profile-created', this._profile_created, this);
|
settings.off(':profile-created', this._profile_created, this);
|
||||||
settings.off(':profile-changed', this._profile_changed, this);
|
settings.off(':profile-changed', this._profile_changed, this);
|
||||||
|
|
|
@ -214,6 +214,16 @@ export default {
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if ( this.filter.flags ) {
|
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') ) {
|
if ( this.filter.flags.has('modified') ) {
|
||||||
// We need to tree walk for this one.
|
// We need to tree walk for this one.
|
||||||
if ( ! is_walking ) {
|
if ( ! is_walking ) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue