More receipt fixes

This commit is contained in:
N-Pex 2021-03-04 12:48:32 +01:00
parent 6e38fe2b08
commit 902fa3a171
2 changed files with 78 additions and 77 deletions

View file

@ -358,7 +358,7 @@ export default {
RoomHistoryVisibility, RoomHistoryVisibility,
DebugEvent, DebugEvent,
MessageOperations, MessageOperations,
VoiceRecorder VoiceRecorder,
}, },
data() { data() {
@ -563,56 +563,57 @@ export default {
{} {}
); );
const self = this; const self = this;
this.timelineWindow.load(initialEventId, 20) this.timelineWindow
.then(() => { .load(initialEventId, 20)
console.log("This is", self); .then(() => {
self.events = self.timelineWindow.getEvents(); console.log("This is", self);
self.events = self.timelineWindow.getEvents();
const getMoreIfNeeded = function _getMoreIfNeeded() { const getMoreIfNeeded = function _getMoreIfNeeded() {
const container = self.$refs.chatContainer; const container = self.$refs.chatContainer;
if ( if (
container.scrollHeight <= container.clientHeight && container.scrollHeight <= container.clientHeight &&
self.timelineWindow && self.timelineWindow &&
self.timelineWindow.canPaginate(EventTimeline.BACKWARDS) self.timelineWindow.canPaginate(EventTimeline.BACKWARDS)
) { ) {
return self.timelineWindow return self.timelineWindow
.paginate(EventTimeline.BACKWARDS, 10, true, 5) .paginate(EventTimeline.BACKWARDS, 10, true, 5)
.then((success) => { .then((success) => {
self.events = self.timelineWindow.getEvents(); self.events = self.timelineWindow.getEvents();
if (success) { if (success) {
return _getMoreIfNeeded.call(self); return _getMoreIfNeeded.call(self);
} else { } else {
return Promise.reject("Failed to paginate"); return Promise.reject("Failed to paginate");
} }
}); });
} else { } else {
return Promise.resolve("Done"); return Promise.resolve("Done");
}
}.bind(self);
getMoreIfNeeded()
.catch((err) => {
console.log("ERROR " + err);
})
.finally(() => {
self.initialLoadDone = true;
if (initialEventId) {
self.scrollToEvent(initialEventId);
} }
self.restartRRTimer(); }.bind(self);
});
}) getMoreIfNeeded()
.catch(err => { .catch((err) => {
console.log("Error fetching events!", err, this); console.log("ERROR " + err);
if (err.errcode == 'M_UNKNOWN' && initialEventId) { })
// Try again without initial event! .finally(() => {
this.onRoomJoined(null); self.initialLoadDone = true;
} else { if (initialEventId) {
// Error. Done loading. self.scrollToEvent(initialEventId);
this.events = this.timelineWindow.getEvents(); }
this.initialLoadDone = true; self.restartRRTimer();
} });
}) })
.catch((err) => {
console.log("Error fetching events!", err, this);
if (err.errcode == "M_UNKNOWN" && initialEventId) {
// Try again without initial event!
this.onRoomJoined(null);
} else {
// Error. Done loading.
this.events = this.timelineWindow.getEvents();
this.initialLoadDone = true;
}
});
}, },
onRoomNotJoined() { onRoomNotJoined() {
@ -1108,27 +1109,27 @@ export default {
// Already sent this or too old... // Already sent this or too old...
break; break;
} }
// Is it an incoming event? // Make sure it's not a local echo event...
if (event.getSender() !== this.$matrix.currentUserId) { if (!event.getId().startsWith("~")) {
// Send read receipt // Send read receipt
this.$matrix.matrixClient this.$matrix.matrixClient
.sendReadReceipt(event) .sendReadReceipt(event)
.then(() => { .then(() => {
this.$matrix.matrixClient.setRoomReadMarkers( this.$matrix.matrixClient.setRoomReadMarkers(
this.room.roomId, this.room.roomId,
event.getId() event.getId()
); );
}) })
.then(() => { .then(() => {
console.log("RR sent for event: " + event.getId()); console.log("RR sent for event: " + event.getId());
this.lastRR = event; this.lastRR = event;
}) })
.catch((err) => { .catch((err) => {
console.log("Failed to update read marker: ", err); console.log("Failed to update read marker: ", err);
}) })
.finally(() => { .finally(() => {
this.restartRRTimer(); this.restartRRTimer();
}); });
return; // Bail out here return; // Bail out here
} }
@ -1161,12 +1162,12 @@ export default {
onVoiceRecording(event) { onVoiceRecording(event) {
util.sendImage( util.sendImage(
this.$matrix.matrixClient, this.$matrix.matrixClient,
this.roomId, this.roomId,
event.file, event.file,
undefined undefined
); );
} },
}, },
}; };
</script> </script>

View file

@ -143,7 +143,7 @@ export default {
if (!this.$matrix.currentUser) { if (!this.$matrix.currentUser) {
return null; return null;
} }
return (this.$matrix.userDisplayName || this.$matrix.currentUser.userId.substring(1)).substring(0, 1).toUpperCase(); return (this.$matrix.userDisplayName || this.$matrix.currentUserId.substring(1)).substring(0, 1).toUpperCase();
} }
}, },
methods: { methods: {