From 643f98225ffb50ccb20b65645346fbd9218d0b97 Mon Sep 17 00:00:00 2001 From: IJustDev Date: Fri, 14 Jun 2019 13:22:17 +0200 Subject: [PATCH] FIXED #3 Issue is now opened just once --- CHANGELOG.md | 6 ++++++ src/extension.ts | 17 ++++++++++++++++- src/issue.ts | 3 --- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c27a49d..a52330c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -41,6 +41,12 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how ### Added: - Label dependent icons now allow the user to use the colors from the Gitea server +## [0.0.7] - 2019-06-14 +### Added: +- Every issue can now be opened just once at a time +### Refactored: +- Removed "filename" from `issue.ts` `labelDependentIcon()` + ## [Unreleased] diff --git a/src/extension.ts b/src/extension.ts index 9a6720c..e1a698a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -10,7 +10,7 @@ export function activate(context: vscode.ExtensionContext) { initializeIssueTracker(); }); context.subscriptions.push(disposable); - + let openIssues: Array = []; const openIssuesProvider = new OpenIssuesProvider(); const closedIssuesProvider = new ClosedIssuesProvider(); @@ -24,10 +24,25 @@ export function activate(context: vscode.ExtensionContext) { // }); vscode.commands.registerCommand('giteaIssues.openIssue', (issue: Issue) => { + for (let i = 0; i !== openIssues.length; i++) { + let openIssue = openIssues[i]; + if (openIssue.issueId === issue.issueId) { + return; + } + } const panel = vscode.window.createWebviewPanel('issue', issue.label, vscode.ViewColumn.Active, {}); panel.webview.html = showIssueHTML(issue); + openIssues.push(issue); + panel.onDidDispose(event => { + for (let i = 0; i !== openIssues.length; i++) { + let openIssue = openIssues[i]; + if (openIssue.issueId === issue.issueId) { + openIssues.splice(openIssues.indexOf(issue), 1); + } + } + }); }); vscode.commands.registerCommand('giteaIssues.refreshIssues', () => { diff --git a/src/issue.ts b/src/issue.ts index 8147acd..e5f2932 100644 --- a/src/issue.ts +++ b/src/issue.ts @@ -34,12 +34,9 @@ export class Issue extends vscode.TreeItem { } labelDependentIcon(dark: boolean = false): string { - let filename = ""; if (this.labels.length === 0) { - filename = "issue"; return path.join(__filename, '..', '..', 'media', 'issue.svg'); } else { - filename = this.labels[0].name; return path.join(vscode.workspace.rootPath as string, '.gitea', 'label_pictures', this.labels[0].name + ".svg"); } }