desktop: Remove logic for legacy QT/webkit desktop app.

We leave around a few comments that may help the new electron desktop
app do similar things in the future.
This commit is contained in:
Tim Abbott
2018-05-15 15:50:52 -07:00
parent 9eb3bdaf6c
commit 954fd8178f
5 changed files with 7 additions and 80 deletions

View File

@@ -2,6 +2,7 @@
set_global('$', global.make_zjquery({ set_global('$', global.make_zjquery({
silent: true, silent: true,
})); }));
set_global('blueslip', global.make_zblueslip());
set_global('document', { set_global('document', {
hasFocus: function () { hasFocus: function () {
return true; return true;

View File

@@ -134,13 +134,6 @@ function copy_handler() {
construct_copy_div(div, start_id, end_id); construct_copy_div(div, start_id, end_id);
} }
if (window.bridge !== undefined) {
// If the user is running the desktop app,
// convert emoji images to plain text for
// copy-paste purposes.
ui.replace_emoji_with_text(div);
}
// Select div so that the browser will copy it // Select div so that the browser will copy it
// instead of copying the original selection // instead of copying the original selection
div.css({position: 'absolute', left: '-99999px'}) div.css({position: 'absolute', left: '-99999px'})

View File

@@ -50,9 +50,7 @@ function browser_desktop_notifications_on() {
// Firefox on Ubuntu claims to do webkitNotifications but its notifications are terrible // Firefox on Ubuntu claims to do webkitNotifications but its notifications are terrible
/webkit/i.test(navigator.userAgent) && /webkit/i.test(navigator.userAgent) &&
// 0 is PERMISSION_ALLOWED // 0 is PERMISSION_ALLOWED
notifications_api.checkPermission() === 0) || notifications_api.checkPermission() === 0);
// window.bridge is the desktop client
(window.bridge !== undefined);
} }
function cancel_notification_object(notification_object) { function cancel_notification_object(notification_object) {
@@ -83,12 +81,6 @@ exports.initialize = function () {
window_has_focus = false; window_has_focus = false;
}); });
if (window.bridge !== undefined) {
supports_sound = true;
return;
}
var audio = $("<audio>"); var audio = $("<audio>");
if (audio[0].canPlayType === undefined) { if (audio[0].canPlayType === undefined) {
supports_sound = false; supports_sound = false;
@@ -118,20 +110,6 @@ exports.permission_state = function () {
return window.Notification.permission; return window.Notification.permission;
}; };
// For web pages, the initial favicon is the same as the favicon we
// set for no unread messages and the initial page title is the same
// as the page title we set for no unread messages. However, for the
// macOS app, the dock icon does not get its badge updated on initial
// page load. If the badge icon was wrong right before a reload and
// we actually have no unread messages then we will never execute
// bridge.updateCount() until the unread count changes. Therefore,
// we ensure that bridge.updateCount is always run at least once to
// synchronize it with the page title. This can be done before the
// DOM is loaded.
if (window.bridge !== undefined) {
window.bridge.updateCount(0);
}
var new_message_count = 0; var new_message_count = 0;
exports.update_title_count = function (count) { exports.update_title_count = function (count) {
@@ -173,14 +151,6 @@ exports.redraw_title = function () {
favicon.set(current_favicon); favicon.set(current_favicon);
} }
// window.bridge is for the legacy QT desktop app; we'll likely
// remove this code soon.
if (window.bridge !== undefined) {
// We don't use 'n' because we want the exact count. The bridge handles
// which icon to show.
window.bridge.updateCount(new_message_count);
}
// Notify the current desktop app's UI about the new unread count. // Notify the current desktop app's UI about the new unread count.
if (window.electron_bridge !== undefined) { if (window.electron_bridge !== undefined) {
window.electron_bridge.send_event('total_unread_count', new_message_count); window.electron_bridge.send_event('total_unread_count', new_message_count);
@@ -210,10 +180,8 @@ function flash_pms() {
} }
} }
exports.update_pm_count = function (new_pm_count) { exports.update_pm_count = function () {
if (window.bridge !== undefined && window.bridge.updatePMCount !== undefined) { // TODO: Add a `window.electron_bridge.updatePMCount(new_pm_count);` call?
window.bridge.updatePMCount(new_pm_count);
}
if (!flashing) { if (!flashing) {
flashing = true; flashing = true;
flash_pms(); flash_pms();
@@ -301,6 +269,7 @@ function process_notification(notification) {
notification_source = 'stream'; notification_source = 'stream';
} }
} }
blueslip.debug("Desktop notification from source " + notification_source);
if (content.length > 150) { if (content.length > 150) {
// Truncate content at a word boundary // Truncate content at a word boundary
@@ -387,9 +356,6 @@ function process_notification(notification) {
}); });
} else if (notification.webkit_notify === false) { } else if (notification.webkit_notify === false) {
in_browser_notify(message, title, content, raw_operators, opts); in_browser_notify(message, title, content, raw_operators, opts);
} else {
// Shunt the message along to the desktop client
window.bridge.desktopNotification(title, content, notification_source);
} }
} }
@@ -499,9 +465,7 @@ function should_send_audible_notification(message) {
exports.granted_desktop_notifications_permission = function () { exports.granted_desktop_notifications_permission = function () {
return (notifications_api && return (notifications_api &&
// 0 is PERMISSION_ALLOWED // 0 is PERMISSION_ALLOWED
notifications_api.checkPermission() === 0) || notifications_api.checkPermission() === 0);
// window.bridge is the legacy desktop app
(window.bridge !== undefined);
}; };
@@ -531,11 +495,7 @@ exports.received_messages = function (messages) {
} }
} }
if (should_send_audible_notification(message) && supports_sound) { if (should_send_audible_notification(message) && supports_sound) {
if (window.bridge !== undefined) { $("#notifications-area").find("audio")[0].play();
window.bridge.bell();
} else {
$("#notifications-area").find("audio")[0].play();
}
} }
}); });
}; };

View File

@@ -191,20 +191,6 @@ exports.restore_compose_cursor = function () {
.caret(saved_compose_cursor); .caret(saved_compose_cursor);
}; };
exports.do_stuff_for_desktop_app = function () {
if (window.bridge !== undefined) {
// Disable "spellchecking" in our desktop app. The "spellchecking"
// in our Mac app is actually autocorrect, and frustrates our
// users.
$("#compose-textarea").attr('spellcheck', 'false');
// Modify the zephyr mirroring error message in our desktop
// app, since it doesn't work from the desktop version.
$("#webathena_login_menu").hide();
$("#normal-zephyr-mirror-error-text").addClass("notdisplayed");
$("#desktop-zephyr-mirror-error-text").removeClass("notdisplayed");
}
};
exports.initialize = function () { exports.initialize = function () {
exports.set_compose_textarea_handlers(); exports.set_compose_textarea_handlers();

View File

@@ -183,19 +183,6 @@ exports.options = function (config) {
}; };
}; };
// Expose the internal file upload functions to the desktop app,
// since the linux/windows QtWebkit based apps upload images
// directly to the server
if (window.bridge) {
var opts = exports.options({ mode: "compose" });
exports.drop = opts.drop;
exports.uploadStarted = opts.uploadStarted;
exports.progressUpdated = opts.progressUpdated;
exports.uploadError = opts.error;
exports.uploadFinished = opts.uploadFinished;
}
return exports; return exports;
}()); }());