add config settings for typing notifications, message history and typing updates

This commit is contained in:
hippoz 2022-08-31 11:40:10 +03:00
parent e42176fac7
commit 8c75b96696
No known key found for this signature in database
GPG key ID: 7C52899193467641
2 changed files with 29 additions and 21 deletions

View file

@ -8,7 +8,11 @@ const defaults = {
"log:Gateway": false,
"log:Store": false,
"ui:stateful:presistSelectedChannel": true,
"ui:showSidebarToggle": false
"ui:showSidebarToggle": false,
"ui:online:processRemoteTypingEvents": true,
"ui:online:processRemotePresenceEvents": true,
"ui:online:loadMessageHistory": true,
"ui:online:sendTypingUpdates": true
};
const store = new Map(Object.entries(defaults));
const persistentProvider = localStorage;

View file

@ -229,7 +229,7 @@ class MessageStore extends Store {
}
async loadOlderMessages(beforeCommitToStore=null) {
if (this.channelId === -1)
if (!getItem("ui:online:loadMessageHistory") || this.channelId === -1)
return;
const oldestMessage = this.value[0];
@ -331,6 +331,7 @@ class TypingStore extends Store {
this.ownTimeout = null;
this.ownNeedsUpdate = true;
if (getItem("ui:online:processRemoteTypingEvents")) {
gateway.subscribe(GatewayPayloadType.TypingStart, ({ user, channel, time }) => {
if (userInfoStore && user.id === userInfoStore.value.id)
return;
@ -343,6 +344,7 @@ class TypingStore extends Store {
this.stoppedTyping(author_id);
});
}
}
stoppedTyping(id) {
const index = this.value.findIndex(e => e.user.id === id);
@ -392,7 +394,7 @@ class TypingStore extends Store {
}
async didInputKey() {
if (!userInfoStore.value)
if (!userInfoStore.value || !getItem("ui:online:sendTypingUpdates"))
return;
this.startedTyping(userInfoStore.value, selectedChannel.value.id, 6500);
@ -407,6 +409,7 @@ class PresenceStore extends Store {
constructor() {
super([], "PresenceStore");
if (getItem("ui:online:processRemotePresenceEvents")) {
gateway.subscribe(GatewayEventType.Ready, ({ presence }) => {
this.ingestPresenceUpdate(presence);
});
@ -415,6 +418,7 @@ class PresenceStore extends Store {
this.ingestPresenceUpdate(data);
});
}
}
entryIndexByUserId(userId) {
return this.value.findIndex(a => a.user.id === userId);