Permalink
Browse files

Week 17, error on unable to edit channel.

  • Loading branch information...
roncli committed Aug 22, 2017
1 parent 514e938 commit 6ac42bd21ace4495369ffcd875a77660f40c4a34
Showing with 61 additions and 15 deletions.
  1. +1 −0 app/site/editchannel.htm
  2. +35 −13 app/site/js/editchannel.js
  3. +9 −1 app/site/js/index.js
  4. +16 −1 app/site/modules/chat/twitch/index.js
@@ -16,6 +16,7 @@
Game: <input type="text" id="game" /><br />
<button id="update">Update</button>
</div>
<div class="error text-danger" style="text-align: center;"></div>
</div>
</body>
</html>
@@ -1,12 +1,12 @@
const electron = require("electron"),
win = electron.remote.getCurrentWindow();

// # # # # # ## #
// # # # # #
// # # ## ### ## ### ## ### ## ### ## ### ### ### ### ## # ### ## ###
// # # # # # # # # # # ## # # # # # # # # # # # # # # ## # #### ## # ## #
// #### # # # # # # # ## # # # # # # # # ## # # # # ## # ## ## #
// #### ### # # ## # # ## ### ### ## ## # # # # # # # # ## ### ### ## ##
// # # # # # ## #
// # # # # #
// # # ## ### ## ### ## ### ## ### ## ### ### ### ### ## # ### ## ###
// # # # # # # # # # # ## # # # # # # # # # # # # # # ## # #### ## # ## #
// #### # # # # # # # ## # # # # # # # # ## # # # # ## # ## ## #
// #### ### # # ## # # ## ### ### ## ## # # # # # # # # ## ### ### ## ##
win.on("editchannel-set", (channel, title, game) => {
win.channel = channel;

@@ -17,17 +17,39 @@ win.on("editchannel-set", (channel, title, game) => {
$(".channel").text(channel);
});

// # # # # #
// ### # # # # #
// # # # ### ## ## # # # # ## ### ### # ### ## ### ### # #
// ### # # # # # # # # #### # ## # # # # # # # ## # # # # # #
// # # # # # # # # # # # # ## # # # # ## # ## # ## # # # #
// ### # ### ## ## ### # # ## # # ## # ## # ## # # ### #
// #
// # # # # # ## # ## # # # ##
// # # # # # # # #
// # # ## ### ## ### ## ### ## ### ## ### ### ### ### ## # ## ### # # ### # ## ### ## ### ### ### ### ## #
// # # # # # # # # # # ## # # # # # # # # # # # # # # ## # #### # # # # # # # # # # # # # # # # # # # # # ## #
// #### # # # # # # # ## # # # # # # # # ## # # # # ## # # # # # # # ## # # # # # # # # ## # # # # ## #
// #### ### # # ## # # ## ### ### ## ## # # # # # # # # ## ### ### # # # # # ### ### ### ## # # # # # # # # ## ###
win.on("editchannel-invalidchannel", () => {
$(".error").text("You do not have permission to edit this channel.").addClass("text-danger");
});

// # # # # # ## #
// # # # # #
// # # ## ### ## ### ## ### ## ### ## ### ### ### ### ## # ## # #
// # # # # # # # # # # ## # # # # # # # # # # # # # # ## # #### # # ##
// #### # # # # # # # ## # # # # # # # # ## # # # # ## # # # # #
// #### ### # # ## # # ## ### ### ## ## # # # # # # # # ## ### ## # #

win.on("editchannel-ok", () => {
$(".error").text("Channel updated.").removeClass("text-danger");
});

// # # # # #
// ### # # # # #
// # # # ### ## ## # # # # ## ### ### # ### ## ### ### # #
// ### # # # # # # # # #### # ## # # # # # # # ## # # # # # #
// # # # # # # # # # # # # ## # # # # ## # ## # ## # # # #
// ### # ### ## ## ### # # ## # # ## # ## # ## # # ### #
// #
$(document).ready(() => {
win.emit("editchannel-get");

$("#update").on("click", () => {
$(".error").text();
win.emit("updatechannel", win.channel, $("#title").val(), $("#game").val());
});
});
@@ -820,7 +820,15 @@ $(document).ready(() => {
client.setStatus(channel, {status: title, game}).then((channelData) => {
channels[channelName].channel = channelData;
Index.updateTitle(channelName);
}).catch(console.log);

if (editChannelWin) {
editChannelWin.emit("editchannel-ok");
}
}).catch((err) => {
if (editChannelWin) {
editChannelWin.emit("editchannel-invalidchannel");
}
});
});

editChannelWin.on("closed", () => {
@@ -181,7 +181,17 @@ class Twitch extends Chat {
userstate.color = defaultColors[(userstate.username.charCodeAt(0) + userstate.username.charCodeAt(userstate.username.length - 1)) % defaultColors.length];
}

twitch.emit("message", channel, userstate.username, userstate.color, userstate["display-name"], userstate.badges, span.html(), text);
switch (userstate["message-type"]) {
case "chat":
twitch.emit("message", channel, userstate.username, userstate.color, userstate["display-name"], userstate.badges, span.html(), text);
break;
case "whisper":
twitch.emit("whisper", channel, userstate.username, userstate.color, userstate["display-name"], userstate.badges, span.html(), text);
break;
default:
console.log("WARNING: Missing message-type", channel, userstate, text, self);
break;
}
});

twitch.tmi.on("join", (channel, username, self) => {
@@ -572,6 +582,11 @@ class Twitch extends Chat {

return new Promise((resolve, reject) => {
twitch.api.updateChannel(channel, twitch.accessToken, {channel: status}, (err, channel) => {
if (typeof channel === "string") {
reject("Invalid channel.");
return;
}

if (err) {
reject(err);
return;

0 comments on commit 6ac42bd

Please sign in to comment.