Permalink
Browse files

Chat bug fixes from week 14.

  • Loading branch information...
roncli committed Aug 1, 2017
1 parent 9022d89 commit 31bd6b96cc757701b50d863ebc0ed5f79b6c6f16
Showing with 202 additions and 149 deletions.
  1. +1 −0 app/package.json
  2. +4 −0 app/site/css/profile.css
  3. +1 −0 app/site/index.htm
  4. +9 −1 app/site/js/apiSettings.js
  5. +47 −11 app/site/js/index.js
  6. +140 −137 app/site/modules/chat/twitch/index.js
@@ -20,6 +20,7 @@
"dependencies": {
"bootstrap": "3.3.7",
"bootstrap-colorpicker": "2.5.1",
"emojionearea": "3.1.5",
"express": "4.15.3",
"iconv-lite": "0.4.18",
"jquery": "3.2.1",
@@ -25,6 +25,10 @@ h3 {
user-select: text;
}

#user-chat > span {
display: block;
}

a.userlink, a.userlink:hover, a.userlink:visited {
text-decoration: none;
color: inherit;
@@ -4,6 +4,7 @@
<script>$ = jQuery = require("jquery")</script>
<script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
<script src="js/index.js"></script>
<script src="../node_modules/emojionearea/dist/emojionearea.js"></script>
<link href="../node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"></link>
<link href="../node_modules/bootstrap/dist/css/bootstrap-theme.min.css" rel="stylesheet"></link>
<link href="css/index.css" rel="stylesheet"></link>
@@ -11,6 +11,14 @@ module.exports = {
clientId: "xetz9cvboym6sr1iz19qr0kubr2nl1",
clientSecret: undefined,
redirectUri: "http://127.0.0.1:65100/token",
scopes: ["chat_login", "channel_editor", "channel_commercial", "user_read", "channel_subscriptions", "user_follows_edit"]
scopes: [
"channel_commercial",
"channel_editor",
"channel_read",
"channel_subscriptions",
"chat_login",
"user_follows_edit",
"user_read"
]
}
};
@@ -1,7 +1,6 @@
const path = require("path"),
electron = require("electron"),
remote = electron.remote,
app = remote.app,
{remote, remote: {Menu, MenuItem, app}} = electron,
win = remote.getCurrentWindow(),
tinycolor = require("tinycolor2"),
Twitch = require("./modules/chat/twitch"), // TODO: Load modules
@@ -124,6 +123,11 @@ class Index {
*/
static updateStream(channel) {
var channelName = channel.substring(1);

if (!channels[channel]) {
return;
}

client.getStream(channelName).then((stream) => {
if (stream) {
channels[channel].stream = stream;
@@ -202,13 +206,17 @@ class Index {

$channel.append(html);

while ($channel.children().length > 1000) {
$channel.children().first().remove(); // TODO: Investigate possible memory leak?
}

if (atBottom) {
$channel.scrollTop($channel.prop("scrollHeight"));
}

const thisChannelName = $channel.parent().parent().data("username"),
activeChannelName = $("#channels li.active").text().substring(1);

if (thisChannelName !== activeChannelName) {
$(`#tab-${thisChannelName}`).find("a").addClass("text-danger");
}
@@ -248,7 +256,7 @@ client.on("message", (channel, username, usercolor, displayname, html, text) =>
}
}

if (text.indexOf(win.data.userSettings.data.twitch.username) === -1) {
if ($("<div></div>").append(html).text().indexOf(win.data.userSettings.data.twitch.username) === -1) {
Index.appendToChannel($(`#channel-${channelName} .text`), `<span class="user-${username}">${Index.timestamp()}<b style="color: ${usercolor}">${Index.userLink(channel, username, displayname)}</b>: ${html}</span>`);
} else {
Index.appendToChannel($(`#channel-${channelName} .text`), `<span class="user-${username}">${Index.timestamp()}<b style="color: ${usercolor}">${Index.userLink(channel, username, displayname)}</b>: <span class="highlight">${html}</span></span>`);
@@ -460,6 +468,14 @@ $(document).ready(() => {
part: /^\/part$/i
};

Index.tabContextMenu = new Menu();
Index.tabContextMenu.append(new MenuItem({
label: "Close",
click: () => {
client.part($("#channels li.context").text());
}
}));

// # # # #
// # # # # #
// ##### ## ### ### # # ### ### ## # # ## ### # # ## # # ### ### ## ### ###
@@ -496,6 +512,10 @@ $(document).ready(() => {
$inputbox.on("keydown", () => Index.setSize($inputbox));
$inputbox.on("keyup", () => Index.setSize($inputbox));

$("#inputbox").emojioneArea({
shortcuts: false
});

// # ## ## # #
// # # # # # #
// ##### ## ### ### ### ### ## # ### ### ## ### ## # ## ## # #
@@ -511,17 +531,16 @@ $(document).ready(() => {

channels[`#${currentChannelName}`].isAtBottom = Index.isAtBottom($channel);

$(this).tab("show").on("shown.bs.tab", () => {
$(ev.target).tab("show").on("shown.bs.tab", () => {
currentChannelName = $("#channels li.active").text().substring(1);
$channel = $(`#channel-${currentChannelName} .text`);

if (channels[`#${currentChannelName}`].isAtBottom) {
console.log("setting to bottom");
$channel.scrollTop($channel.prop("scrollHeight"));
}
});

$(this).find("a").removeClass("text-danger");
$(ev.target).removeClass("text-danger");
});

// # # # # # # #
@@ -547,22 +566,39 @@ $(document).ready(() => {
ev.preventDefault();
});

// ## # # ## # # #
// # # # # # #
// # ## ## ### ### ### ### ## # ### ### ### ## ### # # ## # # ### ## ### ## # # ###
// # # # # # # # # # # # # ## # #### # # # # # # # # # #### # # # # ## # ## # # # # # # # #
// # # ## # # # # ## # # # # ## # # # ## # # # # # # # # # # # # ## ## # # # # #### # #
// ### ### ## ## # # # # # # # # ## ### ## # # ### ## # # # # ## ### ### ## ### ## #### # #
$("#channels").on("mousedown", "li.channel-tab", (ev) => {
if (ev.which === 3) {
$("#channels li.channel-tab").removeClass("context");
$(ev.target).closest("li").addClass("context");
Index.tabContextMenu.popup();
}
});

// ## # # ## # #
// # # # #
// ### # # ### ## ### # ## ### # # ## ### ## # ## ## # #
// # # # # ## # ## # # # # # # ## # # # # # # # # ##
// # ## ## # # ## ## # # # # # # # # # # # # # # # # #
// # # ## ### ### ## # ### ### # # # # ## # # ## ### ### ## # #
$("#display").on("click", "a.userlink", (ev) => {
var data = $(ev.target).data();
const data = $(ev.target).data(),
$text = $("<div></div>");

$(`#display .text .user-${data.username}`).each((index, value) => $text.append($(value).clone()));

if (profileWin) {
profileWin.emit("profile-set", data.channel, data.username, $(`#display .text .user-${data.username}`).map((index, el) => $(el).html()).toArray().join("")); // TODO: Consolidate user data, possibly into the channel user array.
profileWin.emit("profile-set", data.channel, data.username, $text.html());
} else {
profileWin = new electron.remote.BrowserWindow({width: 640, height: 480, resizable: false, title: `Hyperdrive Toolkit - Profile - ${data.username} on ${data.channel}`});

profileWin.on("profile-get", () => {
profileWin.emit("profile-set", data.channel, data.username, $(`#display .text .user-${data.username}`).map((index, el) => $(el).html()).toArray().join("")); // TODO: Consolidate user data, possibly into the channel user array.
profileWin.emit("profile-set", data.channel, data.username, $text.html());
profileWin.emit("chat-settings", win.data.appSettings.data.chat);
});

Oops, something went wrong.

0 comments on commit 31bd6b9

Please sign in to comment.