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.",
|
||||
"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": {
|
||||
"type": "string",
|
||||
"default": "",
|
||||
|
|
|
@ -126,14 +126,23 @@ function setActivity(): void {
|
|||
if (!rpc) return;
|
||||
if (window.activeTextEditor && window.activeTextEditor.document.fileName === lastKnownFileName) return;
|
||||
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.
|
||||
const activity = {
|
||||
details: window.activeTextEditor
|
||||
? config.get('details').replace('{filename}', basename(window.activeTextEditor.document.fileName))
|
||||
: config.get('detailsIdle'),
|
||||
state: window.activeTextEditor
|
||||
? config.get('workspace').replace('{workspace}', workspace.getWorkspaceFolder(window.activeTextEditor.document.uri).name)
|
||||
: config.get('workspaceIdle'),
|
||||
details,
|
||||
state,
|
||||
startTimestamp: new Date().getTime() / 1000,
|
||||
largeImageKey: window.activeTextEditor
|
||||
? extname(basename(window.activeTextEditor.document.fileName)).substring(1)
|
||||
|
|
Loading…
Reference in a new issue