mozilla-b2g/gaia — pull request #22908 by jrburke (2014-08-15 03:02:21+00:00)
Title: Bug 1001629: email notification clear triggers failure in startup

If a notification for email is cleared from the notification tray, and the email app is not already running, the email app is launched.

Since it was a launch for a notification, the startup logic in mail_app sets waitForAppMessage to true, and that holds off the insertion of a card until more information about the notification is known, since the notification could be to go to the message_list or message_reader.

However, in app_messages, if the notification was not a 'clicked' message, it was discarded. This causes a problem because mail_app was waiting to hear back from app_messages to know what to do.

So now, if it is just a close of a notification, and not one that was clicked on, app_messages sends out a 'notificationClosed' event. mail_app listens for it, and if it was in that waiting state and there are no cards, the front end of the app is reset, which will lead to the insertion of the message_list card.