Navigation Menu

Skip to content

Commit

Permalink
fixes #2601
Browse files Browse the repository at this point in the history
fixes #2608
fixes #2643
fixes #2670
  • Loading branch information
night committed Sep 9, 2017
1 parent 9dce2fb commit 427db03
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
15 changes: 10 additions & 5 deletions src/modules/chat/index.js
Expand Up @@ -65,7 +65,7 @@ function hasNonASCII(message) {
class ChatModule {
constructor() {
watcher.on('chat.message', ($element, message) => this.messageParser($element, message));
watcher.on('conversation.message', ($element, message) => this.messageParser($element, message));
watcher.on('conversation.message', ($element, message) => this.messageParser($element, message, false));
watcher.on('channel.updated', ({bots}) => {
channelBots = bots;
});
Expand Down Expand Up @@ -188,7 +188,7 @@ class ChatModule {
}
}

messageParser($element, messageObj) {
messageParser($element, messageObj, channelChat = true) {
const user = formatChatUser(messageObj);
if (!user) return;

Expand All @@ -214,10 +214,15 @@ class ChatModule {
$message.css('color', color);
}

if (channelChat && ($element.hasClass('whisper-line') || $element.hasClass('admin'))) {
channelChat = false;
}
if (
(modsOnly === true && !user.mod) ||
(subsOnly === true && !user.subscriber) ||
(asciiOnly === true && hasNonASCII(messageObj.message))
channelChat && (
(modsOnly === true && !user.mod) ||
(subsOnly === true && !user.subscriber) ||
(asciiOnly === true && hasNonASCII(messageObj.message))
)
) {
$element.hide();
}
Expand Down
2 changes: 1 addition & 1 deletion src/modules/chat_moderator_cards/index.js
Expand Up @@ -204,7 +204,7 @@ class ChatModeratorCardsModule {
// If there is no id, the user must be yourself
const currentUser = twitch.getCurrentUser();
if (!currentUser) return;
const id = (messageObj.tags && messageObj.tags['user-id']) || currentUser.id;
const id = (messageObj.tags && messageObj.tags['user-id']) || messageObj.id || currentUser.id;
this.create(id, $target);
}
});
Expand Down
23 changes: 17 additions & 6 deletions src/modules/disable_host_mode/index.js
@@ -1,4 +1,6 @@
const settings = require('../../settings');
const watcher = require('../../watcher');
const twitch = require('../../utils/twitch');

class DisableHostModeModule {
constructor() {
Expand All @@ -8,14 +10,23 @@ class DisableHostModeModule {
defaultValue: false,
description: 'Disables hosted channels on Twitch'
});
settings.on('changed.disableHostMode', () => this.load());
this.load();
settings.on('changed.disableHostMode', () => this.disableHostMode());
watcher.on('load.channel', () => this.observeHostMode());
}

load() {
try {
window.App.__container__.lookup('service:globals').set('enableHostMode', !settings.get('disableHostMode'));
} catch (e) {}
disableHostMode() {
if (!settings.get('disableHostMode')) return;

const channelContainer = twitch.getEmberContainer('controller:channel');
if (!channelContainer) return;
channelContainer.set('channelModel.hostModeTarget', null);
}

observeHostMode() {
const channelContainer = twitch.getEmberContainer('controller:channel');
if (!channelContainer) return;
channelContainer.addObserver('channelModel.hostModeTarget', () => this.disableHostMode());
this.disableHostMode();
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/modules/global_css/index.js
Expand Up @@ -2,6 +2,7 @@ const $ = require('jquery');
const cdn = require('../../utils/cdn');
const css = require('../../utils/css');
const settings = require('../../settings');
const storage = require('../../storage');
const watcher = require('../../watcher');
const twitch = require('../../utils/twitch');

Expand Down Expand Up @@ -45,6 +46,12 @@ class GlobalCSSModule {
}

loadDark() {
if (!settings.get('darkenedMode') && window.location.search && window.location.search.indexOf('darkpopout') >= 0) {
settings.set('darkenedMode', true);
// Turn darkenedMode setting off again if needed but without emit
storage.set('darkenedMode', false, undefined, false, false);
}

if (settings.get('darkenedMode') !== true || !$('body').attr('data-page')) return;

const pageKind = $('body').data('page').split('#')[0];
Expand Down

0 comments on commit 427db03

Please sign in to comment.