From 90576570e2841e908e68b43b63d5f902fe932f54 Mon Sep 17 00:00:00 2001 From: Devin Binnie <52460000+devinbinnie@users.noreply.github.com> Date: Mon, 25 Apr 2022 17:18:23 -0400 Subject: [PATCH] [MM-43632] Ensure handleURLView is called when removing the target URL (#2074) --- src/main/views/MattermostView.test.js | 8 +++++++- src/main/views/MattermostView.ts | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/views/MattermostView.test.js b/src/main/views/MattermostView.test.js index 2cc3d007..00251873 100644 --- a/src/main/views/MattermostView.test.js +++ b/src/main/views/MattermostView.test.js @@ -315,7 +315,13 @@ describe('main/views/MattermostView', () => { it('should not emit tooltip URL if internal', () => { mattermostView.handleUpdateTarget(null, 'http://server-1.com/path/to/channels'); - expect(mattermostView.emit).not.toHaveBeenCalled(); + expect(mattermostView.emit).toHaveBeenCalled(); + expect(mattermostView.emit).not.toHaveBeenCalledWith(UPDATE_TARGET_URL, 'http://server-1.com/path/to/channels'); + }); + + it('should still emit even if URL is blank', () => { + mattermostView.handleUpdateTarget(null, ''); + expect(mattermostView.emit).toHaveBeenCalled(); }); }); diff --git a/src/main/views/MattermostView.ts b/src/main/views/MattermostView.ts index 36e14b91..1b210007 100644 --- a/src/main/views/MattermostView.ts +++ b/src/main/views/MattermostView.ts @@ -360,6 +360,8 @@ export class MattermostView extends EventEmitter { log.silly('MattermostView.handleUpdateTarget', {tabName: this.tab.name, url}); if (url && !urlUtils.isInternalURL(urlUtils.parseURL(url), this.tab.server.url)) { this.emit(UPDATE_TARGET_URL, url); + } else { + this.emit(UPDATE_TARGET_URL); } }