From dd3fa0c2b7713c251630ff1824634990f3664c80 Mon Sep 17 00:00:00 2001 From: Crawl Date: Wed, 19 Sep 2018 19:52:44 +0200 Subject: [PATCH] fix: local clients time offset fixes #92 --- package.json | 4 ++-- src/extension.ts | 6 +++--- yarn.lock | 20 +++++++++++++------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 00702fc..e0ad9fd 100644 --- a/package.json +++ b/package.json @@ -149,10 +149,10 @@ "theme": "dark" }, "dependencies": { - "discord-rpc": "icrawl/rpc#ubuntu" + "discord-rpc": "icrawl/rpc#unix_timestamp" }, "devDependencies": { - "@types/node": "^10.9.4", + "@types/node": "^10.10.1", "tslint": "^5.11.0", "typescript": "^3.0.3", "vscode": "^1.1.21" diff --git a/src/extension.ts b/src/extension.ts index 069d55e..dd14ad8 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -121,7 +121,7 @@ function initRPC(clientID: string, loud?: boolean): void { reconnectCounter = 0; setActivity(); // Set the activity once on ready - setTimeout(() => rpc.setActivity(activity), 500); + setTimeout(() => rpc.setActivity(activity).catch(err => console.error(`[Discord Presence]: ${err}`)), 500); // Make sure to listen to the close event and dispose and destroy everything accordingly. rpc.transport.once('close', async () => { if (!config.get('enabled')) return; @@ -139,7 +139,7 @@ function initRPC(clientID: string, loud?: boolean): void { // Update the config before updating the activity config = workspace.getConfiguration('discord'); setActivity(Boolean(config.get('workspaceElapsedTime'))); - rpc.setActivity(activity); + rpc.setActivity(activity).catch(err => console.error(`[Discord Presence]: ${err}`)); }, 15000); }); @@ -262,7 +262,7 @@ function setActivity(workspaceElapsedTime: boolean = false): void { activity = { details: generateDetails('detailsDebugging', 'detailsEditing', 'detailsIdle'), state: generateDetails('lowerDetailsDebugging', 'lowerDetailsEditing', 'lowerDetailsIdle'), - startTimestamp: window.activeTextEditor && previousTimestamp && workspaceElapsedTime ? previousTimestamp : window.activeTextEditor ? new Date().getTime() / 1000 : null, + startTimestamp: window.activeTextEditor && previousTimestamp && workspaceElapsedTime ? previousTimestamp : window.activeTextEditor ? new Date().getTime() : null, largeImageKey: largeImageKey ? largeImageKey.image || largeImageKey diff --git a/yarn.lock b/yarn.lock index 16e5905..be0d400 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,9 +2,9 @@ # yarn lockfile v1 -"@types/node@^10.9.4": - version "10.9.4" - resolved "https://registry.yarnpkg.com/@types/node/-/node-10.9.4.tgz#0f4cb2dc7c1de6096055357f70179043c33e9897" +"@types/node@^10.10.1": + version "10.10.1" + resolved "https://registry.yarnpkg.com/@types/node/-/node-10.10.1.tgz#d5c96ca246a418404914d180b7fdd625ad18eca6" ajv@^5.3.0: version "5.5.2" @@ -247,9 +247,15 @@ color-name@1.1.3: version "1.1.3" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" -combined-stream@1.0.6, combined-stream@~1.0.6: +combined-stream@1.0.6: version "1.0.6" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + resolved "http://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz#723e7df6e801ac5613113a7e445a9b69cb632818" + dependencies: + delayed-stream "~1.0.0" + +combined-stream@~1.0.6: + version "1.0.7" + resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.7.tgz#2d1d24317afb8abe95d6d2c0b07b57813539d828" dependencies: delayed-stream "~1.0.0" @@ -305,9 +311,9 @@ diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" -discord-rpc@icrawl/rpc#ubuntu: +discord-rpc@icrawl/rpc#unix_timestamp: version "3.0.0" - resolved "https://codeload.github.com/icrawl/rpc/tar.gz/b1d5c07600fdd05d3847a50551414f8448b6dfc4" + resolved "https://codeload.github.com/icrawl/rpc/tar.gz/f1d7eea1e7f9becb35f78d0c5a3b1cf26d57b0af" dependencies: node-fetch "^2.1.2" ws "^5.2.1"