From 859f94bf982a99447eb25e57ce623794d2a885a2 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 10 May 2024 14:38:02 +0200 Subject: [PATCH 1/3] MOBILE-4470 tabs: Fix route loaded when changing main menu tabs When using sub-routes like with core-tabs-outlet (e.g. participants), going back to the main menu tab set the main menu route as the current one instead of the sub-route and this caused problems with split view. --- src/core/components/tabs-outlet/tabs-outlet.ts | 9 +++++++++ src/core/singletons/path.ts | 18 ++++++++++++++++++ src/core/singletons/tests/path.test.ts | 9 +++++++++ 3 files changed, 36 insertions(+) diff --git a/src/core/components/tabs-outlet/tabs-outlet.ts b/src/core/components/tabs-outlet/tabs-outlet.ts index 0deddc47e..92c2d696d 100644 --- a/src/core/components/tabs-outlet/tabs-outlet.ts +++ b/src/core/components/tabs-outlet/tabs-outlet.ts @@ -30,6 +30,7 @@ import { StackDidChangeEvent } from '@ionic/angular/common/directives/navigation import { CoreNavigator } from '@services/navigator'; import { CoreTabBase, CoreTabsBaseComponent } from '@classes/tabs'; import { CoreDirectivesRegistry } from '@singletons/directives-registry'; +import { CorePath } from '@singletons/path'; /** * This component displays some top scrollable tabs that will autohide on vertical scroll. @@ -143,6 +144,14 @@ export class CoreTabsOutletComponent extends CoreTabsBaseComponent= pathSplit.length) { + return false; + } + + return !ancestorSplit.some((value, index) => value !== pathSplit[index]); + } + } diff --git a/src/core/singletons/tests/path.test.ts b/src/core/singletons/tests/path.test.ts index 9cee687e0..2800b79ef 100644 --- a/src/core/singletons/tests/path.test.ts +++ b/src/core/singletons/tests/path.test.ts @@ -52,4 +52,13 @@ describe('CorePath', () => { expect(CorePath.concatenatePaths('foo/bar', 'baz')).toEqual('foo/bar/baz'); }); + it('checks ancestor paths', () => { + expect(CorePath.pathIsAncestor('/foo', '/foo/bar')).toEqual(true); + expect(CorePath.pathIsAncestor('/foo/', '/foo/bar')).toEqual(true); + expect(CorePath.pathIsAncestor('/foo', '/foo/bar/baz')).toEqual(true); + expect(CorePath.pathIsAncestor('/foo/baz', '/foo/bar')).toEqual(false); + expect(CorePath.pathIsAncestor('/foo/bar', '/foo/bar')).toEqual(false); + expect(CorePath.pathIsAncestor('/foo/b', '/foo/bar')).toEqual(false); + }); + }); From 87c76b3db4477a3fa781548fd7e9d16ec20d078b Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Thu, 16 May 2024 11:58:57 +0200 Subject: [PATCH 2/3] MOBILE-4470 viewer: Fix viewing data images --- src/core/features/viewer/components/image/image.html | 4 ++++ src/core/features/viewer/components/image/image.ts | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/features/viewer/components/image/image.html b/src/core/features/viewer/components/image/image.html index 74946e401..d25fdff4a 100644 --- a/src/core/features/viewer/components/image/image.html +++ b/src/core/features/viewer/components/image/image.html @@ -2,7 +2,11 @@
+ @if (dataUrl) { + + } @else { + }
diff --git a/src/core/features/viewer/components/image/image.ts b/src/core/features/viewer/components/image/image.ts index f52e9ab52..87deee8c7 100644 --- a/src/core/features/viewer/components/image/image.ts +++ b/src/core/features/viewer/components/image/image.ts @@ -13,11 +13,12 @@ // limitations under the License. import { Component, ElementRef, Input, OnInit, ViewChild } from '@angular/core'; -import { ModalController, Translate } from '@singletons'; +import { DomSanitizer, ModalController, Translate } from '@singletons'; import { CoreMath } from '@singletons/math'; import { Swiper } from 'swiper'; import { SwiperOptions } from 'swiper/types'; import { CoreSwiper } from '@singletons/swiper'; +import { SafeResourceUrl } from '@angular/platform-browser'; /** * Modal component to view an image. @@ -52,6 +53,8 @@ export class CoreViewerImageComponent implements OnInit { @Input() component?: string; // Component to use in external-content. @Input() componentId?: string | number; // Component ID to use in external-content. + dataUrl?: SafeResourceUrl; + private static readonly MAX_RATIO = 8; private static readonly MIN_RATIO = 0.5; @@ -72,6 +75,12 @@ export class CoreViewerImageComponent implements OnInit { */ ngOnInit(): void { this.title = this.title || Translate.instant('core.imageviewer'); + + if (this.image.startsWith('data:')) { + // It's a data image, sanitize it so it can be rendered. + // Don't sanitize other images because they load fine and they need to be treated by core-external-content. + this.dataUrl = DomSanitizer.bypassSecurityTrustResourceUrl(this.image); + } } /** From fb7f63732c652c8cedda9e133cdd1db84dd900d2 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Fri, 17 May 2024 12:58:18 +0200 Subject: [PATCH 3/3] MOBILE-4470 iframe: Fix regression with default values --- src/core/components/iframe/iframe.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/components/iframe/iframe.ts b/src/core/components/iframe/iframe.ts index 58fd3f82a..32b7fc156 100644 --- a/src/core/components/iframe/iframe.ts +++ b/src/core/components/iframe/iframe.ts @@ -48,8 +48,8 @@ export class CoreIframeComponent implements OnChanges, OnDestroy { @Input() src?: string; @Input() id: string | null = null; - @Input() iframeWidth?: string; - @Input() iframeHeight?: string; + @Input() iframeWidth = '100%'; + @Input() iframeHeight = '100%'; @Input() allowFullscreen?: boolean | string; @Input() showFullscreenOnToolbar?: boolean | string; @Input() autoFullscreenOnRotate?: boolean | string;