diff --git a/package.json b/package.json index 57cc60ea8..0d6dc3620 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "trilium", "productName": "Trilium Notes", "description": "Trilium Notes", - "version": "0.50.1", + "version": "0.50.2", "license": "AGPL-3.0-only", "main": "electron.js", "bin": { diff --git a/src/becca/entities/etapi_token.js b/src/becca/entities/etapi_token.js index 04c882536..170e79bc8 100644 --- a/src/becca/entities/etapi_token.js +++ b/src/becca/entities/etapi_token.js @@ -42,7 +42,9 @@ class EtapiToken extends AbstractEntity { /** @type {boolean} */ this.isDeleted = !!row.isDeleted; - this.becca.etapiTokens[this.etapiTokenId] = this; + if (this.etapiTokenId) { + this.becca.etapiTokens[this.etapiTokenId] = this; + } } init() { diff --git a/src/public/app/dialogs/options/etapi.js b/src/public/app/dialogs/options/etapi.js index 2246d3ecd..aba500d44 100644 --- a/src/public/app/dialogs/options/etapi.js +++ b/src/public/app/dialogs/options/etapi.js @@ -48,46 +48,46 @@ const TPL = ` export default class EtapiOptions { constructor() { $("#options-etapi").html(TPL); - + $("#create-etapi-token").on("click", async () => { const promptDialog = await import('../../dialogs/prompt.js'); const tokenName = await promptDialog.ask({ title: "New ETAPI token", - message: "Please enter new token's name", - defaultValue: "new token" + message: "Please enter new token's name", + defaultValue: "new token" }); - + if (!tokenName.trim()) { alert("Token name can't be empty"); return; } - - const {token} = await server.post('etapi-tokens', {tokenName}); - await promptDialog.ask({ + const {authToken} = await server.post('etapi-tokens', {tokenName}); + + await promptDialog.ask({ title: "ETAPI token created", - message: 'Copy the created token into clipboard. Trilium stores the token hashed and this is the last time you see it.', - defaultValue: token + message: 'Copy the created token into clipboard. Trilium stores the token hashed and this is the last time you see it.', + defaultValue: authToken }); - + this.refreshTokens(); }); this.refreshTokens(); } - + async refreshTokens() { const $noTokensYet = $("#no-tokens-yet"); const $tokensTable = $("#tokens-table"); - + const tokens = await server.get('etapi-tokens'); - + $noTokensYet.toggle(tokens.length === 0); $tokensTable.toggle(tokens.length > 0); const $tokensTableBody = $tokensTable.find("tbody"); $tokensTableBody.empty(); - + for (const token of tokens) { $tokensTableBody.append( $("") @@ -112,7 +112,7 @@ export default class EtapiOptions { }); await server.patch(`etapi-tokens/${etapiTokenId}`, {name: tokenName}); - + this.refreshTokens(); } diff --git a/src/public/app/dialogs/prompt.js b/src/public/app/dialogs/prompt.js index c4e03b6b1..94a8e9c46 100644 --- a/src/public/app/dialogs/prompt.js +++ b/src/public/app/dialogs/prompt.js @@ -13,9 +13,9 @@ let shownCb; export function ask({ title, message, defaultValue, shown }) { shownCb = shown; - + $("#prompt-title").text(title || "Prompt"); - + $question = $("