1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-27 21:05:53 +00:00

Add a setting for tab-completion of FFZ emotes. Process default values of settings with merge strategies.

This commit is contained in:
SirStendec 2018-03-30 19:54:26 -04:00
parent d922c00748
commit 79e4b02e6b
6 changed files with 44 additions and 11 deletions

View file

@ -43,7 +43,7 @@ configure linting support for your editor as well.
If you're using Visual Studio Code, make sure to install the ESLint extension
and add the following to your workspace settings:
```json
```
{
"eslint.validate": [
"javascript",

View file

@ -1,3 +1,10 @@
<div class="list-header">4.0.0-beta1.8<span>@c07590bbb2a94b83c0e3</span> <time datetime="2018-03-30">(2018-03-30)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Added: Basic tab completion of FrankerFaceZ emotes, using Twitch's existing tab-completion system.</li>
<li>Fixed: Do not hide the Hosting bar when the setting to hide the Rerun bar is enabled.</li>
<li>Changed: Re-implement Twitch's emote matching code for tab-completion to improve performance when there are a significant number of emotes.</li>
</ul>
<div class="list-header">4.0.0-beta1.7<span>@014a758f744a54c37b26</span> <time datetime="2018-03-25">(2018-03-25)</time></div>
<ul class="chat-menu-content menu-side-padding">
<li>Added: Settings to hide the Event Bar and Rerun Bar over the player.</li>

View file

@ -95,7 +95,7 @@ class FrankerFaceZ extends Module {
FrankerFaceZ.Logger = Logger;
const VER = FrankerFaceZ.version_info = {
major: 4, minor: 0, revision: 0, extra: '-beta1.7',
major: 4, minor: 0, revision: 0, extra: '-beta1.8',
build: __webpack_hash__,
toString: () =>
`${VER.major}.${VER.minor}.${VER.revision}${VER.extra || ''}${DEBUG ? '-dev' : ''}`

View file

@ -241,6 +241,9 @@ export default class SettingsContext extends EventEmitter {
value = def_default(this);
else
value = def_default;
if ( type.default )
value = type.default(value);
}
if ( definition.requires )

View file

@ -43,6 +43,15 @@ export const object_merge = {
export const array_merge = {
default(val) {
const values = [];
for(const v of val)
if ( v.t !== 'inherit' && v.v )
values.push(v.v);
return values;
},
get(key, profiles, log) {
const values = [],
trailing = [],

View file

@ -131,7 +131,7 @@ export default class ChatHook extends Module {
n => n.collapseCheer && n.saveRenderedMessageRef,
Twilight.CHAT_ROUTES
);
this.TabComplete = this.fine.define(
'tab-complete-emotes',
n => n.getMatchedEmotes,
@ -237,6 +237,15 @@ export default class ChatHook extends Module {
]
}
});
this.settings.add('chat.tab-complete.ffz-emotes', {
default: true,
ui: {
path: 'Chat > Input >> Tab Completion',
title: 'Allow tab-completion of FrankerFaceZ emotes.',
component: 'setting-check-box'
}
});
}
@ -443,13 +452,14 @@ export default class ChatHook extends Module {
}, this);
}
getResultsForSets(input, inst) {
if (!inst._ffz_channelInfo) return [];
const search = input.substring(1),
results = [],
emotes = Object.values(this.chat.emotes.getEmotes(inst._ffz_channelInfo.props.sessionUser.id, undefined, inst._ffz_channelInfo.props.channelID));
for (const emote of emotes) {
if (inst.doesEmoteMatchTerm(emote, search)) {
results.push({
@ -467,18 +477,21 @@ export default class ChatHook extends Module {
return results;
}
setupTabCompletion(inst) {
const t = this,
old_matched = inst._ffz_getMatchedEmotes || inst.getMatchedEmotes;
if (!inst._ffz_getMatchedEmotes) inst._ffz_getMatchedEmotes = old_matched;
inst._ffz_channelInfo = this.fine.searchParent(inst, n => n.props !== undefined
inst._ffz_channelInfo = this.fine.searchParent(inst, n => n.props
&& n.props.channelID !== undefined
&& !n.props.roomID
&& n.props.roomID === undefined
);
if (!inst._ffz_channelInfo) return;
if ( ! inst._ffz_channelInfo )
return;
inst.doesEmoteMatchTerm = function (emote, term) {
const emote_name = emote.name || emote.token,
emote_lower = emote_name.toLowerCase(),
@ -493,10 +506,11 @@ export default class ChatHook extends Module {
};
inst.getMatchedEmotes = function (input) {
const results = old_matched.call(this, input)
.concat(t.getResultsForSets(input, this))
const results = old_matched.call(this, input);
if ( ! t.chat.context.get('chat.tab-complete.ffz-emotes') )
return results;
return results;
return results.concat(t.getResultsForSets(input, this));
};
}