On 08/15/2017 10:17 AM, sebb wrote: > -1 > > This is still an unnecessary work-round. > > IMO it's worse, because any null database entries will still affect > other code that uses the preferences API. > There may not be any (yet) but the API is public.
Until such a point where a different fix is in place, I don't see this as unnecessary. It's not the _perfect solution_, but it's what we have at the moment. No-one else has written anything to replace it. If at one point something gets written that can clean the database, I will gladly remove this again from the code. But we are not there now. With regards, Daniel. > > As I already wrote, the proper solution is to: > 1) fix the bug that creates the null entries > 2) run a once-off job to tidy up the database > > > On 15 August 2017 at 06:56, <[email protected]> wrote: >> Ensure that a list isn't null when adding to favorites. >> >> This is a workaround for #392. It checks whether a list is non-null >> before attempting to add it to the favorites list in the UI. >> >> >> Project: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/repo >> Commit: >> http://git-wip-us.apache.org/repos/asf/incubator-ponymail/commit/be430c66 >> Tree: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/tree/be430c66 >> Diff: http://git-wip-us.apache.org/repos/asf/incubator-ponymail/diff/be430c66 >> >> Branch: refs/heads/master >> Commit: be430c666bc220a52ffdcaa69e5a005836e22590 >> Parents: 915b6f5 >> Author: Daniel Gruno <[email protected]> >> Authored: Tue Aug 15 07:56:08 2017 +0200 >> Committer: Daniel Gruno <[email protected]> >> Committed: Tue Aug 15 07:56:08 2017 +0200 >> >> ---------------------------------------------------------------------- >> site/js/dev/ponymail_phonebook.js | 4 +++- >> site/js/dev/ponymail_user_preferences.js | 18 ++++++++++-------- >> site/js/ponymail.js | 22 +++++++++++++--------- >> 3 files changed, 26 insertions(+), 18 deletions(-) >> ---------------------------------------------------------------------- >> >> >> http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/be430c66/site/js/dev/ponymail_phonebook.js >> ---------------------------------------------------------------------- >> diff --git a/site/js/dev/ponymail_phonebook.js >> b/site/js/dev/ponymail_phonebook.js >> index 9fc8365..754c49f 100644 >> --- a/site/js/dev/ponymail_phonebook.js >> +++ b/site/js/dev/ponymail_phonebook.js >> @@ -111,7 +111,9 @@ function seedDomains(json) { >> if (login && login.favorites && login.favorites.length > 0) { >> domlist['★'] = [] >> for (mli in login.favorites) { >> - domlist['★'].push(login.favorites[mli]) >> + if (mli != null) { // #392: ensure the list exists >> + domlist['★'].push(login.favorites[mli]) >> + } >> } >> } >> var po = document.createElement("div") >> >> http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/be430c66/site/js/dev/ponymail_user_preferences.js >> ---------------------------------------------------------------------- >> diff --git a/site/js/dev/ponymail_user_preferences.js >> b/site/js/dev/ponymail_user_preferences.js >> index 7d0e2f8..2f1ff46 100644 >> --- a/site/js/dev/ponymail_user_preferences.js >> +++ b/site/js/dev/ponymail_user_preferences.js >> @@ -218,14 +218,16 @@ function setupUser() { >> li.appendChild(ul) >> for (var i in login.favorites) { >> var l = login.favorites[i] >> - var sli = document.createElement('li') >> - sli.setAttribute("class", "pull-left") >> - var st = document.createTextNode(l) >> - var sa = document.createElement('a') >> - sa.setAttribute("href", "list.html?" + l) >> - sa.appendChild(st) >> - sli.appendChild(sa) >> - ul.appendChild(sli) >> + if (l != null) { >> + var sli = document.createElement('li') >> + sli.setAttribute("class", "pull-left") >> + var st = document.createTextNode(l) >> + var sa = document.createElement('a') >> + sa.setAttribute("href", "list.html?" + l) >> + sa.appendChild(st) >> + sli.appendChild(sa) >> + ul.appendChild(sli) >> + } >> } >> >> pd.appendChild(li) >> >> http://git-wip-us.apache.org/repos/asf/incubator-ponymail/blob/be430c66/site/js/ponymail.js >> ---------------------------------------------------------------------- >> diff --git a/site/js/ponymail.js b/site/js/ponymail.js >> index 9aa2310..689bc8e 100644 >> --- a/site/js/ponymail.js >> +++ b/site/js/ponymail.js >> @@ -4310,7 +4310,9 @@ function seedDomains(json) { >> if (login && login.favorites && login.favorites.length > 0) { >> domlist['★'] = [] >> for (mli in login.favorites) { >> - domlist['★'].push(login.favorites[mli]) >> + if (mli != null) { // #392: ensure the list exists >> + domlist['★'].push(login.favorites[mli]) >> + } >> } >> } >> var po = document.createElement("div") >> @@ -5313,14 +5315,16 @@ function setupUser() { >> li.appendChild(ul) >> for (var i in login.favorites) { >> var l = login.favorites[i] >> - var sli = document.createElement('li') >> - sli.setAttribute("class", "pull-left") >> - var st = document.createTextNode(l) >> - var sa = document.createElement('a') >> - sa.setAttribute("href", "list.html?" + l) >> - sa.appendChild(st) >> - sli.appendChild(sa) >> - ul.appendChild(sli) >> + if (l != null) { >> + var sli = document.createElement('li') >> + sli.setAttribute("class", "pull-left") >> + var st = document.createTextNode(l) >> + var sa = document.createElement('a') >> + sa.setAttribute("href", "list.html?" + l) >> + sa.appendChild(st) >> + sli.appendChild(sa) >> + ul.appendChild(sli) >> + } >> } >> >> pd.appendChild(li) >>
