fix voting/flagging from a7299e84
If the Lobster replacement class isn't in the global scope, the existing Lobsters can't refer to it. But if it's in the global scope, the DOM isn't yet loaded for it to read the current username. When the old class is entirely replaced, insantiation of the class can move back into onPageLoad().
This commit is contained in:
parent
4c3c17710b
commit
48b23c148e
|
@ -316,8 +316,8 @@ const removeExtraInputs = () => {
|
|||
}
|
||||
|
||||
class _LobstersFunction {
|
||||
constructor () {
|
||||
this.curUser = document.body.getAttribute('data-username');
|
||||
constructor (username) {
|
||||
this.curUser = null;
|
||||
|
||||
this.storyFlagReasons = ({
|
||||
<%= Vote::STORY_REASONS.map{|k,v| "'#{k}': '#{v}'" }.join(", ") %>
|
||||
|
@ -544,12 +544,13 @@ class _LobstersFunction {
|
|||
}
|
||||
}
|
||||
|
||||
const Lobster = new _LobstersFunction();
|
||||
|
||||
onPageLoad(() => {
|
||||
Lobster.curUser = document.body.getAttribute('data-username'); // hack
|
||||
|
||||
// Global Functions
|
||||
|
||||
const Lobster = new _LobstersFunction();
|
||||
|
||||
on('click', '.markdown_help_label', (event) => {
|
||||
parentSelector(event.target, '.markdown_help_toggler').querySelector('.markdown_help').classList.toggle('display-block');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue