From 0923389973e7fb6b2d6f335cc7318223e91ad4f1 Mon Sep 17 00:00:00 2001 From: Evyatar Amitay Date: Tue, 28 May 2013 02:09:56 -0700 Subject: [PATCH] Merge pull request #9084 from EverythingMe/bugfix-no-more-more [Bug 860230] Fix "More" menu when there are no more suggestions [r=crdlc](cherry picked from commit 57ff1b0d55a0b3a6edb64e18c56d181d9b93cecf) Conflicts: apps/homescreen/everything.me/js/Brain.js --- apps/homescreen/everything.me/js/Brain.js | 40 ++++++++++++------- .../everything.me/js/api/DoATAPI.js | 4 ++ .../locales/homescreen.en-US.properties | 1 + 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/apps/homescreen/everything.me/js/Brain.js b/apps/homescreen/everything.me/js/Brain.js index a28a97e27720..95b1c8d37119 100644 --- a/apps/homescreen/everything.me/js/Brain.js +++ b/apps/homescreen/everything.me/js/Brain.js @@ -1239,24 +1239,34 @@ Evme.Brain = new function Evme_Brain() { requestSuggest = Evme.DoATAPI.Shortcuts.suggest({ "existing": arrCurrentShortcuts }, function onSuccess(data) { - var suggestedShortcuts = data.response.shortcuts, - icons = data.response.icons; - - for (var id in icons) { - currentIcons[id] = icons[id]; + var suggestedShortcuts = data.response.shortcuts || [], + icons = data.response.icons || {}; + + if(!isRequesting) { + return; } - - Evme.ShortcutsCustomize.load({ - "shortcuts": suggestedShortcuts, - "icons": currentIcons - }); - + isFirstShow = false; isRequesting = false; - Evme.ShortcutsCustomize.show(); - // setting timeout to give the select box enough time to show - // otherwise there's visible flickering - window.setTimeout(Evme.ShortcutsCustomize.Loading.hide, 300); + + if (suggestedShortcuts.length === 0) { + window.alert(Evme.Utils.l10n(L10N_SYSTEM_ALERT, 'no-more-shortcuts')); + Evme.ShortcutsCustomize.Loading.hide(); + } else { + for (var id in icons) { + currentIcons[id] = icons[id]; + } + + Evme.ShortcutsCustomize.load({ + "shortcuts": suggestedShortcuts, + "icons": currentIcons + }); + + Evme.ShortcutsCustomize.show(); + // setting timeout to give the select box enough time to show + // otherwise there's visible flickering + window.setTimeout(Evme.ShortcutsCustomize.Loading.hide, 300); + } }); }); }); diff --git a/apps/homescreen/everything.me/js/api/DoATAPI.js b/apps/homescreen/everything.me/js/api/DoATAPI.js index 3370e4d2fb11..6a0e0ce5b3e8 100644 --- a/apps/homescreen/everything.me/js/api/DoATAPI.js +++ b/apps/homescreen/everything.me/js/api/DoATAPI.js @@ -355,6 +355,10 @@ Evme.DoATAPI = new function Evme_DoATAPI() { // check if a list of shortcuts contain the given shortcut // not a simple indexOf since a shortcut is either a query or an experienceId function contains(shortcuts, shortcut) { + if (!shortcuts) { + return false; + } + for (var i=0,shortcutToCheck; shortcutToCheck=shortcuts[i++];) { var experienceId1 = shortcutToCheck.experienceId, experienceId2 = shortcut.experienceId, diff --git a/apps/homescreen/locales/homescreen.en-US.properties b/apps/homescreen/locales/homescreen.en-US.properties index 6006226ffa43..4f4a3a00b27b 100644 --- a/apps/homescreen/locales/homescreen.en-US.properties +++ b/apps/homescreen/locales/homescreen.en-US.properties @@ -49,6 +49,7 @@ evme-appsmore-loading=Loading… evme-alert-app-install-confirm=Add {{name}} to Home Screen? evme-alert-app-install-exists={{name}} was already added to Home Screen evme-alert-offline-shortcuts-more=Connect to the internet to add more shortcuts +evme-alert-no-more-shortcuts=No Shortcuts to add evme-banner-app-install-success={{name}} added to Home Screen # Shortcuts - AKA smart folders - evme homepage