Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
settings-banner: Fix bugs in the rendering of the desktop notification banner.
Maneesh Shukla5ba7c2bddbff
diff --git a/web/src/settings_notifications.ts b/web/src/settings_notifications.tsindex acc89ec0db3..bac648a7e68 100644--- a/web/src/settings_notifications.ts+++ b/web/src/settings_notifications.ts@@ -48,7 +48,7 @@ const DESKTOP_NOTIFICATIONS_BANNER: banners.Banner = {buttons: [{label: $t({defaultMessage: "Enable notifications"}),- custom_classes: "request-desktop-notifications",+ custom_classes: "desktop-notifications-request",attention: "primary",},],@@ -371,6 +371,26 @@ export function set_up(settings_panel: SettingsPanel): void {settings_object.automatically_unmute_topics_in_muted_streams_policy,);+ update_desktop_notification_banner();++ $container.on("click", ".desktop-notifications-request", (e) => {+ e.preventDefault();+ // This is only accessed via the notifications banner, so we+ // do not need to do a mobile check here--as that banner is+ // not shown in a mobile context anyway.+ void Notification.requestPermission().then((permission) => {+ if (permission === "granted") {+ update_desktop_notification_banner();+ } else if (permission === "denied") {+ window.open(+ "/help/desktop-notifications#check-platform-settings",+ "_blank",+ "noopener noreferrer",+ );+ }+ });+ });+set_enable_digest_emails_visibility($container, for_realm_settings);if (for_realm_settings) {@@ -490,24 +510,6 @@ export function set_up(settings_panel: SettingsPanel): void {);});- $("#settings_content").on("click", ".request-desktop-notifications", (e) => {- e.preventDefault();- // This is only accessed via the notifications banner, so we- // do not need to do a mobile check here--as that banner is- // not shown in a mobile context anyway.- void Notification.requestPermission().then((permission) => {- if (permission === "granted") {- update_desktop_notification_banner();- } else if (permission === "denied") {- window.open(- "/help/desktop-notifications#check-platform-settings",- "_blank",- "noopener noreferrer",- );- }- });- });-$("#settings_content").on("click", ".banner-close-button", (e) => {e.preventDefault();$(".banner-wrapper").remove();diff --git a/web/styles/app_components.css b/web/styles/app_components.cssindex f3ae9a1721c..140f19f6551 100644--- a/web/styles/app_components.css+++ b/web/styles/app_components.css@@ -542,6 +542,10 @@ input.settings_text_input {}}+.desktop-setting-notifications {+ margin-bottom: 10px;+}+.invite-stream-notice {margin-bottom: 20px;}diff --git a/web/templates/settings/notification_settings.hbs b/web/templates/settings/notification_settings.hbsindex 2f5e3c1f8cb..8c0009531d7 100644--- a/web/templates/settings/notification_settings.hbs+++ b/web/templates/settings/notification_settings.hbs@@ -131,7 +131,7 @@{{> settings_save_discard_widget section_name="desktop-message-settings" show_only_indicator=(not for_realm_settings) }}</div>- <div class="desktop-notification-settings-banners"></div>+ <div class="desktop-notification-settings-banners banner-wrapper"></div>{{#unless for_realm_settings}}<p><a class="send_test_notification">{{t "Send a test notification" }}</a></p>