From c50a923bafec740d38a818caa6a7af8f86dd94c8 Mon Sep 17 00:00:00 2001 From: Josh Kasten Date: Tue, 14 Nov 2023 02:45:55 +0000 Subject: [PATCH] fix "Hide bell if user is subscribed" option Option that can be set in dashboard when configuring the bell. Updated to the new v16 function. Also corrected type that was incorrect for displayPredicate --- src/shared/helpers/ConfigHelper.ts | 9 +-------- src/shared/models/Prompts.ts | 2 +- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/src/shared/helpers/ConfigHelper.ts b/src/shared/helpers/ConfigHelper.ts index dbf857c9a..402912494 100644 --- a/src/shared/helpers/ConfigHelper.ts +++ b/src/shared/helpers/ConfigHelper.ts @@ -532,14 +532,7 @@ export class ConfigHelper { enable: serverConfig.config.staticPrompts.bell.enabled, displayPredicate: serverConfig.config.staticPrompts.bell .hideWhenSubscribed - ? () => { - return OneSignal.isPushNotificationsEnabled().then( - (isPushEnabled: boolean) => { - /* The user is subscribed, so we want to return "false" to hide the notify button */ - return !isPushEnabled; - }, - ); - } + ? () => !OneSignal.User.PushSubscription.optedIn : null, size: serverConfig.config.staticPrompts.bell.size, position: serverConfig.config.staticPrompts.bell.location, diff --git a/src/shared/models/Prompts.ts b/src/shared/models/Prompts.ts index fec8b30c6..59d50fa49 100644 --- a/src/shared/models/Prompts.ts +++ b/src/shared/models/Prompts.ts @@ -123,7 +123,7 @@ export interface BellText { export interface AppUserConfigNotifyButton { options?: AppUserConfigNotifyButton; enable: boolean; - displayPredicate?: () => void | null | undefined; + displayPredicate?: null | (() => void | null | undefined | boolean); size?: BellSize; position?: BellPosition; offset?: { bottom: string; left: string; right: string };