@vnejs/plugins.feature.history 0.0.1 → 0.1.0

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.
Files changed (2) hide show
  1. package/modules/history.js +12 -11
  2. package/package.json +5 -6
@@ -31,22 +31,23 @@ export class History extends Module {
31
31
 
32
32
  const uid = (await this.emitOne(this.EVENTS.VENDORS.UID)).split("-").slice(0, 3).join("");
33
33
 
34
- this.log({ action: "add", uid });
34
+ this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "add", uid } });
35
+
36
+ const speaker = this.presavedHistory?.text?.text.speaker;
35
37
 
36
38
  this.shared.history.storage[uid] = this.presavedHistory;
37
39
  this.shared.history.storageKeys.push(uid);
38
40
  this.state.history.push({
39
41
  uid,
40
- label: this.presavedHistory.scenario.label,
41
- text: this.presavedHistory.text.originalText,
42
- speaker: this.presavedHistory.text.speaker,
43
- meet: this.presavedHistory.meet[this.presavedHistory.text.speaker] || 0,
42
+ label: this.presavedHistory?.scenario.label,
43
+ text: this.presavedHistory?.text?.originalText,
44
+ speaker,
45
+ meet: this.presavedHistory?.["text.meet"][speaker] || 0,
44
46
  });
45
47
 
46
48
  while (this.state.history.length > 50) this.state.history.shift();
47
49
  this.maxCurrentItem = this.state.history.length - 1;
48
- while (this.shared.history.storageKeys.length > 100)
49
- delete this.shared.history.storage[this.shared.history.storageKeys.shift()];
50
+ while (this.shared.history.storageKeys.length > 100) delete this.shared.history.storage[this.shared.history.storageKeys.shift()];
50
51
  };
51
52
 
52
53
  onHistoryLoad = async ({ uid } = {}) => {
@@ -60,14 +61,14 @@ export class History extends Module {
60
61
  }
61
62
  await this.emit(this.EVENTS.SAVE.LOAD_STATE, { state: await this.emitOne(this.EVENTS.VENDORS.CLONE, state) });
62
63
  this.emit(this.EVENTS.SCENARIO.LABEL_GET, { label: state.scenario.label });
63
- } else this.log({ action: "deleted" });
64
+ } else {
65
+ this.emit(this.EVENTS.LOGS.EMIT, { module: this.name, value: { action: "deleted" } });
66
+ }
64
67
 
65
68
  this.currentItem = null;
66
69
  };
67
70
 
68
- onHistoryBack = () =>
69
- this.state.history.length &&
70
- this.emit(this.EVENTS.HISTORY.LOAD, { uid: this.state.history[this.state.history.length - 1].uid });
71
+ onHistoryBack = () => this.state.history.length && this.emit(this.EVENTS.HISTORY.LOAD, { uid: this.state.history[this.state.history.length - 1].uid });
71
72
 
72
73
  onSetState = async (globalState = {}) => {
73
74
  this.state.history = globalState[this.name].history;
package/package.json CHANGED
@@ -1,18 +1,17 @@
1
1
  {
2
2
  "name": "@vnejs/plugins.feature.history",
3
- "version": "0.0.1",
3
+ "version": "0.1.0",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",
7
+ "publish:major:plugin": "npm run publish:major",
8
+ "publish:minor:plugin": "npm run publish:minor",
9
+ "publish:patch:plugin": "npm run publish:patch",
7
10
  "publish:major": "npm version major && npm publish --access public",
8
11
  "publish:minor": "npm version minor && npm publish --access public",
9
12
  "publish:patch": "npm version patch && npm publish --access public"
10
13
  },
11
14
  "author": "",
12
15
  "license": "ISC",
13
- "description": "",
14
- "peerDependencies": {
15
- "@vnejs/shared": "*",
16
- "@vnejs/module": "*"
17
- }
16
+ "description": ""
18
17
  }