Skip to content

Commit

Permalink
Merge pull request #4688 from ruhani2/feat/add-ability-to-toggle-sett…
Browse files Browse the repository at this point in the history
…ings-in-iframe

feat: added feature to toggle visibility of settings in iframe
  • Loading branch information
ainouzgali authored Oct 29, 2023
2 parents ca1176b + 242fabb commit 8be7ba4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export function NotificationCenterWidget(props: INotificationCenterWidgetProps)
const [colorScheme, setColorScheme] = useState<ColorScheme>('light');
const [doLogout, setDoLogout] = useState(false);
const [preferenceFilter, setPreferenceFilter] = useState<(userPreference: IUserPreferenceSettings) => boolean>();
const [showUserPreferences, setShowUserPreferences] = useState<boolean>(true);

useEffect(() => {
if (fontFamily !== DEFAULT_FONT_FAMILY) {
Expand Down Expand Up @@ -94,6 +95,10 @@ export function NotificationCenterWidget(props: INotificationCenterWidgetProps)
setPreferenceFilter(() => data.value.preferenceFilter);
}

if (data.value.showUserPreferences) {
setShowUserPreferences(data.value.showUserPreferences);
}

setFrameInitialized(true);
}

Expand Down Expand Up @@ -145,6 +150,7 @@ export function NotificationCenterWidget(props: INotificationCenterWidgetProps)
preferenceFilter={preferenceFilter}
theme={theme}
tabs={tabs}
showUserPreferences={showUserPreferences}
/>
</NovuNotificationCenterWrapper>
</NovuProvider>
Expand Down
5 changes: 5 additions & 0 deletions libs/embed/src/embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class Novu {

private listeners: { [key: string]: (data: any) => void } = {};

private showUserPreferences?: boolean;

constructor(onloadFunc = function () {}) {
this.debugMode = false;
this.onloadFunc = onloadFunc;
Expand Down Expand Up @@ -79,6 +81,7 @@ class Novu {
this.tabs = selectorOrOptions.tabs;
this.stores = selectorOrOptions.stores;
this.colorScheme = selectorOrOptions.colorScheme;
this.showUserPreferences = selectorOrOptions.showUserPreferences;
}

this.clientId = clientId;
Expand Down Expand Up @@ -248,6 +251,7 @@ class Novu {
tabs: this.tabs,
stores: this.stores,
colorScheme: this.colorScheme,
showUserPreferences: this.showUserPreferences,
},
},
'*'
Expand Down Expand Up @@ -425,4 +429,5 @@ interface IOptions {
tabs: ITab[];
stores: IStore[];
colorScheme?: ColorScheme;
showUserPreferences?: boolean;
}

2 comments on commit 8be7ba4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.