Skip to content

Commit

Permalink
Fix duplicate message after dismissing suggestions
Browse files Browse the repository at this point in the history
If we create one category_meta_message for each category, removing when
not relevant, then duplicat suggestion showing leads to duplicate
messages because the layer is still relevant, just not visible, and so
the old layer message is not removed. Instead, repurpose the ID of any
existing category_meta_message, so there is only ever one in existence.
  • Loading branch information
dracos committed Jul 2, 2020
1 parent c8d6856 commit 5768cc0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -20,6 +20,7 @@
- Skip accounts without email when sending inactive emails.
- Include file extensions in Dropzone accepted photo config.
- Fix photo orientation in modern browsers.
- Fix duplicate asset message after dismissing duplicate suggestions.
- Admin improvements:
- Display user name/email for contributed as reports. #2990
- Interface for enabling anonymous reports for certain categories. #2989
Expand Down
8 changes: 6 additions & 2 deletions web/cobrands/fixmystreet/assets.js
Expand Up @@ -419,17 +419,18 @@ function check_zoom_message_visibility() {
category = $("select#" + select).val() || '',
prefix = category.replace(/[^a-z]/gi, ''),
id = "category_meta_message_" + prefix,
$p = $('#' + id),
$p = $('.category_meta_message'),
message;
if ($p.length === 0) {
$p = $("<p>").prop("id", id).prop('class', 'category_meta_message');
$p = $("<p>").prop('class', 'category_meta_message');
if ($('html').hasClass('mobile')) {
$p.click(function() {
$("#mob_ok").trigger('click');
}).addClass("btn");
}
$p.prependTo('#js-post-category-messages');
}
$p.prop('id', id);

if (this.getVisibility() && this.inRange) {
message = get_asset_pick_message.call(this);
Expand All @@ -453,6 +454,9 @@ function get_asset_pick_message() {
return message;
}

/* This doesn't just use the class because e.g. an unselect event
* can fire after a category change event, and that would then
* update the new message using the text of the unselected layer. */
function update_message_display(message) {
if (this.fixmystreet.asset_group) {
_update_message(message, this.fixmystreet.asset_group);
Expand Down

0 comments on commit 5768cc0

Please sign in to comment.