Compare commits

...

2 commits

Author SHA1 Message Date
Badri Sunderarajan 8d1ca787fa
Set message limits and disable group autojoin
All this is in order to solve the big problem with Convo, which
was that a large number of messages coming in (as is the case with
highly active groupchats) would overload the entire app and cause
it to crash.

To fix this, I've taken the somewhat draconian measure of not
auto-joining any groupchats at all. Of course, this should be
better optimised in future, starting with an option to join
specific groupchats, and later perhaps allowing the user to "pin"
one or two important groupchats, or have some kind of cyclical
function that catches up on one groupchat at a time, checks for
important mentions, and then closes it to save memory.

Another option would be to load the groupchat data but offload it
from the working memory; unfortunately that'd require a greater
knowledge of the internal workings of ConverseJS than I currently
posess.
2024-03-23 13:05:57 +05:30
Badri Sunderarajan 15bfc1599b
Lighten rendering function in conversation list
Instead of running the entire toArray of the chatboxes object, we
only render the information we need (id, title, last message text)
which will (hopefully) make for a less resource-hungry function
2024-03-23 13:04:25 +05:30
2 changed files with 27 additions and 5 deletions

View file

@ -55,6 +55,15 @@
enable_smacks: true,
allow_chat_pending_contacts: true,
allow_non_roster_messaging: true,
// Special optimisations to reduce memory usage on KaiOS
mam_request_all_pages: false,
muc_fetch_members: ['owner'], // no admin or member, to reduce load
muc_respect_autojoin: false,
archived_messages_page_size: 10,
prune_messages_above: 30,
// BOSH and WebSocket configuration
bosh_service_url: $useAdvancedSettings && $boshURL || undefined,
websocket_url: $useAdvancedSettings && $wsURL || undefined,
}

View file

@ -43,14 +43,27 @@
}
}), 1000)
let chatboxes = _converse?.chatboxes?.toArray() || []
// Helper function to convert chatboxes into
// (exceedingly lightweight) object array for
// final rendering
function chatboxesToArray(chatboxes) {
if (!chatboxes) return []
return _converse.chatboxes.models.map(c => ({
id: c.id,
title: c.attributes.name || c.attributes.id,
lastMessage: c.messages?.last()?.attributes?.body,
}))
}
let chatboxes = chatboxesToArray(_converse?.chatboxes)
_converse.on('chatBoxesFetched', () => {
chatboxes = _converse.chatboxes?.toArray() || []
chatboxes = chatboxesToArray(_converse.chatboxes)
})
_converse.on('message', () => {
chatboxes = _converse.chatboxes?.toArray() || []
chatboxes = chatboxesToArray(_converse.chatboxes)
})
</script>
@ -61,8 +74,8 @@
{:else}
{#each chatboxes as convo, index (convo.id)}
<ListItem
text={convo.attributes.nickname || convo.attributes.id}
subtext={convo.messages?.last()?.attributes?.body || undefined}
text={convo.title}
subtext={convo.lastMessage}
tabindex={index}
onclick={() => openChat(convo.id)}
/>