Rewrote frontend download download function to make use of forked processes. This means that the download runs in full async (essentially in a separate thread). Updated the discord wrapper to be more dynamic. Updated auth manager to use async/await.
This commit is contained in:
@@ -3,16 +3,15 @@ const {Client} = require('discord-rpc')
|
||||
const ConfigManager = require('./configmanager.js')
|
||||
|
||||
let rpc
|
||||
let activity
|
||||
|
||||
exports.initRPC = function(genSettings, servSettings){
|
||||
rpc = new Client({ transport: 'ipc' });
|
||||
exports.initRPC = function(genSettings, servSettings, initialDetails = 'Waiting for Client..'){
|
||||
rpc = new Client({ transport: 'ipc' })
|
||||
|
||||
rpc.on('ready', () => {
|
||||
const activity = {
|
||||
// state = top text
|
||||
// details = bottom text
|
||||
activity = {
|
||||
details: initialDetails,
|
||||
state: 'Server: ' + servSettings.shortId,
|
||||
details: 'Exploring the wall',
|
||||
largeImageKey: servSettings.largeImageKey,
|
||||
largeImageText: servSettings.largeImageText,
|
||||
smallImageKey: genSettings.smallImageKey,
|
||||
@@ -33,8 +32,18 @@ exports.initRPC = function(genSettings, servSettings){
|
||||
})
|
||||
}
|
||||
|
||||
exports.updateDetails = function(details){
|
||||
if(activity == null){
|
||||
console.error('Discord RPC is not initialized and therefore cannot be updated.')
|
||||
}
|
||||
activity.details = details
|
||||
rpc.setActivity(activity)
|
||||
}
|
||||
|
||||
exports.shutdownRPC = function(){
|
||||
if(!rpc) return
|
||||
rpc.setActivity({})
|
||||
rpc.destroy()
|
||||
rpc = null
|
||||
activity = null
|
||||
}
|
||||
Reference in New Issue
Block a user