Skip to content

Commit 355308f

Browse files
committed
fix: improved socket.send conditions and sync conditions
1 parent a094fb2 commit 355308f

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/index.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,9 @@
8484
data['database'] = data.organization_id
8585
}
8686

87+
let response
8788
if (isBrowser && indexeddb && data['storage'].includes('indexeddb')) {
88-
let response = await indexeddb.send(data)
89+
response = await indexeddb.send(data)
8990

9091
let type = data.method.split('.')[0];
9192
if (data.status !== 'await' && type && response && response[type] && response[type].length) {
@@ -94,15 +95,14 @@
9495
response.resolved = true
9596

9697
this.socket.send(response)
97-
} else {
98-
this.socket.send(response || data).then((response) => {
99-
resolve(response);
100-
})
10198
}
102-
} else {
103-
this.socket.send(data).then((response) => {
99+
}
100+
101+
if (!response || response.status !== 'resolve') {
102+
this.socket.send(response || data).then((response) => {
104103
resolve(response);
105104
})
105+
106106
}
107107
})
108108
},
@@ -173,8 +173,7 @@
173173
}
174174

175175
response = await indexeddb.send(response)
176-
177-
if (!response[type].length || !response[type][0].organization_id) {
176+
if (!response[type].length || type === 'object' && response[type][0] && response[type][0]._id && Object.keys(response[type][0]).length === 1) {
178177
response.method = type + '.create'
179178
response[type] = data[type][i]
180179
response = await indexeddb.send(response)

0 commit comments

Comments
 (0)