Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
frankpagan committed Oct 21, 2023
2 parents 3c290fe + 3bcc92e commit d293be3
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@
if (!lastSynced) {
config.set(socket.url, message._id)
} else if (lastSynced !== message._id) {
if (self.getDateFromObjectId(lastSynced) < self.getDateFromObjectId(message._id)) {
if (indexeddb.ObjectId(lastSynced).timestamp < indexeddb.ObjectId(message._id).timestamp) {
config.set(socket.url, message._id)
}
}
Expand Down Expand Up @@ -509,20 +509,7 @@

sendLocalMessage(data) {
this.__fireListeners(data)
},

// TODO: add to ObjectId function
getDateFromObjectId(objectIdStr) {
if (objectIdStr.length !== 24) {
throw new Error('Invalid ObjectId string');
}

const timestampHex = objectIdStr.substring(0, 8);
const timestampInt = parseInt(timestampHex, 16) * 1000; // Multiply by 1000 to get milliseconds
return new Date(timestampInt);
}


}

if (isBrowser) {
Expand Down

0 comments on commit d293be3

Please sign in to comment.