Closed Bug 269578 Opened 20 years ago Closed 20 years ago

Deleting events brings up multiple confirmation dialogs

Categories

(Calendar :: Sunbird Only, defect)

defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mattwillis, Assigned: mattwillis)

References

Details

Attachments

(1 file, 1 obsolete file)

Deleting a single, titled event brings up multiple confirmation dialogs.

Sunbird 0.2b
Attachment #165765 - Flags: first-review?(mostafah)
Comment on attachment 165765 [details] [diff] [review]
rev0 - evaluations in nested if statements are more specific to prevent match multiple confirms

Note the "=" where "==" was intended.  Also note that title could be null or
empty.

It will be clearer to make the control structure simpler rather than use long
test cases where the conditions before the last are exclusive if you study
them.

if ( SelectedItems && SelectedItems.length > 0) {
  if ( !DoNotConfirm )
  {
    var calendarEvent = SelectedItems[0];
    if ( SelectedItems.length > 1) {
      if (!confirm( confirmDeleteAllEvents ) )
	break outerLoop;
      // else fall thru
    } else if (calendarEvent.title) { // null and empty string are false
      if (!confirm( confirmDeleteEvent+" "+calendarEvent.title+"?" ) )
	break outerLoop;
      // else fall thru
    } else {
      if (!confirm( confirmDeleteUntitledEvent ) )
	break outerLoop;
      // else fall thru
    }
  }
  ...
}
Attachment #165765 - Flags: first-review?(mostafah) → first-review-
(In reply to comment #2)
> (From update of attachment 165765 [details] [diff] [review])
> Note the "=" where "==" was intended.  Also note that title could be null or
> empty.

Thanks for that catch.

> It will be clearer to make the control structure simpler rather than use long
> test cases where the conditions before the last are exclusive if you study
> them.
> 
> if ( SelectedItems && SelectedItems.length > 0) {
>   if ( !DoNotConfirm )
>   {
>     var calendarEvent = SelectedItems[0];
>     if ( SelectedItems.length > 1) {
>       if (!confirm( confirmDeleteAllEvents ) )
> 	break outerLoop;
>       // else fall thru 
>     } else if (calendarEvent.title) { // null and empty string are false
Won't this also be true for the multiple event case above when it falls through?

>       if (!confirm( confirmDeleteEvent+" "+calendarEvent.title+"?" ) )
> 	break outerLoop;
>       // else fall thru
>     } else {
Again, won't this be true for the above cases that have fallen through?

>       if (!confirm( confirmDeleteUntitledEvent ) )
> 	break outerLoop;
>       // else fall thru
>     }
>   }
>   ...
> }
> 

I think I have an even easier way to make this work. I'm testing it now, and
I'll attach the patch once I'm pretty sure it's all sussed out.
This is more straightforward, and should be much more readable. 

After getting some exceptions when testing (which I am about to file a bug on),
I added the try/catch to take catch them.
Attachment #165765 - Attachment is obsolete: true
Attachment #165803 - Flags: first-review?(mostafah)
*** Bug 269805 has been marked as a duplicate of this bug. ***
Status: NEW → ASSIGNED
Comment on attachment 165803 [details] [diff] [review]
rev1 - more elegant, readable solution. Also catches exceptions when actually calling libical to delete

+		confirmText = (confirmDeleteEvent+" "+calendarEvent.title+"?"
);

That should use stringbundles and formatStringFromName instead. Please file a
followup bug for this.
(it already was like that, and should not hold back fixing the regression)
Attachment #165803 - Flags: first-review?(mostafah) → first-review+
patch checked in.
leaving open for checkin to sunbird0.2
Checked into 0.2 branch
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
The bugspam monkeys have been set free and are feeding on Calendar :: Sunbird Only. Be afraid for your sanity!
QA Contact: gurganbl → sunbird
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: