From 0ca42d0288ccc77a61b06a2465f8fa5bc9381e67 Mon Sep 17 00:00:00 2001 From: iCrawl Date: Fri, 24 Nov 2017 04:31:18 +0100 Subject: [PATCH] fix: only send a new presence if the user is writing in a new file --- src/extension.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index b8223ce..735ebb0 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -21,6 +21,7 @@ let config; let reconnect: NodeJS.Timer; // Define the reconnect counter and its type. let reconnectCounter = 0; +let lastKnownFileName: string; // `Activate` is fired when the extension is enabled. This SHOULD only fire once. export function activate(context: ExtensionContext) { @@ -116,6 +117,8 @@ function destroyRPC(): void { function setActivity(): void { // Do not continue if RPC isn't initalized. if (!rpc) return; + if (window.activeTextEditor && window.activeTextEditor.document.fileName === lastKnownFileName) return; + lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : ''; // Create a JSON Object with the user's activity information. const activity = { @@ -142,3 +145,5 @@ function setActivity(): void { // Update the user's activity to the `activity` variable. rpc.setActivity(activity); } + +process.on('unhandledRejection', err => console.error(err));