fix: name of undefined when no workspace could be found
This commit is contained in:
parent
36f326f7c1
commit
8f5be47e44
2 changed files with 20 additions and 6 deletions
|
@ -73,6 +73,11 @@
|
||||||
"default": "Idling.",
|
"default": "Idling.",
|
||||||
"description": "Custom string for the state section of the rich presence when idling"
|
"description": "Custom string for the state section of the rich presence when idling"
|
||||||
},
|
},
|
||||||
|
"discord.workspaceNotFound": {
|
||||||
|
"type": "string",
|
||||||
|
"default": "No workspace.",
|
||||||
|
"description": "Custom string for the state section of the rich presence when no workspace is found"
|
||||||
|
},
|
||||||
"discord.largeImage": {
|
"discord.largeImage": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"default": "",
|
"default": "",
|
||||||
|
|
|
@ -126,14 +126,23 @@ function setActivity(): void {
|
||||||
if (!rpc) return;
|
if (!rpc) return;
|
||||||
if (window.activeTextEditor && window.activeTextEditor.document.fileName === lastKnownFileName) return;
|
if (window.activeTextEditor && window.activeTextEditor.document.fileName === lastKnownFileName) return;
|
||||||
lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null;
|
lastKnownFileName = window.activeTextEditor ? window.activeTextEditor.document.fileName : null;
|
||||||
|
|
||||||
|
const details = window.activeTextEditor
|
||||||
|
? config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))
|
||||||
|
: config.get('detailsIdle');
|
||||||
|
const checkState = window.activeTextEditor
|
||||||
|
? Boolean(workspace.getWorkspaceFolder(window.activeTextEditor.document.uri))
|
||||||
|
: false;
|
||||||
|
const state = window.activeTextEditor
|
||||||
|
? checkState
|
||||||
|
? config.get('workspace').replace('{workspace}', workspace.getWorkspaceFolder(window.activeTextEditor.document.uri).name)
|
||||||
|
: config.get('workspaceNotFound')
|
||||||
|
: config.get('workspaceIdle');
|
||||||
|
|
||||||
// Create a JSON Object with the user's activity information.
|
// Create a JSON Object with the user's activity information.
|
||||||
const activity = {
|
const activity = {
|
||||||
details: window.activeTextEditor
|
details,
|
||||||
? config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))
|
state,
|
||||||
: config.get('detailsIdle'),
|
|
||||||
state: window.activeTextEditor
|
|
||||||
? config.get('workspace').replace('{workspace}', workspace.getWorkspaceFolder(window.activeTextEditor.document.uri).name)
|
|
||||||
: config.get('workspaceIdle'),
|
|
||||||
startTimestamp: new Date().getTime() / 1000,
|
startTimestamp: new Date().getTime() / 1000,
|
||||||
largeImageKey: window.activeTextEditor
|
largeImageKey: window.activeTextEditor
|
||||||
? extname(basename(window.activeTextEditor.document.fileName)).substring(1)
|
? extname(basename(window.activeTextEditor.document.fileName)).substring(1)
|
||||||
|
|
Loading…
Reference in a new issue