Last Comment Bug 58713 - After delete an account the next account should be selected
: After delete an account the next account should be selected
Status: RESOLVED FIXED
[Halloween2011Bug]
:
Product: MailNews Core
Classification: Components
Component: Account Manager (show other bugs)
: Trunk
: All All
: -- normal (vote)
: Thunderbird 15.0
Assigned To: :aceman
:
Mentors:
Depends on: 27417 740617
Blocks: 274452 815283
  Show dependency treegraph
 
Reported: 2000-11-01 01:10 PST by Henrik Gemal
Modified: 2013-02-04 11:53 PST (History)
7 users (show)
ryanvm: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---


Attachments
patch (2.44 KB, patch)
2012-04-11 15:18 PDT, :aceman
iann_bugzilla: review+
bwinton: ui‑review+
Details | Diff | Review
patch v2 (2.46 KB, patch)
2012-04-24 13:47 PDT, :aceman
no flags Details | Diff | Review
patch v3 (2.57 KB, patch)
2012-04-28 06:24 PDT, :aceman
mconley: review+
Details | Diff | Review
patch v4 (2.60 KB, patch)
2012-04-30 12:26 PDT, :aceman
acelists: review+
Details | Diff | Review

Description Henrik Gemal 2000-11-01 01:10:05 PST
If you have 5 accounts and delete number 4, number 1 is selected after the delete.
When you delete the next account should be selected.
So deleting number 4 out of 5 should select number 4 of out 4 af the delete.
Deleting number 4 out of 4 should select number 3 of out 3 af the delete.
etc. etc. etc...
Comment 1 (not reading, please use seth@sspitzer.org instead) 2000-12-24 00:05:36 PST
mass re-assign of account manager bugs to racham.
Comment 2 Matthew Paul Thomas 2002-04-03 07:17:00 PST

*** This bug has been marked as a duplicate of 27417 ***
Comment 3 Ninoschka Baca 2002-04-04 12:37:41 PST
Verified Duplicate.
Comment 4 Ninoschka Baca 2002-04-04 13:06:18 PST
Reopening because I believe this bug depends on bug# 27417. I also I don't want
to miss testing this case when 27417 is fixed.
Comment 5 (not reading, please use seth@sspitzer.org instead) 2003-05-08 11:37:44 PDT
mass re-assign.
Comment 6 Robert Kaiser (not working on stability any more) 2009-06-14 07:38:56 PDT
This bug report is registered in the SeaMonkey product, but has been without a comment since the inception of the SeaMonkey project. This means that it was logged against the old Mozilla suite and we cannot determine that it's still valid for the current SeaMonkey suite. Because of this, we are setting it to an UNCONFIRMED state.

If you can confirm that this report still applies to current SeaMonkey 2.x nightly builds, please set it back to the NEW state along with a comment on how you reproduced it on what Build ID, or if it's an enhancement request, why it's still worth implementing and in what way.
If you can confirm that the report doesn't apply to current SeaMonkey 2.x nightly builds, please set it to the appropriate RESOLVED state (WORKSFORME, INVALID, WONTFIX, or similar).
If no action happens within the next few months, we move this bug report to an EXPIRED state.

Query tag for this change: mass-UNCONFIRM-20090614
Comment 7 Robert Kaiser (not working on stability any more) 2009-06-14 07:41:47 PDT
This bug report is registered in the SeaMonkey product, but has been without a comment since the inception of the SeaMonkey project. This means that it was logged against the old Mozilla suite and we cannot determine that it's still valid for the current SeaMonkey suite. Because of this, we are setting it to an UNCONFIRMED state.

If you can confirm that this report still applies to current SeaMonkey 2.x nightly builds, please set it back to the NEW state along with a comment on how you reproduced it on what Build ID, or if it's an enhancement request, why it's still worth implementing and in what way.
If you can confirm that the report doesn't apply to current SeaMonkey 2.x nightly builds, please set it to the appropriate RESOLVED state (WORKSFORME, INVALID, WONTFIX, or similar).
If no action happens within the next few months, we move this bug report to an EXPIRED state.

Query tag for this change: mass-UNCONFIRM-20090614
Comment 8 Robert Kaiser (not working on stability any more) 2009-06-14 07:48:39 PDT
This bug report is registered in the SeaMonkey product, but has been without a comment since the inception of the SeaMonkey project. This means that it was logged against the old Mozilla suite and we cannot determine that it's still valid for the current SeaMonkey suite. Because of this, we are setting it to an UNCONFIRMED state.

If you can confirm that this report still applies to current SeaMonkey 2.x nightly builds, please set it back to the NEW state along with a comment on how you reproduced it on what Build ID, or if it's an enhancement request, why it's still worth implementing and in what way.
If you can confirm that the report doesn't apply to current SeaMonkey 2.x nightly builds, please set it to the appropriate RESOLVED state (WORKSFORME, INVALID, WONTFIX, or similar).
If no action happens within the next few months, we move this bug report to an EXPIRED state.

Query tag for this change: mass-UNCONFIRM-20090614
Comment 9 Robert Kaiser (not working on stability any more) 2009-06-14 08:30:44 PDT
This bug report is registered in the SeaMonkey product, but has been without a comment since the inception of the SeaMonkey project. This means that it was logged against the old Mozilla suite and we cannot determine that it's still valid for the current SeaMonkey suite. Because of this, we are setting it to an UNCONFIRMED state.

If you can confirm that this report still applies to current SeaMonkey 2.x nightly builds, please set it back to the NEW state along with a comment on how you reproduced it on what Build ID, or if it's an enhancement request, why it's still worth implementing and in what way.
If you can confirm that the report doesn't apply to current SeaMonkey 2.x nightly builds, please set it to the appropriate RESOLVED state (WORKSFORME, INVALID, WONTFIX, or similar).
If no action happens within the next few months, we move this bug report to an EXPIRED state.

Query tag for this change: mass-UNCONFIRM-20090614
Comment 10 Robert Kaiser (not working on stability any more) 2009-06-14 08:43:14 PDT
This bug report is registered in the SeaMonkey product, but has been without a comment since the inception of the SeaMonkey project. This means that it was logged against the old Mozilla suite and we cannot determine that it's still valid for the current SeaMonkey suite. Because of this, we are setting it to an UNCONFIRMED state.

If you can confirm that this report still applies to current SeaMonkey 2.x nightly builds, please set it back to the NEW state along with a comment on how you reproduced it on what Build ID, or if it's an enhancement request, why it's still worth implementing and in what way.
If you can confirm that the report doesn't apply to current SeaMonkey 2.x nightly builds, please set it to the appropriate RESOLVED state (WORKSFORME, INVALID, WONTFIX, or similar).
If no action happens within the next few months, we move this bug report to an EXPIRED state.

Query tag for this change: mass-UNCONFIRM-20090614
Comment 11 Robert Kaiser (not working on stability any more) 2009-06-14 14:48:41 PDT
This bug report is registered in the SeaMonkey product, but has been without a comment since the inception of the SeaMonkey project. This means that it was logged against the old Mozilla suite and we cannot determine that it's still valid for the current SeaMonkey suite. Because of this, we are setting it to an UNCONFIRMED state.

If you can confirm that this report still applies to current SeaMonkey 2.x nightly builds, please set it back to the NEW state along with a comment on how you reproduced it on what Build ID, or if it's an enhancement request, why it's still worth implementing and in what way.
If you can confirm that the report doesn't apply to current SeaMonkey 2.x nightly builds, please set it to the appropriate RESOLVED state (WORKSFORME, INVALID, WONTFIX, or similar).
If no action happens within the next few months, we move this bug report to an EXPIRED state.

Query tag for this change: mass-UNCONFIRM-20090614
Comment 12 Robert Kaiser (not working on stability any more) 2010-04-28 12:57:00 PDT
MASS-CHANGE:
This bug report is registered in the SeaMonkey product, but still has no comment since the inception of the SeaMonkey project 5 years ago.

Because of this, we're resolving the bug as EXPIRED.

If you still can reproduce the bug on SeaMonkey 2 or otherwise think it's still valid, please REOPEN it and if it is a platform or toolkit issue, move it to the according component.

Query tag for this change: EXPIRED-20100420
Comment 13 Karsten Düsterloh 2011-10-30 14:51:46 PDT
Still valid when deleting accounts which are not the first one in the tree.
Comment 14 :aceman 2012-04-08 13:56:23 PDT
I'll try to look.
Comment 15 :aceman 2012-04-11 13:40:40 PDT
Confirming, it always selects the top one. I'll try to fix this.

Usul, could you please hide the duplicate comment 7 to comment 11 to clean up this bug?
Comment 16 :aceman 2012-04-11 15:16:43 PDT
OK, I have a working patch ready but need to wait until bug 740617 lands as it touches the same function.
Comment 17 :aceman 2012-04-11 15:18:56 PDT
Created attachment 614193 [details] [diff] [review]
patch

But let's collect some reviews in the mean time.
Comment 18 Blake Winton (:bwinton) (:☕️) 2012-04-17 13:15:36 PDT
Comment on attachment 614193 [details] [diff] [review]
patch

I'm pretty happy with this behaviour.  ui-r=me.

Oh, and I'ld like to see some tests, of course.  ;)

Thanks,
Blake.
Comment 19 :aceman 2012-04-17 13:47:23 PDT
I'd like to see some too! :)
Comment 20 Ian Neal 2012-04-23 16:04:21 PDT
Comment on attachment 614193 [details] [diff] [review]
patch

I presume moving to Services.jsm/mailServices.js is in another bug?

>     dump("failure to remove account: " + ex + "\n");
Would we want to use reportError rather than dump here?

r=me with those answered/addressed.
Comment 21 :aceman 2012-04-23 23:57:31 PDT
Yes, that onRemoveAccount function is already moved to Services in bug 740617 (the patch is already bitrotted :)) Moving the rest of the file is bug 738810.
Comment 22 :aceman 2012-04-24 13:47:43 PDT
Created attachment 618025 [details] [diff] [review]
patch v2

Thanks, fixed, plus a bit of planned bitrot.
Comment 23 Mike Conley (:mconley) - (needinfo me!) 2012-04-27 08:51:39 PDT
Comment on attachment 618025 [details] [diff] [review]
patch v2

Review of attachment 618025 [details] [diff] [review]:
-----------------------------------------------------------------

::: mailnews/base/prefs/content/AccountManager.js
@@ +509,5 @@
> +  let serverIndex = serverList.indexOf(server);
> +
> +  // After the current server is deleted, choose the next server/account,
> +  // or the previous one if the last one was deleted.
> +  if (serverIndex == serverList.length - 1)

Suppose we only have one server, and we've removed it.

So serverIndex = 0, serverList.length = 1.

serverIndex == serverList.length - 1

We then run serverIndex--, so serverIndex is now -1.  And then we try to access serverList[-1], which doesn't make much sense.

We should definitely handle that case.

@@ +529,3 @@
>    }
>    catch (ex) {
> +    Components.utils.reportError("failure to remove account: " + ex + "\n");

The \n isn't needed.

@@ +532,2 @@
>      let alertText = bundle.getString("failedRemoveAccount");
>      Services.prompt.alert(window, null, alertText);;

While you're here - can you remove the double semi-colon?
Comment 24 :aceman 2012-04-27 15:16:58 PDT
(In reply to Mike Conley (:mconley) from comment #23)
> ::: mailnews/base/prefs/content/AccountManager.js
> We then run serverIndex--, so serverIndex is now -1.  And then we try to
> access serverList[-1], which doesn't make much sense.
> 
> We should definitely handle that case.
OK, I can support that ofr safety. But I think it is currently unrealistic as the Local Folders can't be removed. But maybe it is possible to not have them.
Comment 25 :aceman 2012-04-28 06:24:58 PDT
Created attachment 619286 [details] [diff] [review]
patch v3
Comment 26 Mike Conley (:mconley) - (needinfo me!) 2012-04-30 10:12:31 PDT
Comment on attachment 619286 [details] [diff] [review]
patch v3

Review of attachment 619286 [details] [diff] [review]:
-----------------------------------------------------------------

Just one last thing.  Beyond that, r=me.

Great job, as usual!

::: mailnews/base/prefs/content/AccountManager.js
@@ +524,5 @@
>      if (serverId in accountArray) {
>        delete accountArray[serverId];
>      }
> +
> +    if (serverIndex >= 0)

Maybe I'm being paranoid, but I'd also like a final check to ensure that serverIndex < serverList.length.
Comment 27 :aceman 2012-04-30 12:26:33 PDT
Created attachment 619638 [details] [diff] [review]
patch v4

Thanks.
Comment 28 Ryan VanderMeulen [:RyanVM] 2012-04-30 17:00:41 PDT
http://hg.mozilla.org/comm-central/rev/ddd7afa181b2
Comment 29 Ryan VanderMeulen [:RyanVM] 2013-02-04 11:53:46 PST
Tests checked in.
https://hg.mozilla.org/comm-central/rev/0cf5688a02e9

Note You need to log in before you can comment on or make changes to this bug.