Flash messages for AJAX-ified actions appear multiple times if another flash div is already present

Description

Steps to reproduce:

This bug can happen anywhere we have an AJAX-y action and can make a flash div display on that page, but the easiest ways to test it are as follows:

Example 1:
1. While logged out, go to a tag's works index, e.g. http://test.archiveofourown.org/tags/Veronica%20Mars%20(TV)/works
2. Log in using the form in the upper right corner
3. This should return to you the work index you were just on, with a blue message saying, "Successfully logged in" across the top of the page. With that message still displaying, press "Favorite Tag" (or "Unfavorite Tag" if that's showing – either will cause this problem)

Example 2:
1. Log in
2. Hi, username! > My Preferences
3. Check "Turn the new user help banner back on."
4. Press "Update"
5. This should return you to you dashboard, where you will see a blue message saying, "Your preferences were successfully updated" and another blue message saying, "Hi! It looks like you've just logged into the archive for the first time..." With those messages still displaying, press "Subscribe" (or "Unsubscribe" if that's showing – either will cause this problem)

What happens:

Example 1:
"You have successfully added Veronica Mars (TV) to your favorite tags. You can find them on the Archive homepage," will appear twice at the top of the page, in two separate blue banners.

Example 2:
"You are now following [user]. If you'd like to stop receiving email updates, you can unsubscribe from your Subscriptions page," will appear three times at the top of the page, in three separate blue banners.

What should happen instead:

The message should only appear once. Preferably, it will replace the "Successfully logged in" message or the "Your preferences were successfully updated" message, but the new user help banner will stay in place.

Notes:

I'd suggest taking the "flash" class off the new user help banner, since it's just a notice (we use the class "notice" by itself in other places where we want the blue background to get attention): https://github.com/otwcode/otwarchive/blob/c1e4bf14ade86b345e78e705d2caffb8643948ff/app/views/users/show.html.erb#L2

Assignee

Unassigned

Reporter

Sarken

Roadmap

Misc

Priority

Low

Affects versions

Fix versions

None

Components

FrontEnd

Difficulty

Medium

Milestone

Internal 0.9