Banner not dismissing

Hello all
I have implemented custom code to inject a more dynamic banner into Discourse. I essentially just
set #banner-content to be an object with my secondary page as the body. This works quite well and
I am getting almost all of the results I expect.

The problem I have to manually set the banner-content depending on the URL as it wasn’t propagating properly. Once doing this however on a page refresh the banner comes back regardless of if the user dismissed it or not.

My question is this: Is there a site setting I can access via Discourse.user to determine if they’ve dismissed the banner?

Code I am using
<script type="text/discourse-plugin" version="0.4">
api.onPageChange((url, title) => {
    if(url === '/'){
        $('#banner').css({'display' : 'block'});
        $('#banner-content').html('<object class="banner-container" data="https://myforumurl/banner.html">');
    }
    
    //Display the whos online plugin only for staff.
    if(Discourse.User.currentProp('staff') !== true){
        $('#whos-online').remove();
    }

    /**
    * If the banner is showing detect if we are away from the main page.
    * If we are on any page other than home set the banner to be invisible. 
    * Don't use .remove(); as that would require re adding the element after.
    */
    if($('#banner').is(':visible')){
        if(url !== '/'){
            $('#banner').css({'display': 'none'});
        }
    }
}

Update

So it appears that the dismissed_banner_key is not being properly updated. When I select to update this key I get a new value which appears correct but I additionally get a NOT FOUND error. I know this is in reference to the dismissal as it only appears when I select to dismiss the banner. This was working fine before the most recent update. Has something happened in the most recent rev?

Not Found
s@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:14:27536
o@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:14:27393
i@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:14:27322
trigger@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:19:4711
_onError/<@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:19:6692
invokeWithOnError@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:7:17919
flush@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:7:18364
flush@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:7:19124
end@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:7:19469
run@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:7:20538
u@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:13:1629
e/i.error@https://myforum.com/assets/application-9e0a922055fc3f9e9e6a011c36bea139b9b6d7fe31884a4038e65a13fb75b5e1.js:2:1160
l@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:2:6359
fireWith@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:2:7127
r@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:3:10013
n/<@https://myforum.com/assets/ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:3:15842

Figured it out.

If there is a period (.) in a username the value cannot be stored properly. Actually many user items are broken as a result.

2 Likes

I’m not sure that’s an allowed character in Discourse usernames?

1 Like

I didn’t see it as unallowed but now that I do some more digging I see it is unallowed. :man_facepalming:
If it is unallowed there should be a more explicit notification when creating but now that I look at the
username requirements I feel like an idiot.

Seems that a . is the only character not being rejected. Tested all other characters (US) and got the appropriate error.

Where is the rejection failing? This could be our bug.

Rejection fails at both sign up and altering post account creation. When creating an account it fully says the username is available and usable.

Same thing when updating post creation via your user account. No error and updates just fine.

This statement seems inconsistent with your other statements? @jomaxro can you have a look?

1 Like

Ah probably poor wording on my end.

It accepts the username in both cases. It is post creation that things begin failing.

Sorry about that.

Alright, here’s what I’ve found.

:white_check_mark: I can register with a . in my username. I signed up on try as jo.maxro
:white_check_mark: I can activate my account on try.
:white_check_mark: I can create a new topic.
:white_check_mark: I can create a reply.
:x: I cannot dismiss a banner. When clicking the x is disappears, however it reappears upon page refresh. The following errors appear in the console when I click the x to close the banner.

_ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:9176 PUT https://try.discourse.org/u/jo.maxro 404 ()
send @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:9176
ajax @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:8657
e @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:2021
S @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:57172
M @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:57660
s @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:2036
dismissBanner @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:27255
dismiss @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:31874
send @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:50230
n @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:49950
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:23374
d @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:29665
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:23373
run @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12382
u @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:33455
e.handler @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:23353
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:51352
dispatch @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:4736
v.handle @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:4548
_ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:28913 undefined
u @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:28913
o @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:28892
i @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:42405
trigger @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:56776
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:57679
invokeWithOnError @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12021
flush @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12080
flush @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12204
end @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12274
run @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12388
u @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:33455
i.error @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:2001
l @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:3186
fireWith @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:3316
r @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:8760
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:9124
XMLHttpRequest.send (async)
send @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:9176
ajax @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:8657
e @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:2021
S @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:57172
M @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:57660
s @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:2036
dismissBanner @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:27255
dismiss @ _application-9ade5b6f55bdede6798107d6d110d9e3e3e62718fde1708cdccf171cb6b5cdef.js:31874
send @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:50230
n @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:49950
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:23374
d @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:29665
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:23373
run @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:12382
u @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:33455
e.handler @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:23353
(anonymous) @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:51352
dispatch @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:4736
v.handle @ _ember_jquery-a8dcbd325e04410f036f2a791d66d8316c48c5387acdd914de99a5dd6afb3cd3.js:4548
2 Likes

Getting the same thing on my end.

I’m guessing it was introduced recently as we have many uses with dots in the usernames and hadn’t had a complaint until now.

Have the same issue when we talk about the re-appearing banner. This happens only if the username of the logged in user includes a “dot” and also triggers an error in the console if the banner is closed.

  1. Are there any other known issues if a “dot” is in the username - e.g. max.muster?
  2. Is there a workaround for new installations to prevent the usage of “dots” or other problematic additional characters when choosing the username (for invite & self-signup)?

Fixed per:

https://github.com/discourse/discourse/commit/90351348ec3c0b1872aa680c0c9ddd5271e3740b

5 Likes