From 32af99cd4d05ec0e7fd3918a4e654518d7a933cb Mon Sep 17 00:00:00 2001 From: Brock Whittaker Date: Fri, 15 Sep 2017 16:16:42 -0700 Subject: [PATCH] Display an error for the ZulipDesktop unsupported platform. This displays an error at the top of the screen on page load that will inform any user with the userAgent string "ZulipDesktop" that they should upgrade to our newer electron app Fixes: #6551. --- static/js/ui.js | 15 +++++++++++++++ static/js/ui_report.js | 7 +++++++ 2 files changed, 22 insertions(+) diff --git a/static/js/ui.js b/static/js/ui.js index ce4ccdd91e..df2083b798 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -46,6 +46,20 @@ function update_message_in_all_views(message_id, callback) { }); } +exports.show_error_for_unsupported_platform = function () { + if (/ZulipDesktop/.test(navigator.userAgent)) { + // We don't internationalize this string because it is long, + // and few users will have both the old desktop app and an + // internationalized version of Zulip anyway. + var error = "Hello! You're using the unsupported old Zulip desktop app," + + " which is no longer developed. We recommend switching to the new, " + + "modern desktop app, which you can download at " + + "zulipchat.com/apps."; + + ui_report.generic_embed_error(error); + } +}; + exports.find_message = function (message_id) { // Try to find the message object. It might be in the narrow list // (if it was loaded when narrowed), or only in the message_list.all @@ -285,6 +299,7 @@ $(function () { exports.initialize = function () { i18n.ensure_i18n(_setup_info_overlay); + exports.show_error_for_unsupported_platform(); }; return exports; diff --git a/static/js/ui_report.js b/static/js/ui_report.js index 251c7be183..dfe62b4138 100644 --- a/static/js/ui_report.js +++ b/static/js/ui_report.js @@ -43,6 +43,13 @@ exports.success = function (response, status_box, type) { exports.message(response, status_box, 'alert-success', type); }; +exports.generic_embed_error = function (error) { + var $alert = $("
"); + var $exit = "
"; + + $(".alert-box").append($alert.html($exit + "
" + error + "
").addClass("show")); +}; + exports.hide_error = function ($target) { $target.addClass("fade-out"); setTimeout(function () {