From 0e53a20b235f5edd5ec98aab1c9daad48a88d46f Mon Sep 17 00:00:00 2001 From: dizzy Date: Thu, 11 Nov 2021 18:40:50 -0800 Subject: [Vue] Cannot return IAngularEvent in $emit wrapper unfortunately. (#18296) * Cannot return IAngularEvent in $emit wrapper unfortunately. * built vue files --- plugins/CoreHome/vue/src/Matomo/Matomo.adapter.ts | 4 +++- plugins/CoreHome/vue/src/Matomo/Matomo.ts | 7 +++---- 2 files changed, 6 insertions(+), 5 deletions(-) (limited to 'plugins/CoreHome/vue/src/Matomo') diff --git a/plugins/CoreHome/vue/src/Matomo/Matomo.adapter.ts b/plugins/CoreHome/vue/src/Matomo/Matomo.adapter.ts index 8ea591fca7..0ab71e38ef 100644 --- a/plugins/CoreHome/vue/src/Matomo/Matomo.adapter.ts +++ b/plugins/CoreHome/vue/src/Matomo/Matomo.adapter.ts @@ -18,7 +18,9 @@ function initPiwikService(piwik: PiwikGlobal, $rootScope: IRootScopeService) { // overwrite $rootScope so all events also go through Matomo.postEvent(...) too. ($rootScope as any).$oldEmit = $rootScope.$emit; // eslint-disable-line $rootScope.$emit = function emitWrapper(name: string, ...args: any[]): IAngularEvent { // eslint-disable-line - return Matomo.postEvent(name, ...args); + Matomo.postEvent(name, ...args); + // can't always get the result. it's not really used in angularjs though, so it should be ok. + return null as unknown as IAngularEvent; }; ($rootScope as any).$oldBroadcast = $rootScope.$broadcast; // eslint-disable-line diff --git a/plugins/CoreHome/vue/src/Matomo/Matomo.ts b/plugins/CoreHome/vue/src/Matomo/Matomo.ts index e2a00bc3b1..30b821f403 100644 --- a/plugins/CoreHome/vue/src/Matomo/Matomo.ts +++ b/plugins/CoreHome/vue/src/Matomo/Matomo.ts @@ -5,7 +5,6 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -import { IAngularEvent } from 'angular'; import Periods from '../Periods/Periods'; let originalTitle: string; @@ -61,13 +60,13 @@ piwik.postEventNoEmit = function postEventNoEmit( piwik.postEvent = function postMatomoEvent( eventName: string, ...args: any[] // eslint-disable-line -): IAngularEvent { +): void { piwik.postEventNoEmit(eventName, ...args); // required until angularjs is removed - angular.element(() => { + window.angular.element(() => { const $rootScope = piwik.helper.getAngularDependency('$rootScope') as any; // eslint-disable-line - return $rootScope.$oldEmit(eventName, ...args); + $rootScope.$oldEmit(eventName, ...args); }); }; -- cgit v1.2.3