web: Added interval checking for nos2x
This commit is contained in:
parent
72346522eb
commit
ef1c2ca525
2 changed files with 21 additions and 4 deletions
|
@ -18,11 +18,8 @@
|
||||||
<script>
|
<script>
|
||||||
// This is our main entry.
|
// This is our main entry.
|
||||||
// https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event
|
// https://developer.mozilla.org/en-US/docs/Web/API/Window/DOMContentLoaded_event
|
||||||
console.log("window.nostr", window.nostr)
|
|
||||||
addEventListener('DOMContentLoaded', (ev) => {
|
addEventListener('DOMContentLoaded', (ev) => {
|
||||||
// TODO fix race condition where profile doesn't load fast enough.
|
damus_web_init()
|
||||||
setTimeout(damus_web_init, 500);
|
|
||||||
init_message_textareas();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<nav id="gnav" class="">
|
<nav id="gnav" class="">
|
||||||
|
|
|
@ -120,6 +120,26 @@ function notice_chatroom(state, id)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function damus_web_init()
|
async function damus_web_init()
|
||||||
|
{
|
||||||
|
init_message_textareas();
|
||||||
|
|
||||||
|
let tries = 0;
|
||||||
|
function init() {
|
||||||
|
// only wait for 500ms max
|
||||||
|
const max_wait = 500
|
||||||
|
const interval = 20
|
||||||
|
if (window.nostr || tries >= (max_wait/interval)) {
|
||||||
|
console.info("init after", tries);
|
||||||
|
damus_web_init_ready();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tries++;
|
||||||
|
setTimeout(init, interval);
|
||||||
|
}
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function damus_web_init_ready()
|
||||||
{
|
{
|
||||||
const model = init_home_model()
|
const model = init_home_model()
|
||||||
DAMUS = model
|
DAMUS = model
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue