mirror of https://github.com/zulip/zulip.git
notifications: Rename to desktop_notifications.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
fcaf1fe7d5
commit
ba1895cb1c
|
@ -91,6 +91,7 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/demo_organizations_ui.js",
|
||||
"web/src/deprecated_feature_notice.ts",
|
||||
"web/src/desktop_integration.js",
|
||||
"web/src/desktop_notifications.js",
|
||||
"web/src/dialog_widget.ts",
|
||||
"web/src/drafts.js",
|
||||
"web/src/drafts_overlay_ui.js",
|
||||
|
@ -148,7 +149,6 @@ EXEMPT_FILES = make_set(
|
|||
"web/src/narrow_title.js",
|
||||
"web/src/navbar_alerts.js",
|
||||
"web/src/navigate.js",
|
||||
"web/src/notifications.js",
|
||||
"web/src/overlays.ts",
|
||||
"web/src/padded_widget.ts",
|
||||
"web/src/page_params.ts",
|
||||
|
|
|
@ -11,7 +11,7 @@ import "jquery-validation";
|
|||
import "../setup";
|
||||
import "../reload";
|
||||
import "../hotkey";
|
||||
import "../notifications";
|
||||
import "../desktop_notifications";
|
||||
import "../server_events";
|
||||
import "../templates";
|
||||
import "../settings";
|
||||
|
|
|
@ -2,10 +2,10 @@ import $ from "jquery";
|
|||
|
||||
import * as alert_words from "./alert_words";
|
||||
import * as blueslip from "./blueslip";
|
||||
import * as desktop_notifications from "./desktop_notifications";
|
||||
import {$t} from "./i18n";
|
||||
import * as message_parser from "./message_parser";
|
||||
import * as narrow from "./narrow";
|
||||
import * as notifications from "./notifications";
|
||||
import * as people from "./people";
|
||||
import * as spoilers from "./spoilers";
|
||||
import * as stream_data from "./stream_data";
|
||||
|
@ -139,9 +139,9 @@ export function process_notification(notification) {
|
|||
|
||||
debug_notification_source_value(message);
|
||||
|
||||
if (notifications.notice_memory.has(key)) {
|
||||
msg_count = notifications.notice_memory.get(key).msg_count + 1;
|
||||
notification_object = notifications.notice_memory.get(key).obj;
|
||||
if (desktop_notifications.notice_memory.has(key)) {
|
||||
msg_count = desktop_notifications.notice_memory.get(key).msg_count + 1;
|
||||
notification_object = desktop_notifications.notice_memory.get(key).obj;
|
||||
notification_object.close();
|
||||
}
|
||||
|
||||
|
@ -149,12 +149,12 @@ export function process_notification(notification) {
|
|||
|
||||
if (notification.desktop_notify) {
|
||||
const icon_url = people.small_avatar_url(message);
|
||||
notification_object = new notifications.NotificationAPI(title, {
|
||||
notification_object = new desktop_notifications.NotificationAPI(title, {
|
||||
icon: icon_url,
|
||||
body: content,
|
||||
tag: message.id,
|
||||
});
|
||||
notifications.notice_memory.set(key, {
|
||||
desktop_notifications.notice_memory.set(key, {
|
||||
obj: notification_object,
|
||||
msg_count,
|
||||
message_id: message.id,
|
||||
|
@ -173,7 +173,7 @@ export function process_notification(notification) {
|
|||
window.focus();
|
||||
});
|
||||
notification_object.addEventListener("close", () => {
|
||||
notifications.notice_memory.delete(key);
|
||||
desktop_notifications.notice_memory.delete(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -380,7 +380,7 @@ export function received_messages(messages) {
|
|||
if (should_send_desktop_notification(message)) {
|
||||
process_notification({
|
||||
message,
|
||||
desktop_notify: notifications.granted_desktop_notifications_permission(),
|
||||
desktop_notify: desktop_notifications.granted_desktop_notifications_permission(),
|
||||
});
|
||||
}
|
||||
if (should_send_audible_notification(message)) {
|
||||
|
|
|
@ -11,9 +11,9 @@ import render_profile_incomplete_alert_content from "../templates/navbar_alerts/
|
|||
import render_server_needs_upgrade_alert_content from "../templates/navbar_alerts/server_needs_upgrade.hbs";
|
||||
|
||||
import * as compose_ui from "./compose_ui";
|
||||
import * as desktop_notifications from "./desktop_notifications";
|
||||
import * as keydown_util from "./keydown_util";
|
||||
import {localstorage} from "./localstorage";
|
||||
import * as notifications from "./notifications";
|
||||
import {page_params} from "./page_params";
|
||||
import {should_display_profile_incomplete_alert} from "./timerender";
|
||||
import * as unread from "./unread";
|
||||
|
@ -65,9 +65,9 @@ export function should_show_notifications(ls) {
|
|||
// don't exist like `Notification.permission`.
|
||||
!util.is_mobile() &&
|
||||
// if permission has not been granted yet.
|
||||
!notifications.granted_desktop_notifications_permission() &&
|
||||
!desktop_notifications.granted_desktop_notifications_permission() &&
|
||||
// if permission is allowed to be requested (e.g. not in "denied" state).
|
||||
notifications.permission_state() !== "denied"
|
||||
desktop_notifications.permission_state() !== "denied"
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ export function initialize() {
|
|||
$(".request-desktop-notifications").on("click", function (e) {
|
||||
e.preventDefault();
|
||||
$(this).closest(".alert").hide();
|
||||
notifications.request_desktop_notifications_permission();
|
||||
desktop_notifications.request_desktop_notifications_permission();
|
||||
$(window).trigger("resize");
|
||||
});
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@ import * as composebox_typeahead from "./composebox_typeahead";
|
|||
import * as condense from "./condense";
|
||||
import * as copy_and_paste from "./copy_and_paste";
|
||||
import * as dark_theme from "./dark_theme";
|
||||
import * as desktop_notifications from "./desktop_notifications";
|
||||
import * as drafts from "./drafts";
|
||||
import * as drafts_overlay_ui from "./drafts_overlay_ui";
|
||||
import * as echo from "./echo";
|
||||
|
@ -74,7 +75,6 @@ import * as narrow_state from "./narrow_state";
|
|||
import * as narrow_title from "./narrow_title";
|
||||
import * as navbar_alerts from "./navbar_alerts";
|
||||
import * as navigate from "./navigate";
|
||||
import * as notifications from "./notifications";
|
||||
import * as overlays from "./overlays";
|
||||
import {page_params} from "./page_params";
|
||||
import * as people from "./people";
|
||||
|
@ -670,7 +670,7 @@ export function initialize_everything() {
|
|||
on_narrow_search: narrow.activate,
|
||||
});
|
||||
tutorial.initialize();
|
||||
notifications.initialize();
|
||||
desktop_notifications.initialize();
|
||||
audible_notifications.initialize();
|
||||
compose_notifications.initialize({
|
||||
on_click_scroll_to_selected: navigate.scroll_to_selected,
|
||||
|
|
|
@ -5,6 +5,7 @@ import render_confirm_mark_all_as_read from "../templates/confirm_dialog/confirm
|
|||
import * as blueslip from "./blueslip";
|
||||
import * as channel from "./channel";
|
||||
import * as confirm_dialog from "./confirm_dialog";
|
||||
import * as desktop_notifications from "./desktop_notifications";
|
||||
import * as dialog_widget from "./dialog_widget";
|
||||
import {$t_html} from "./i18n";
|
||||
import * as loading from "./loading";
|
||||
|
@ -13,7 +14,6 @@ import * as message_lists from "./message_lists";
|
|||
import * as message_store from "./message_store";
|
||||
import * as message_viewport from "./message_viewport";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as notifications from "./notifications";
|
||||
import * as overlays from "./overlays";
|
||||
import * as people from "./people";
|
||||
import * as recent_view_ui from "./recent_view_ui";
|
||||
|
@ -165,7 +165,7 @@ function process_newly_read_message(message, options) {
|
|||
for (const msg_list of message_lists.all_rendered_message_lists()) {
|
||||
msg_list.view.show_message_as_read(message, options);
|
||||
}
|
||||
notifications.close_notification(message);
|
||||
desktop_notifications.close_notification(message);
|
||||
recent_view_ui.update_topic_unread_count(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,9 +53,9 @@ const $ = require("./lib/zjquery");
|
|||
set_global("document", {hasFocus: () => true});
|
||||
|
||||
const channel = mock_esm("../src/channel");
|
||||
const desktop_notifications = mock_esm("../src/desktop_notifications");
|
||||
const message_lists = mock_esm("../src/message_lists");
|
||||
const message_viewport = mock_esm("../src/message_viewport");
|
||||
const notifications = mock_esm("../src/notifications");
|
||||
const unread_ui = mock_esm("../src/unread_ui");
|
||||
|
||||
message_lists.current = {view: {}};
|
||||
|
@ -108,7 +108,7 @@ run_test("unread_ops", ({override}) => {
|
|||
// Ignore these interactions for now:
|
||||
override(message_lists.current.view, "show_message_as_read", () => {});
|
||||
override(message_lists.home.view, "show_message_as_read", () => {});
|
||||
override(notifications, "close_notification", () => {});
|
||||
override(desktop_notifications, "close_notification", () => {});
|
||||
override(unread_ui, "update_unread_counts", () => {});
|
||||
override(unread_ui, "notify_messages_remain_unread", () => {});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ const {page_params} = require("./lib/zpage_params");
|
|||
|
||||
page_params.is_spectator = false;
|
||||
|
||||
const notifications = mock_esm("../src/notifications");
|
||||
const desktop_notifications = mock_esm("../src/desktop_notifications");
|
||||
const util = mock_esm("../src/util");
|
||||
const timerender = mock_esm("../src/timerender");
|
||||
|
||||
|
@ -30,8 +30,8 @@ test("allow_notification_alert", ({disallow, override}) => {
|
|||
// Show alert.
|
||||
assert.equal(ls.get("dontAskForNotifications"), undefined);
|
||||
override(util, "is_mobile", () => false);
|
||||
override(notifications, "granted_desktop_notifications_permission", () => false);
|
||||
override(notifications, "permission_state", () => "granted");
|
||||
override(desktop_notifications, "granted_desktop_notifications_permission", () => false);
|
||||
override(desktop_notifications, "permission_state", () => "granted");
|
||||
assert.equal(navbar_alerts.should_show_notifications(ls), true);
|
||||
|
||||
// Avoid showing if the user said to never show alert on this computer again.
|
||||
|
@ -47,18 +47,18 @@ test("allow_notification_alert", ({disallow, override}) => {
|
|||
// Avoid showing if notification permission is denied.
|
||||
override(util, "is_mobile", () => false);
|
||||
assert.equal(navbar_alerts.should_show_notifications(ls), true);
|
||||
override(notifications, "permission_state", () => "denied");
|
||||
override(desktop_notifications, "permission_state", () => "denied");
|
||||
assert.equal(navbar_alerts.should_show_notifications(ls), false);
|
||||
|
||||
// Avoid showing if notification is already granted.
|
||||
disallow(notifications, "permission_state");
|
||||
override(notifications, "granted_desktop_notifications_permission", () => "granted");
|
||||
disallow(desktop_notifications, "permission_state");
|
||||
override(desktop_notifications, "granted_desktop_notifications_permission", () => "granted");
|
||||
assert.equal(navbar_alerts.should_show_notifications(ls), false);
|
||||
|
||||
// Don't ask for permission to spectator.
|
||||
disallow(util, "is_mobile");
|
||||
disallow(notifications, "granted_desktop_notifications_permission");
|
||||
disallow(notifications, "permission_state");
|
||||
disallow(desktop_notifications, "granted_desktop_notifications_permission");
|
||||
disallow(desktop_notifications, "permission_state");
|
||||
page_params.is_spectator = true;
|
||||
assert.equal(navbar_alerts.should_show_notifications(ls), false);
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ mock_esm("../src/spoilers", {hide_spoilers_in_notification() {}});
|
|||
const user_topics = zrequire("user_topics");
|
||||
const stream_data = zrequire("stream_data");
|
||||
|
||||
const notifications = zrequire("notifications");
|
||||
const desktop_notifications = zrequire("desktop_notifications");
|
||||
const message_notifications = zrequire("message_notifications");
|
||||
|
||||
// Not muted streams
|
||||
|
@ -365,7 +365,7 @@ test("basic_notifications", () => {
|
|||
}
|
||||
}
|
||||
|
||||
notifications.set_notification_api(StubNotification);
|
||||
desktop_notifications.set_notification_api(StubNotification);
|
||||
|
||||
const message_1 = {
|
||||
id: 1000,
|
||||
|
@ -395,14 +395,14 @@ test("basic_notifications", () => {
|
|||
|
||||
// Send notification.
|
||||
message_notifications.process_notification({message: message_1, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
n = desktop_notifications.get_notifications();
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 1);
|
||||
assert.equal(last_shown_message_id, message_1.id);
|
||||
|
||||
// Remove notification.
|
||||
notifications.close_notification(message_1);
|
||||
n = notifications.get_notifications();
|
||||
desktop_notifications.close_notification(message_1);
|
||||
n = desktop_notifications.get_notifications();
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), false);
|
||||
assert.equal(n.size, 0);
|
||||
assert.equal(last_closed_message_id, message_1.id);
|
||||
|
@ -410,7 +410,7 @@ test("basic_notifications", () => {
|
|||
// Send notification.
|
||||
message_1.id = 1001;
|
||||
message_notifications.process_notification({message: message_1, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
n = desktop_notifications.get_notifications();
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 1);
|
||||
assert.equal(last_shown_message_id, message_1.id);
|
||||
|
@ -418,23 +418,23 @@ test("basic_notifications", () => {
|
|||
// Process same message again. Notification count shouldn't increase.
|
||||
message_1.id = 1002;
|
||||
message_notifications.process_notification({message: message_1, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
n = desktop_notifications.get_notifications();
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 1);
|
||||
assert.equal(last_shown_message_id, message_1.id);
|
||||
|
||||
// Send another message. Notification count should increase.
|
||||
message_notifications.process_notification({message: message_2, desktop_notify: true});
|
||||
n = notifications.get_notifications();
|
||||
n = desktop_notifications.get_notifications();
|
||||
assert.equal(n.has("Gus Fring to general > lunch"), true);
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), true);
|
||||
assert.equal(n.size, 2);
|
||||
assert.equal(last_shown_message_id, message_2.id);
|
||||
|
||||
// Remove notifications.
|
||||
notifications.close_notification(message_1);
|
||||
notifications.close_notification(message_2);
|
||||
n = notifications.get_notifications();
|
||||
desktop_notifications.close_notification(message_1);
|
||||
desktop_notifications.close_notification(message_2);
|
||||
n = desktop_notifications.get_notifications();
|
||||
assert.equal(n.has("Jesse Pinkman to general > whatever"), false);
|
||||
assert.equal(n.size, 0);
|
||||
assert.equal(last_closed_message_id, message_2.id);
|
||||
|
|
Loading…
Reference in New Issue