Fix duplicate messages arriving through websocket
This commit is contained in:
parent
f6310d3065
commit
dc5db6aac6
5 changed files with 24 additions and 24 deletions
12
js/db.js
12
js/db.js
|
|
@ -1,15 +1,9 @@
|
|||
import { normalizeId } from "./utils.js";
|
||||
|
||||
const DB_NAME = "pandora";
|
||||
const DB_VERSION = 6;
|
||||
let dbPromise = null;
|
||||
|
||||
function normalizeId(raw) {
|
||||
if (!raw) return null;
|
||||
if (typeof raw === 'object') {
|
||||
return raw._serialized || raw.user || JSON.stringify(raw);
|
||||
}
|
||||
return raw;
|
||||
}
|
||||
|
||||
function openDb() {
|
||||
if (dbPromise) return dbPromise;
|
||||
|
||||
|
|
@ -120,7 +114,7 @@ function mapMessage(m) {
|
|||
|
||||
return {
|
||||
_data: m._data,
|
||||
id: m.id,
|
||||
id: normalizeId(m.id),
|
||||
timestamp: m.timestamp,
|
||||
body: m.body,
|
||||
from: from,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue