Skip to content

Commit

Permalink
fix(message timestamp): convert inside mailbox manager instead
Browse files Browse the repository at this point in the history
  • Loading branch information
josephmcg committed Jan 6, 2022
1 parent 35d6577 commit 9c6314e
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
3 changes: 2 additions & 1 deletion libraries/Textile/MailboxManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ export class MailboxManager {

// if messages are stored in indexeddb, only fetch new messages from textile
if (lastInbound) {
lastInbound = lastInbound * 1000000 // textile has a more specific unix timestamp, matching theirs
inboxQuery = Query.where('from')
.eq(friendIdentifier)
.and(PropCommonEnum.MOD)
Expand Down Expand Up @@ -130,7 +131,7 @@ export class MailboxManager {

let encryptedSentbox: MessageFromThread[] = []

// only fetch sent messages if indexeddb is empty. after that, sending/editing action will add to indexeddb
// only fetch sent messages from textile if indexeddb is empty. after that, fetch sent messages from indexeddb
if (lastInbound === undefined) {
encryptedSentbox = await this.textile.client.find<MessageFromThread>(
threadID,
Expand Down
Empty file added plugins/local/indexed.ts
Empty file.
5 changes: 2 additions & 3 deletions store/textile/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { Config } from '~/config'
import { MailboxSubscriptionType, Message } from '~/types/textile/mailbox'
import { UploadDropItemType } from '~/types/files/file'
import { db, DexieMessage } from '~/plugins/thirdparty/dexie'
import { reject } from 'lodash'

export default {
/**
Expand Down Expand Up @@ -83,10 +82,10 @@ export default {
const textileMessages = await $MailboxManager.getConversation({
friendIdentifier: friend.textilePubkey,
query,
lastInbound: lastInbound * 1000000, // textile has a more specific unix timestamp, matching theirs
lastInbound: lastInbound,
})

// use textileMessages as primary source. this way, old versions of edited messages (with the same id) will not be used
// use textileMessages as primary source. this way, edited messages will use the newest version
const ids = new Set(textileMessages.map((d) => d.id))
conversation = [
...textileMessages,
Expand Down

0 comments on commit 9c6314e

Please sign in to comment.