From 748dce175772ec5f05d2bb13007d5aba7a11a8b0 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Mon, 13 Nov 2023 13:07:02 +0100 Subject: [PATCH] MOBILE-4469 site: Implement new hasInfo function --- src/core/classes/sites/unauthenticated-site.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/core/classes/sites/unauthenticated-site.ts b/src/core/classes/sites/unauthenticated-site.ts index 7263086b8..fe4134fbd 100644 --- a/src/core/classes/sites/unauthenticated-site.ts +++ b/src/core/classes/sites/unauthenticated-site.ts @@ -71,6 +71,18 @@ export class CoreUnauthenticatedSite { return undefined; } + /** + * Check if the site has info with the given key and it doesn't contain an empty value. + * + * @param key Info key. + * @returns Whether the key is filled within site info. + */ + hasInfo(key: string): boolean { + const info = this.getInfo()?.[key] ?? null; + + return info === false || info === 0 || !!info; + } + /** * Get site name. *