Skip to content

Commit

Permalink
1.0-beta5
Browse files Browse the repository at this point in the history
Add Caffeine Gold as a currency.
Remove build targets, as we only need one to build the .asar
Fix bug with chat not jumping down on long messages.
  • Loading branch information
e3ndr committed Jan 4, 2021
1 parent ba62841 commit ed05ce4
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
4 changes: 2 additions & 2 deletions app/js/caffeinated.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ const { app, ipcRenderer } = require("electron");
const { ipcMain, BrowserWindow } = require("electron").remote;
const windowStateKeeper = require("electron-window-state");

const PROTOCOLVERSION = 13;
const VERSION = "1.0-beta4";
const PROTOCOLVERSION = 14;
const VERSION = "1.0-beta5";

const koi = new Koi("wss://api.casterlabs.co/v2/koi");

Expand Down
21 changes: 19 additions & 2 deletions app/js/currencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const CURRENCY_TABLE = {

// Platforms
"Caffeine Credits": "CAFFEINE_CREDITS",
"Caffeine Gold": "CAFFEINE_GOLD",
"Twitch Bits": "TWITCH_BITS",

// Popular (?)
Expand Down Expand Up @@ -173,7 +174,7 @@ const CURRENCY_TABLE = {

const CURRENCIES = [];
const CURRENCY_TABLE_INVERTED = {};
const PSUEDO_CURRENCIES = ["CAFFEINE_CREDITS", "TWITCH_BITS", "DEFAULT"];
const PSUEDO_CURRENCIES = ["CAFFEINE_CREDITS", "CAFFEINE_GOLD", "TWITCH_BITS", "DEFAULT"];

Object.entries(CURRENCY_TABLE).forEach((currency) => {
CURRENCY_TABLE_INVERTED[currency[1]] = currency[0];
Expand All @@ -190,7 +191,19 @@ function formatCurrency(amount, currency) {
if (currency === "CAFFEINE_CREDITS") {
return `
<span>
<svg viewBox="0 0 16 16" fill="#C6F" style="height: .8em; width: auto; transform: translateY(.075em);">
<svg viewBox="0 0 16 16" fill="#C6F" style="height: .85em; width: auto; transform: translateY(.075em);">
<g fill-rule="evenodd">
<path d="M8 0a8 8 0 110 16A8 8 0 018 0zm0 .667a7.333 7.333 0 100 14.666A7.333 7.333 0 008 .667z"></path>
<circle cx="8" cy="8" r="6"></circle>
</g>
</svg>
${amount.toFixed(0)}
</span>
`;
} else if (currency === "CAFFEINE_GOLD") {
return `
<span>
<svg viewBox="0 0 16 16" fill="#FC0" style="height: .85em; width: auto; transform: translateY(.075em);">
<g fill-rule="evenodd">
<path d="M8 0a8 8 0 110 16A8 8 0 018 0zm0 .667a7.333 7.333 0 100 14.666A7.333 7.333 0 008 .667z"></path>
<circle cx="8" cy="8" r="6"></circle>
Expand Down Expand Up @@ -273,6 +286,8 @@ async function convertCurrency(amount, from, to) {

if (from === "CAFFEINE_CREDITS") {
usd = amount / 91; // Something we figured out, no official source for this though.
} else if (from === "CAFFEINE_GOLD") {
usd = (amount * 3) / 91;
} else if (from === "TWITCH_BITS") {
usd = amount / 100; // https://twitchbitstousd.com/
} else {
Expand All @@ -281,6 +296,8 @@ async function convertCurrency(amount, from, to) {

if (to === "CAFFEINE_CREDITS") {
result = usd * 91; // Something we figured out, no official source for this though.
} else if (to === "CAFFEINE_GOLD") {
result = (usd * 91) / 3;
} else if (to === "TWITCH_BITS") {
result = usd * 100; // https://twitchbitstousd.com/
} else {
Expand Down
7 changes: 1 addition & 6 deletions app/modules/modules/chatdisplaymodule.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ MODULES.moduleClasses["casterlabs_chat_display"] = class {
this.util.updateViewers();
});

koi.addEventListener("close", () => {
this.util.addStatus("", "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==", "#FFFFFF", "connection_lost");
});

}

init() {
Expand Down Expand Up @@ -468,7 +464,6 @@ class VerticalChatUtil {
case "leave": text.innerText = "left the stream."; break;
case "join": text.innerText = "joined the stream."; break;
case "follow": text.innerText = "started following."; break;
case "connection_lost": text.innerText = "Connection lost, reconnecting."; break;
}

div.classList.add("vcchatmessage");
Expand All @@ -492,7 +487,7 @@ class VerticalChatUtil {
const scrollOffset = this.module.page.parentNode.scrollHeight - this.module.page.parentNode.scrollTop;
const height = this.module.page.parentNode.offsetHeight;

return (scrollOffset - height) < 50;
return (scrollOffset - height) < 100;
}

tryJump() {
Expand Down
22 changes: 1 addition & 21 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,6 @@
"icon": "media/app_icon.icns",
"appId": "casterlabs.caffeinated",
"artifactName": "Caffeinated-${version}-${os}-setup.${ext}",
"dmg": {
"contents": [
{
"x": 110,
"y": 150
},
{
"x": 240,
"y": 150,
"type": "link",
"path": "/Applications"
}
]
},
"linux": {
"target": [
"AppImage",
"deb"
]
},
"win": {
"icon": "media/app_icon.ico",
"target": [
Expand All @@ -61,4 +41,4 @@
"electron": "^8.2.1",
"electron-builder": "latest"
}
}
}

0 comments on commit ed05ce4

Please sign in to comment.