diff --git a/src/main.js b/src/main.js index 2b751281..1edaba3f 100644 --- a/src/main.js +++ b/src/main.js @@ -149,7 +149,7 @@ ${typeof x[1] === 'string' ? x[1] : JSON.stringify(x[1], null, 4)}` FrankerFaceZ.Logger = Logger; const VER = FrankerFaceZ.version_info = { - major: 4, minor: 0, revision: 0, extra: '-rc19.4', + major: 4, minor: 0, revision: 0, extra: '-rc20', commit: __git_commit__, build: __webpack_hash__, toString: () => diff --git a/src/modules/chat/actions/components/edit-icon.vue b/src/modules/chat/actions/components/edit-icon.vue index 55fce223..0bb3afd5 100644 --- a/src/modules/chat/actions/components/edit-icon.vue +++ b/src/modules/chat/actions/components/edit-icon.vue @@ -94,8 +94,6 @@ const FFZ_ICONS = [ 'lock', 'lock-open', 'arrows-cw', - 'pin', - 'pin-outline', 'gift', 'eyedropper', 'github', diff --git a/src/modules/chat/actions/index.jsx b/src/modules/chat/actions/index.jsx index 93e63aba..4e454f15 100644 --- a/src/modules/chat/actions/index.jsx +++ b/src/modules/chat/actions/index.jsx @@ -90,6 +90,35 @@ export default class Actions extends Module { } }); + this.settings.add('chat.actions.room', { + // Filter out actions + process: (ctx, val) => + val.filter(x => x.type || (x.appearance && + this.renderers[x.appearance.type] && + (! this.renderers[x.appearance.type].load || this.renderers[x.appearance.type].load(x.appearance)) && + (! x.action || this.actions[x.action]) + )), + + default: [], + type: 'array_merge', + ui: { + path: 'Chat > Actions > Room @{"description": "Here, you can define custom actions that will appear above the chat input box."}', + component: 'chat-actions', + context: ['room'], + inline: true, + + data: () => { + const chat = this.resolve('site.chat'); + + return { + color: val => chat && chat.colors ? chat.colors.process(val) : val, + actions: deep_copy(this.actions), + renderers: deep_copy(this.renderers) + } + } + } + }); + this.settings.add('chat.actions.rules-as-reasons', { default: true, ui: { @@ -346,6 +375,56 @@ export default class Actions extends Module { } + renderRoom(mod_icons, current_user, current_room, createElement) { + const actions = [], + chat = this.resolve('site.chat'); + + for(const data of this.parent.context.get('chat.actions.room')) { + if ( ! data || ! data.action || ! data.appearance ) + continue; + + const ap = data.appearance || {}, + disp = data.display || {}, + + def = this.renderers[ap.type]; + + if ( ! def || disp.disabled || + (disp.mod_icons != null && disp.mod_icons !== !!mod_icons) || + (disp.mod != null && disp.mod !== (current_user ? !!current_user.mod : false)) || + (disp.staff != null && disp.staff !== (current_user ? !!current_user.staff : false)) ) + continue; + + const has_color = def.colored && ap.color, + color = has_color && (chat && chat.colors ? chat.colors.process(ap.color) : ap.color), + contents = def.render.call(this, ap, createElement, color); + + actions.push( + {contents} + ); + } + + if ( ! actions.length ) + return null; + + const room = current_room && JSON.stringify(current_room); + + return (