diff --git a/plugin-conference.js b/plugin-conference.js index b4e558d..627c82c 100644 --- a/plugin-conference.js +++ b/plugin-conference.js @@ -59,6 +59,7 @@ kiwi.plugin('conferencePlugin', (kiwi, log) => { /* eslint-disable-line no-undef let captions = []; let kiwiConferenceTag = '1'; let sharedData = { isOpen: false }; + let enabledNotifyInChannels = ['*']; let enabledInChannels = ['*']; let inviteText = ''; let joinText = ''; @@ -70,10 +71,36 @@ kiwi.plugin('conferencePlugin', (kiwi, log) => { /* eslint-disable-line no-undef let linkShortenerAPIToken = ''; const groupedNoticesTTL = 30000; - - if (kiwi.state.setting('conference.enabledInChannels')) { + + if (kiwi.state.setting('conference.enabledInChannelsJson')) { + + var xmlhttp = new XMLHttpRequest(); + xmlhttp.onload = function onLoad(temp) { + if (xmlhttp.status !== 200) { + console.error('plugin-conference: error loading enabled channels list'); + return + } + try { + var json = JSON.parse(xmlhttp.responseText); + if (!json) { + return; + } + if (json.length > 0) { + enabledInChannels = json; + } + } catch (err) { + console.error('plugin-conference: error parsing enabled channels list:', err); + } + } + xmlhttp.open('GET', kiwi.state.setting('conference.enabledInChannelsJson'), true); + xmlhttp.send(); + } else { enabledInChannels = kiwi.state.setting('conference.enabledInChannels'); } + + if (kiwi.state.setting('conference.enabledNotifyInChannels')) { + enabledNotifyInChannels = kiwi.state.setting('conference.enabledNotifyInChannels'); + } if (kiwi.state.setting('conference.inviteText')) { inviteText = ' ' + kiwi.state.setting('conference.inviteText'); @@ -149,9 +176,30 @@ kiwi.plugin('conferencePlugin', (kiwi, log) => { /* eslint-disable-line no-undef }); // Add the call button to the channel+query headers - const conferencingTool = document.createElement('div'); - conferencingTool.style.cursor = 'pointer'; - conferencingTool.innerHTML = ''; + + var button = new kiwi.Vue({ + template: '
', + data: function(){ + return { + allowed:true, + } + } + }); + button.$mount(); + let conferencingTool = button.$el; + + if (enabledInChannels.indexOf('*') !== -1) { + kiwi.state.$watch('ui.active_buffer', function(newVal){ + if(enabledInChannels.indexOf(kiwi.state.getActiveBuffer().name) > -1) { + button.allowed = true; + } else { + button.allowed = false; + } + if(kiwi.state.getActiveBuffer().isQuery()) { + button.allowed = true; + } + }); + } if (kiwi.state.setting('conference.channels') !== false) { kiwi.addUi('header_channel', conferencingTool); } @@ -188,7 +236,7 @@ kiwi.plugin('conferencePlugin', (kiwi, log) => { /* eslint-disable-line no-undef } } }); - + kiwi.on('message.new', (newMessage, buffer) => { let messageTemplate = null; let message = ''; @@ -317,7 +365,7 @@ kiwi.plugin('conferencePlugin', (kiwi, log) => { /* eslint-disable-line no-undef m = new network.ircClient.Message('PRIVMSG', buffer.name, '* ' + network.nick + ' ' + inviteText + ' ' + await shareLink()); } else { roomName = buffer.name; - if (enabledInChannels.indexOf('*') !== -1 || enabledInChannels.indexOf(roomName) !== -1) { + if (enabledNotifyInChannels.indexOf('*') !== -1 || enabledNotifyInChannels.indexOf(roomName) !== -1) { m = new network.ircClient.Message('PRIVMSG', buffer.name, '* ' + network.nick + ' ' + joinText + ' ' + await shareLink()); } else { hideCams(false);