fix: chats ui socket navigation

This commit is contained in:
trisua 2025-04-29 16:58:42 -04:00
parent 0304461389
commit 0dbf660399

View file

@ -96,6 +96,7 @@
<a <a
class="w-full justify-start button {% if selected_channel == channel.id %}quaternary{% else %}camo{% endif %}" class="w-full justify-start button {% if selected_channel == channel.id %}quaternary{% else %}camo{% endif %}"
href="/chats/{{ selected_community }}/{{ channel.id }}" href="/chats/{{ selected_community }}/{{ channel.id }}"
data-turbo="{{ selected_community == '0' }}"
> >
{{ icon "rss" }} {{ icon "rss" }}
<b class="name shortest">{{ channel.title }}</b> <b class="name shortest">{{ channel.title }}</b>
@ -443,7 +444,6 @@
</script> </script>
<script id="socket_init" data-turbo-permanent="true"> <script id="socket_init" data-turbo-permanent="true">
window.SUBSCRIBE_CHANNEL = "{{ selected_community }}" === "0";
globalThis.socket_init = () => { globalThis.socket_init = () => {
if (window.socket) { if (window.socket) {
window.socket.send("Close"); window.socket.send("Close");
@ -482,6 +482,8 @@
{% if selected_channel %} {% if selected_channel %}
<script> <script>
window.SUBSCRIBE_CHANNEL = "{{ selected_community }}" === "0";
setTimeout(() => { setTimeout(() => {
if (!window.SUBSCRIBE_CHANNEL) { if (!window.SUBSCRIBE_CHANNEL) {
// sub community // sub community
@ -494,7 +496,7 @@
socket_init(); socket_init();
} }
} }
}, 50); }, 100);
setTimeout(() => { setTimeout(() => {
window.socket.addEventListener("message", async (event) => { window.socket.addEventListener("message", async (event) => {