Reload function changed to give response
This commit is contained in:
parent
912f2e8f30
commit
3092880ba6
1 changed files with 13 additions and 12 deletions
|
@ -70,7 +70,14 @@ export default class DiscordRPC {
|
|||
})
|
||||
}
|
||||
})
|
||||
ipcMain.on("reloadRPC", () => this.reload())
|
||||
ipcMain.handle("reloadRPC", (e) => {
|
||||
console.log(`[DiscordRPC][reload] Reloading DiscordRPC.`);
|
||||
if (this._client) {
|
||||
this._client.destroy()
|
||||
this._client = null
|
||||
}
|
||||
this.connect(true)
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -109,7 +116,7 @@ export default class DiscordRPC {
|
|||
* Connect to Discord RPC
|
||||
* @private
|
||||
*/
|
||||
private connect() {
|
||||
private connect(reload = false) {
|
||||
if (!this._utils.getStoreValue("general.discordrpc.enabled")) {
|
||||
return;
|
||||
}
|
||||
|
@ -126,6 +133,10 @@ export default class DiscordRPC {
|
|||
console.info(`[DiscordRPC][connect] Restoring activity cache.`);
|
||||
this._client.setActivity(this._activityCache)
|
||||
}
|
||||
|
||||
if (reload) {
|
||||
this._utils.getWindow().webContents.send("rpcReloaded", this._client.user)
|
||||
}
|
||||
})
|
||||
|
||||
// Login to Discord
|
||||
|
@ -258,14 +269,4 @@ export default class DiscordRPC {
|
|||
}
|
||||
return activity
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads DiscordRPC
|
||||
*/
|
||||
private reload() {
|
||||
if (this._client) {
|
||||
this._client.destroy()
|
||||
}
|
||||
this.connect()
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue