Skip to content

Commit

Permalink
fix: restore functionality of backwards & forwards loader
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriansaliou committed Oct 18, 2023
1 parent 64e13d5 commit d04a830
Showing 1 changed file with 33 additions and 37 deletions.
70 changes: 33 additions & 37 deletions src/components/inbox/InboxMessaging.vue
Original file line number Diff line number Diff line change
Expand Up @@ -511,54 +511,49 @@ export default {
},

async syncMessagesEager(): Promise<void> {
// Can synchronize now? (connected)
// TODO
// if (
// this.isMessageSyncStale === true &&
// Store.$session.connected === true
// ) {

// Can synchronize now? (room is known)
if (this.room) {
// Can synchronize now? (connected & room is known)
if (
this.room &&
this.isMessageSyncStale === true &&
Store.$session.connected === true
) {
// Mark synchronization as non-stale
this.isMessageSyncStale = false;

// Load all messages
const messages = await this.room.loadLatestMessages(undefined, true);

Store.$inbox.insertCoreMessages(this.room.id, messages);

// Load all messages
// await Broker.$mam.loadLatestMessages(this.jid);
//
// const frameRuntime = this.frame();
//
// if (frameRuntime !== null) {
// // Mark forwards loading as complete
// frameRuntime.MessagingStore.loader("forwards", false);
//
// // TODO: Fix backwards loading after updating core lib
// // Mark backwards loading as complete?
// // if (result.complete === true) {
// // frameRuntime.MessagingStore.loader("backwards", false);
// // }
// } else {
// this.$log.warn(
// `Could not show loaders in message frame runtime upon eagerly ` +
// `synchronizing messages, as it is not ready yet for: ${this.jid}`
// );
// }
// }
// Update loading marker
const frameRuntime = this.frame();

if (frameRuntime !== null) {
// Mark forwards loading as complete
frameRuntime.MessagingStore.loader("forwards", false);

// TODO: Fix backwards loading after updating core lib
// Mark backwards loading as complete?
// if (result.complete === true) {
// frameRuntime.MessagingStore.loader("backwards", false);
// }
} else {
this.$log.warn(
`Could not show loaders in message frame runtime upon eagerly ` +
`synchronizing messages, as it is not ready yet for: ` +
`${this.room.id}`
);
}
}
},

async seekMoreMessages(): Promise<void> {
// Can seek now? (connected and not stale)
// TODO: Fix condition after updating core lib
if (
this.room
// Store.$session.connected === true &&
// this.isMessageSyncStale !== true &&
// this.isMessageSyncMoreLoading !== true
Store.$session.connected === true &&
this.room &&
this.isMessageSyncStale !== true &&
this.isMessageSyncMoreLoading !== true
) {
const frameRuntime = this.frame();

Expand All @@ -576,7 +571,7 @@ export default {

frameRuntime.MessagingStore.loader("backwards", true);

// TODO: this one is not working
// Load earlier messages
const messages = await this.room.loadLatestMessages(undefined, true);

Store.$inbox.insertCoreMessages(this.room.id, messages);
Expand All @@ -588,7 +583,8 @@ export default {
} else {
this.$log.warn(
`Could not seek previous messages, as there is no first ` +
`message from archives or frame is not ready yet for: ${this.jid}`
`message from archives or frame is not ready yet for: ` +
`${this.room.id}`
);
}
}
Expand Down

0 comments on commit d04a830

Please sign in to comment.