From f425b9842f9e20282218331099ef6a07094a5f71 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Tue, 8 Dec 2020 22:57:09 -0500 Subject: [PATCH] Updated twitch chat component to support user colors and to auto open if the chat has already been downloaded --- backend/app.js | 2 ++ backend/twitch.js | 6 ++++-- src/app/components/twitch-chat/twitch-chat.component.html | 4 ++-- src/app/player/player.component.html | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/backend/app.js b/backend/app.js index e50dc8d..0cdd414 100644 --- a/backend/app.js +++ b/backend/app.js @@ -2037,6 +2037,8 @@ app.post('/api/getFile', optionalJwt, function (req, res) { if (!file && type) file = db.get(`files.${type}`).find({uid: uid}).value(); } + // check if chat exists for twitch videos + if (file['url'].includes('twitch.tv')) file['chat_exists'] = fs.existsSync(file['path'].substring(0, file['path'].length - 4) + '.twitch_chat.json'); if (file) { res.send({ diff --git a/backend/twitch.js b/backend/twitch.js index 62c390d..fb05fbb 100644 --- a/backend/twitch.js +++ b/backend/twitch.js @@ -28,7 +28,8 @@ async function getCommentsForVOD(clientID, vodId) { created_at: acctCreated }, message: { - body: msg + body: msg, + user_color: user_color } } = c; @@ -49,7 +50,8 @@ async function getCommentsForVOD(clientID, vodId) { timestamp: timestamp, timestamp_str: timestamp_str, name: name, - message: msg + message: msg, + user_color: user_color }); // let line = `${timestamp},${msgCreated.format(tsFormat)},${name},${_id},"${msg.replace(/"/g, '""')}",${acctCreated.format(tsFormat)}`; // return line; diff --git a/src/app/components/twitch-chat/twitch-chat.component.html b/src/app/components/twitch-chat/twitch-chat.component.html index 7ad40fc..634cac6 100644 --- a/src/app/components/twitch-chat/twitch-chat.component.html +++ b/src/app/components/twitch-chat/twitch-chat.component.html @@ -1,11 +1,11 @@
Twitch Chat
- {{chat.timestamp_str}} - {{chat.name}}: {{chat.message}} + {{chat.timestamp_str}} - {{chat.name}}: {{chat.message}}
- + \ No newline at end of file diff --git a/src/app/player/player.component.html b/src/app/player/player.component.html index c70800d..6774ace 100644 --- a/src/app/player/player.component.html +++ b/src/app/player/player.component.html @@ -13,7 +13,7 @@ {{playlist_item.label}} - +