Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
cairthenn committed Mar 23, 2019
2 parents 4fb902d + a60374a commit bef26c9
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 71 deletions.
17 changes: 0 additions & 17 deletions get-emote-sets.js

This file was deleted.

4 changes: 3 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ function launchApplication() {
window.show();
});

// window.webContents.toggleDevTools();
// if(process.env.NODE_ENV == 'dev') {
// window.webContents.toggleDevTools();
// }
window.loadFile('./dist/index.html');

if(!firstRun && process.env.NODE_ENV != 'dev' && process.platform == 'win32') {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Blink",
"version": "1.2.5",
"version": "1.2.6",
"description": "Blink",
"license": "GPL-3.0",
"main": "main.js",
Expand Down
13 changes: 5 additions & 8 deletions src/app/chat/chat.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,19 @@
<div class="cc-flex cc-flex-column cc-full-height cc-full-width">

<div class="cc-flex-none">
<div class="cc-header cc-flex cc-flex-row cc-align-items-center cc-justify-content-between cc-pd-x-1 cc-alt-background">
<div class="cc-align-items-center cc-align-middle cc-flex cc-font-size-6 cc-overflow-hidden cc-mg-r-1">
<div class="cc-header cc-flex cc-flex-row cc-align-items-center cc-justify-content-between cc-pd-r-1 cc-pd-l-05 cc-alt-background">
<div class="cc-align-items-center cc-align-middle cc-flex cc-font-size-6 cc-overflow-hidden cc-mg-r-05">
<button mat-icon-button #tabButton (click)="drawer.toggle()" tabindex="-1">
<mat-icon aria-label="Close Tabs">{{drawer.opened ? "chevron_left" : "chevron_right"}}</mat-icon>
</button>
<img *ngIf="tab.channelInfo.logo" [src]="tab.channelInfo.logo" class="avatar-icon cc-inline cc-mg-r-05">
<img *ngIf="tab.channelInfo.logo" [src]="tab.channelInfo.logo" class="avatar-icon cc-inline cc-mg-x-05 ">
{{tab.channelDisplay}}
<span class="cc-pd-x-05" [style.color]="tab.streamInfo._id ? 'red' : 'grey'"></span>
<span *ngIf="tab.streamInfo.game" class="cc-font-size-8 cc-ellipsis">{{tab.streamInfo.game}}</span>
</div>

<button mat-button (click)="openSettings(tab)" class="cc-flex-none" tabindex="-1">
<div class="cc-flex cc-align-items-center">
<span class="cc-font-size-6">Settings&nbsp;</span>
<mat-icon aria-label="Settings">settings</mat-icon>
</div>
<button mat-icon-button (click)="openSettings(tab)" class="cc-flex-none" tabindex="-1">
<mat-icon aria-label="Settings">settings</mat-icon>
</button>
</div>
<mat-divider></mat-divider>
Expand Down
86 changes: 51 additions & 35 deletions src/app/twitch.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import CryptoJS from 'crypto-js';
import * as qs from 'querystring';
import { Web } from './web';

const twitchEmoteSets = require('../assets/emote-sets.json');

const authBase = 'https://id.twitch.tv/oauth2';
const authUrl = `${authBase}/authorize`;
const validateUrl = `${authBase}/validate`;
Expand All @@ -17,6 +15,7 @@ const clientId = 'ut8pnp247zcvfj7gga2lxo8kp2d9lz';

const badgeChannelUrl = 'https://badges.twitch.tv/v1/badges/channels/';
const badgeGlobalUrl = 'https://badges.twitch.tv/v1/badges/global/display';
const emoteSetUrl = 'https://api.twitchemotes.com/api/v4/sets'

const tmiInfo = 'https://tmi.twitch.tv/group/user/';
const twitchApi = 'https://api.twitch.tv';
Expand Down Expand Up @@ -114,6 +113,7 @@ export class TwitchService {
private channels: any = {};
private badges: any = {};
private emotes: any = {};
private setNames: any = {};
private validation: any = {};
private enckey: string;
private loggedIn: boolean;
Expand Down Expand Up @@ -308,6 +308,18 @@ export class TwitchService {
});
}

public getEmoteSets(sets: string[]) {
return Web.get(`${emoteSetUrl}?id=${sets.join()}`).then(results => {
return results.reduce((obj, item) => {
obj[item.set_id] = item;
return obj;
}, this.setNames);
}).catch(err => {
console.log(err);
return {};
});
}

public getEmotes(update?: boolean) {

const fetch = update || this.emotes ? this.needsUpdate(this.emoteCheck, 'emotes') : true;
Expand All @@ -320,40 +332,44 @@ export class TwitchService {
Authorization : `OAuth ${this.key}`
}
}).then(emotes => {
this.emotes.sets = Object.keys(emotes.emoticon_sets).map(id => {
const set = emotes.emoticon_sets[id];
const noRegex = set.reduce((arr, item) => {
item.userOnly = true;
item.type = 'twitch';
item.src = `https://static-cdn.jtvnw.net/emoticons/v1/${item.id}/1.0`;
item.lower = item.code.toLowerCase();

if (item.code in fixes) {
fixes[item.code].forEach(x => {
arr.push(Object.assign({}, item, { code: x }));
});
} else {
arr.push(item);
}

return arr;
}, []);
const setInfo = twitchEmoteSets[id] || {
set_id: id,
channel_name: `Unknown Set ${id}`,
channel_id: '0',
tier: 0,
};
return [ setInfo, noRegex ];
});
this.emotes.lookup = this.emotes.sets.reduce((obj, arr) => {
arr[1].forEach(e => {
obj[e.code] = e;
const keys = Object.keys(emotes.emoticon_sets);
return this.getEmoteSets(keys).then((sets) => {
console.log(sets);
this.emotes.sets = keys.map(id => {
const set = emotes.emoticon_sets[id];
const noRegex = set.reduce((arr, item) => {
item.userOnly = true;
item.type = 'twitch';
item.src = `https://static-cdn.jtvnw.net/emoticons/v1/${item.id}/1.0`;
item.lower = item.code.toLowerCase();

if (item.code in fixes) {
fixes[item.code].forEach(x => {
arr.push(Object.assign({}, item, { code: x }));
});
} else {
arr.push(item);
}

return arr;
}, []);
const setInfo = sets[id] || {
set_id: id,
channel_name: `Unknown Set ${id}`,
channel_id: '0',
tier: 0,
};
return [ setInfo, noRegex ];
});
return obj;
}, {});
this.emoteCheck = Date.now();
return this.emotes;
this.emotes.lookup = this.emotes.sets.reduce((obj, arr) => {
arr[1].forEach(e => {
obj[e.code] = e;
});
return obj;
}, {});
this.emoteCheck = Date.now();
return this.emotes;
});
});

}
Expand Down
8 changes: 0 additions & 8 deletions src/assets/emote-sets.json

This file was deleted.

0 comments on commit bef26c9

Please sign in to comment.