Skip to content

Commit

Permalink
Added more settings
Browse files Browse the repository at this point in the history
  • Loading branch information
HelloWorld017 committed Nov 28, 2017
1 parent cb91c3c commit 4236d9a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
File renamed without changes.
56 changes: 46 additions & 10 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ const initializeRpc = () => {
const updateConfig = (
i18n = atom.config.get('atom-discord.i18n'),
privacy = atom.config.get('atom-discord.privacy'),
showSmallIcon = atom.config.get('atom-discord.smallIconToggle')
behaviour = atom.config.get('atom-discord.behaviour')
) => {
const i18nValue = require(`../i18n/${i18n}.json`);

ipcRenderer.send('atom-discord.config-update', {
i18n: i18nValue,
privacy,
showSmallIcon
behaviour
});
};

Expand Down Expand Up @@ -85,7 +85,7 @@ atom.config.onDidChange('atom-discord.i18n', ({newValue}) => {
updateConfig(newValue);
});

atom.config.onDidChange('atom-discord.smallIconToggle', ({newValue}) => {
atom.config.onDidChange('atom-discord.behaviour', ({newValue}) => {
updateConfig()
});

Expand All @@ -102,11 +102,25 @@ module.exports = {
},

config: {
smallIconToggle: {
title: "Display small Atom logo",
behaviour: {
title: "Behaviour",
description: "",
type: "boolean",
default: true,
type: "object",
properties: {
smallIconToggle: {
title: "Display small Atom logo",
description: "",
type: "boolean",
default: true
},

updateTick: {
title: "Update tick",
description: "Interval between state update (ms)",
type: "number",
default: 3000
}
},
order: 1
},

Expand All @@ -123,22 +137,37 @@ module.exports = {

{
value: "en-US",
description: "English"
description: "English (United States)"
},

{
value: "fr-FR",
description: "French"
description: "French (France)"
},

{
value: "de-DE",
description: "German (Germany)"
},

{
value: "it-IT",
description: "Italian (Italy)"
},

{
value: "ko-KR",
description: "Korean"
description: "Korean (Korea)"
},

{
value: "pt-BR",
description: "Portuguese (Brazil)"
},

{
value: "ru-RU",
description: "Russian (Russia)"
}
],

Expand Down Expand Up @@ -169,6 +198,13 @@ module.exports = {
description: "Integrate type of files.",
type: "boolean",
default: true
},

sendElapsed: {
title: "Send elapsed time",
description: "Integrate elapsed time when you started coding.",
type: "boolean",
default: true
}
},

Expand Down
17 changes: 10 additions & 7 deletions src/send-discord.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ const {ipcMain} = require('electron');
const path = require('path');
const snekfetch = require("snekfetch")
const startTimestamp = new Date().getTime() / 1000;

let projectName = null;
let currEditor = null;
let largeImage = null;

let translations = {};
let privacySettings = {};
let showSmallIcon = true;
let behaviour = {};

let matchData;
let matchKeys = [];
Expand Down Expand Up @@ -69,19 +71,20 @@ const setupRpc = (Client) => {
const packet = {
state,
details,
startTimestamp,
largeImageKey: largeImageInner.icon,
largeImageText: largeImageInner.text,
largeImageText: largeImageInner.text
};

if(showSmallIcon) {
if(privacySettings.sendElapsed) packet.startTimestamp = startTimestamp;

if(behaviour.smallIconToggle) {
packet.smallImageKey = smallImageKey;
packet.smallImageText = getTranslation('atom-description')
}

rpc.setActivity(packet);

setTimeout(loop, 3000);
setTimeout(loop, behaviour.updateTick);
};

loop();
Expand Down Expand Up @@ -125,10 +128,10 @@ ipcMain.on('atom-discord.data-update', (event, arg) => {
}
});

ipcMain.on('atom-discord.config-update', (event, {i18n, privacy, showSmallIcon: _showSmallIcon}) => {
ipcMain.on('atom-discord.config-update', (event, {i18n, privacy, behaviour: _behaviour}) => {
translations = i18n;
privacySettings = privacy;
showSmallIcon = _showSmallIcon
behaviour = _behaviour
});

ipcMain.on('atom-discord.discord-setup', (event, arg) => {
Expand Down

0 comments on commit 4236d9a

Please sign in to comment.