@cocreate/crdt 1.9.4 → 1.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,31 @@
1
+ ## [1.9.8](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.7...v1.9.8) (2022-02-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update dependencies ([6ce8b07](https://github.com/CoCreate-app/CoCreate-crdt/commit/6ce8b07e9750459abba94ffb6e81df383656d999))
7
+
8
+ ## [1.9.7](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.6...v1.9.7) (2022-02-16)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * update action param to name ([49e60b5](https://github.com/CoCreate-app/CoCreate-crdt/commit/49e60b593477e138fd3ae6bd6738f4f64fb804f6))
14
+
15
+ ## [1.9.6](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.5...v1.9.6) (2022-02-10)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bump dependencies ([138f512](https://github.com/CoCreate-app/CoCreate-crdt/commit/138f512c71cc486762bcc291990437006b94af6a))
21
+
22
+ ## [1.9.5](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.4...v1.9.5) (2022-02-08)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * value duplication resolved ([8894449](https://github.com/CoCreate-app/CoCreate-crdt/commit/8894449cda528249a3f7731490251b07db2a0a61))
28
+
1
29
  ## [1.9.4](https://github.com/CoCreate-app/CoCreate-crdt/compare/v1.9.3...v1.9.4) (2022-02-07)
2
30
 
3
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/crdt",
3
- "version": "1.9.4",
3
+ "version": "1.9.8",
4
4
  "description": "CoCreate crdt",
5
5
  "author": "CoCreate LLC",
6
6
  "license": "SEE LICENSE",
@@ -43,9 +43,9 @@
43
43
  "webpack-log": "^3.0.1"
44
44
  },
45
45
  "dependencies": {
46
- "@cocreate/actions": "^1.3.30",
47
- "@cocreate/crud-client": "^1.4.45",
48
- "@cocreate/message-client": "^1.1.62",
49
- "@cocreate/utils": "^1.6.2"
46
+ "@cocreate/actions": "^1.3.33",
47
+ "@cocreate/crud-client": "^1.4.47",
48
+ "@cocreate/message-client": "^1.1.64",
49
+ "@cocreate/utils": "^1.6.4"
50
50
  }
51
51
  }
package/src/index.js CHANGED
@@ -6,7 +6,8 @@ import action from '@cocreate/actions';
6
6
 
7
7
  const docs = new Map();
8
8
  const clientId = config.clientId || window.CoCreateSockets.clientId || uuid.generate(12);
9
-
9
+ const checkedDb = new Map();
10
+ const isInit = new Map();
10
11
 
11
12
  function init(info){
12
13
  getText(info).then(value => {
@@ -21,20 +22,23 @@ async function getDoc(info) {
21
22
  try {
22
23
  let docName = generateDocName(info);
23
24
  let typeName = info.name;
24
-
25
- if (!docs.has(docName)) {
25
+ let doc = docs.get(docName);
26
+
27
+ if (!doc) {
26
28
  let docNameMap = new Map();
27
29
  docs.set(docName, docNameMap);
30
+ doc = docs.get(docName);
28
31
  }
29
32
 
30
- if (!docs.get(docName).has(typeName)) {
33
+ let type = doc.get(typeName)
34
+ if (!type) {
31
35
  let typeNameMap = new Map();
32
- docs.get(docName).set(typeName, typeNameMap);
36
+ doc.set(typeName, typeNameMap);
37
+ type = doc.get(typeName)
33
38
  }
34
-
35
- if (!docs.get(docName).get(typeName).has('changeLog')) {
39
+ if (!type.has('changeLog')) {
36
40
  let changeLog = [];
37
-
41
+
38
42
  if (info.read != 'false') {
39
43
  let response = await crud.readDocumentList({
40
44
  collection: "crdt-transactions",
@@ -49,11 +53,12 @@ async function getDoc(info) {
49
53
  if (response.data.length && response.data[0][typeName]) {
50
54
  changeLog = response.data[0][typeName];
51
55
  }
52
- docs.get(docName).get(typeName).set('changeLog', changeLog);
56
+ type.set('changeLog', changeLog);
53
57
  await generateText(info, true);
54
58
  }
59
+
55
60
  }
56
- else if (!docs.get(docName).get(typeName).has('text')){
61
+ else if (!type.has('text')){
57
62
  await generateText(info, false);
58
63
  }
59
64
  return true;
@@ -88,7 +93,9 @@ async function generateText(info, flag) {
88
93
 
89
94
  async function checkDb(info, flag) {
90
95
  let { collection, document_id, name } = info;
91
- let response = await crud.readDocument({ collection, document_id, name })
96
+ if (checkedDb.get(`${collection}${document_id}${name}`)) return;
97
+ checkedDb.set(`${collection}${document_id}${name}`, true);
98
+ let response = await crud.readDocument({ collection, document_id, name });
92
99
  let string = response.data[name];
93
100
  if (string && flag != false) {
94
101
  info.value = string;
@@ -233,8 +240,6 @@ async function getText(info) {
233
240
  let doc = await getDoc(info);
234
241
  if (doc) {
235
242
  let value = docs.get(docName).get(typeName).get('text')
236
- if (!value)
237
- console.log(value)
238
243
  return value;
239
244
  }
240
245
  else {
@@ -335,7 +340,7 @@ function generateDocName(info) {
335
340
  }
336
341
 
337
342
  action.init({
338
- action: "undo",
343
+ name: "undo",
339
344
  endEvent: "undo",
340
345
  callback: (btn, data) => {
341
346
  undoChange(btn);
@@ -343,7 +348,7 @@ action.init({
343
348
  });
344
349
 
345
350
  action.init({
346
- action: "redo",
351
+ name: "redo",
347
352
  endEvent: "redo",
348
353
  callback: (btn, data) => {
349
354
  redoChange(btn);