From 003c91ea62b1ee9e5b0ac610026b2cb58f76f169 Mon Sep 17 00:00:00 2001 From: joelthorner Date: Mon, 9 Sep 2019 20:07:52 +0200 Subject: [PATCH] Fix multiple open windows by TicketConsume (Zendesk) #188 --- js/background.js | 39 +++++++++++++---------------- js/inject/zendesk/ticket-consume.js | 1 - js/options/changelog.js | 6 +++++ manifest.json | 2 +- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/js/background.js b/js/background.js index b98f54c4..5f158920 100644 --- a/js/background.js +++ b/js/background.js @@ -86,23 +86,24 @@ chrome.runtime.onInstalled.addListener(function (details) { // TicketConsume system function openTicketConsumeTab() { - chrome.windows.create({ - url: 'http://192.168.110.109:12853/zdreports/rtm.cfm?TicketConsume=true', - // url: 'https://joelthorner.github.io/temp/?TicketConsume=true', - state: 'minimized', - // focused: true - }, function (window) { - // console.log(window); - - // chrome.tabs.create({ - // // url: 'http://192.168.110.109:12853/zdreports/rtm.cfm?TicketConsume=true', - // url: 'https://joelthorner.github.io/temp/?TicketConsume=true', - // active: false, - // index: 0, - // pinned: true, - // windowId: window.id - // }); + chrome.tabs.query({ + url: '*://zdreports/rtm.cfm?TicketConsume=true' + // url: '*://joelthorner.github.io/temp/?TicketConsume=true' + }, function (tabs) { + if (!tabs.length) { + chrome.tabs.create({ + url: 'http://192.168.110.109:12853/zdreports/rtm.cfm?TicketConsume=true', + // url: 'https://joelthorner.github.io/temp/?TicketConsume=true', + active: false, + pinned: true, + }); + } else { + tabs.forEach(tab => { + chrome.tabs.reload(tab.id); + }); + } }); + } chrome.runtime.onMessage.addListener(function (message, sender) { if (message.name == 'openTicketConsumeTab') { @@ -112,12 +113,6 @@ chrome.runtime.onMessage.addListener(function (message, sender) { chrome.tabs.query({ url: '*://tlgcommercehelp.zendesk.com/*' }, function (tabs) { tabs.forEach(tab => { chrome.tabs.sendMessage(tab.id, { data: message.data }); - chrome.tabs.query({ - url: '*://zdreports/rtm.cfm?TicketConsume=true' - // url: '*://joelthorner.github.io/temp/?TicketConsume=true' - }, function (tabs) { - tabs.forEach(tab => { chrome.tabs.remove(tab.id) }); - }); }); }); } diff --git a/js/inject/zendesk/ticket-consume.js b/js/inject/zendesk/ticket-consume.js index 70249246..970b4762 100644 --- a/js/inject/zendesk/ticket-consume.js +++ b/js/inject/zendesk/ticket-consume.js @@ -63,7 +63,6 @@ TicketConsume = { chrome.runtime.sendMessage({ name: 'openTicketConsumeTab' }); } catch (error) { console.log(error); - } } }); diff --git a/js/options/changelog.js b/js/options/changelog.js index 70368f4c..e9f0209d 100644 --- a/js/options/changelog.js +++ b/js/options/changelog.js @@ -1,5 +1,11 @@ const CHANGELOG = [ { + version: 'v2.3.15', date: '10 Sep 2019', + lines: [ + 'FIXED Fix multiple open windows by TicketConsume (Zendesk) #188', + 'IMPROVED Gulp automatic version replace (dev) #189' + ] + }, { version: 'v2.3.14', date: '04 Sep 2019', lines: [ 'FIXED Ticket consume get wrong data #184', diff --git a/manifest.json b/manifest.json index 7bc9c4c6..18b038c9 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "__MSG_appName__", - "version": "2.3.14", + "version": "2.3.15", "manifest_version": 2, "author": "joelthorner", "description": "__MSG_appDesc__",