add config settings for typing notifications, message history and typing updates
This commit is contained in:
parent
e42176fac7
commit
8c75b96696
2 changed files with 29 additions and 21 deletions
|
@ -8,7 +8,11 @@ const defaults = {
|
||||||
"log:Gateway": false,
|
"log:Gateway": false,
|
||||||
"log:Store": false,
|
"log:Store": false,
|
||||||
"ui:stateful:presistSelectedChannel": true,
|
"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 store = new Map(Object.entries(defaults));
|
||||||
const persistentProvider = localStorage;
|
const persistentProvider = localStorage;
|
||||||
|
|
|
@ -229,7 +229,7 @@ class MessageStore extends Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
async loadOlderMessages(beforeCommitToStore=null) {
|
async loadOlderMessages(beforeCommitToStore=null) {
|
||||||
if (this.channelId === -1)
|
if (!getItem("ui:online:loadMessageHistory") || this.channelId === -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const oldestMessage = this.value[0];
|
const oldestMessage = this.value[0];
|
||||||
|
@ -331,17 +331,19 @@ class TypingStore extends Store {
|
||||||
this.ownTimeout = null;
|
this.ownTimeout = null;
|
||||||
this.ownNeedsUpdate = true;
|
this.ownNeedsUpdate = true;
|
||||||
|
|
||||||
gateway.subscribe(GatewayPayloadType.TypingStart, ({ user, channel, time }) => {
|
if (getItem("ui:online:processRemoteTypingEvents")) {
|
||||||
if (userInfoStore && user.id === userInfoStore.value.id)
|
gateway.subscribe(GatewayPayloadType.TypingStart, ({ user, channel, time }) => {
|
||||||
return;
|
if (userInfoStore && user.id === userInfoStore.value.id)
|
||||||
|
return;
|
||||||
this.startedTyping(user, channel.id, time);
|
|
||||||
});
|
this.startedTyping(user, channel.id, time);
|
||||||
|
});
|
||||||
// assume someone has stopped typing once they send a message
|
|
||||||
gateway.subscribe(GatewayPayloadType.MessageCreate, ({ author_id }) => {
|
// assume someone has stopped typing once they send a message
|
||||||
this.stoppedTyping(author_id);
|
gateway.subscribe(GatewayPayloadType.MessageCreate, ({ author_id }) => {
|
||||||
});
|
this.stoppedTyping(author_id);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stoppedTyping(id) {
|
stoppedTyping(id) {
|
||||||
|
@ -392,7 +394,7 @@ class TypingStore extends Store {
|
||||||
}
|
}
|
||||||
|
|
||||||
async didInputKey() {
|
async didInputKey() {
|
||||||
if (!userInfoStore.value)
|
if (!userInfoStore.value || !getItem("ui:online:sendTypingUpdates"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.startedTyping(userInfoStore.value, selectedChannel.value.id, 6500);
|
this.startedTyping(userInfoStore.value, selectedChannel.value.id, 6500);
|
||||||
|
@ -407,13 +409,15 @@ class PresenceStore extends Store {
|
||||||
constructor() {
|
constructor() {
|
||||||
super([], "PresenceStore");
|
super([], "PresenceStore");
|
||||||
|
|
||||||
gateway.subscribe(GatewayEventType.Ready, ({ presence }) => {
|
if (getItem("ui:online:processRemotePresenceEvents")) {
|
||||||
this.ingestPresenceUpdate(presence);
|
gateway.subscribe(GatewayEventType.Ready, ({ presence }) => {
|
||||||
});
|
this.ingestPresenceUpdate(presence);
|
||||||
|
});
|
||||||
gateway.subscribe(GatewayEventType.PresenceUpdate, (data) => {
|
|
||||||
this.ingestPresenceUpdate(data);
|
gateway.subscribe(GatewayEventType.PresenceUpdate, (data) => {
|
||||||
});
|
this.ingestPresenceUpdate(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
entryIndexByUserId(userId) {
|
entryIndexByUserId(userId) {
|
||||||
|
|
Loading…
Reference in a new issue