@diory/client-js 0.1.0 → 0.1.2

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.
@@ -10,11 +10,11 @@ declare class DioryClient implements IDioryClient {
10
10
  diory?: IDiory;
11
11
  constructor(dataClients: IDataClient[]);
12
12
  initialise: (connections: IConnectionObject[]) => Promise<void>;
13
+ enterRoom: (roomObject: IRoomObject) => Promise<void>;
14
+ focusDiory: (dioryObject: IDioryObject) => IDiory;
13
15
  getDiosphere: () => Promise<void>;
14
16
  saveDiosphere: () => Promise<void>;
15
- enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
16
17
  getDiograph: () => Promise<void>;
17
18
  saveDiograph: () => Promise<void>;
18
- focusDiory: (dioryObject: IDioryObject) => IDiory;
19
19
  }
20
20
  export { DioryClient };
@@ -21,11 +21,21 @@ class DioryClient {
21
21
  this.connections = [];
22
22
  this.initialise = async (connections) => {
23
23
  this.connections = connections;
24
+ this.diosphere.resetRooms();
24
25
  await this.getDiosphere();
25
26
  await this.enterRoom({ id: '/' });
26
- await this.focusDiory({ id: '/' });
27
27
  return;
28
28
  };
29
+ this.enterRoom = async (roomObject) => {
30
+ this.room = this.diosphere.getRoom(roomObject);
31
+ this.diograph.resetDiories();
32
+ await this.getDiograph();
33
+ this.focusDiory({ id: '/' });
34
+ return this.room;
35
+ };
36
+ this.focusDiory = (dioryObject) => {
37
+ return (this.diory = this.diograph.getDiory(dioryObject));
38
+ };
29
39
  this.getDiosphere = async () => {
30
40
  console.info('getDiosphere', this.connections);
31
41
  if (this.connections) {
@@ -49,11 +59,6 @@ class DioryClient {
49
59
  }
50
60
  return;
51
61
  };
52
- this.enterRoom = async (roomObject) => {
53
- this.room = this.diosphere.getRoom(roomObject);
54
- await this.getDiograph();
55
- return this.room;
56
- };
57
62
  this.getDiograph = async () => {
58
63
  var _a, _b;
59
64
  console.info('getDiograph', (_a = this.room) === null || _a === void 0 ? void 0 : _a.connections);
@@ -79,9 +84,6 @@ class DioryClient {
79
84
  }
80
85
  return;
81
86
  };
82
- this.focusDiory = (dioryObject) => {
83
- return (this.diory = this.diograph.getDiory(dioryObject));
84
- };
85
87
  this.dataClients = dataClients;
86
88
  this.diosphere = new diosphere_js_1.Diosphere();
87
89
  this.diograph = new diograph_1.Diograph();
package/dist/types.d.ts CHANGED
@@ -31,10 +31,10 @@ export interface IDioryClient {
31
31
  diograph: IDiograph;
32
32
  diory?: IDiory;
33
33
  initialise: (connections: IConnectionObject[]) => Promise<void>;
34
+ enterRoom: (roomObject: IRoomObject) => Promise<void>;
35
+ focusDiory: (dioryObject: IDioryObject) => IDiory;
34
36
  getDiosphere: () => void;
35
37
  saveDiosphere: () => void;
36
- enterRoom: (roomObject: IRoomObject) => Promise<IRoom>;
37
38
  getDiograph: () => void;
38
39
  saveDiograph: () => void;
39
- focusDiory: (dioryObject: IDioryObject) => IDiory;
40
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diory/client-js",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "author": "Olli-Pekka Pohjola <op@diory.me>, Jouni Alanen <jouni@diory.me>",
@@ -44,13 +44,27 @@ class DioryClient implements IDioryClient {
44
44
  initialise = async (connections: IConnectionObject[]): Promise<void> => {
45
45
  this.connections = connections
46
46
 
47
+ this.diosphere.resetRooms()
47
48
  await this.getDiosphere()
48
49
  await this.enterRoom({ id: '/' })
49
- await this.focusDiory({ id: '/' })
50
50
 
51
51
  return
52
52
  }
53
53
 
54
+ enterRoom = async (roomObject: IRoomObject): Promise<void> => {
55
+ this.room = this.diosphere.getRoom(roomObject)
56
+
57
+ this.diograph.resetDiories()
58
+ await this.getDiograph()
59
+ this.focusDiory({ id: '/' })
60
+
61
+ return this.room
62
+ }
63
+
64
+ focusDiory = (dioryObject: IDioryObject): IDiory => {
65
+ return (this.diory = this.diograph.getDiory(dioryObject))
66
+ }
67
+
54
68
  getDiosphere = async (): Promise<void> => {
55
69
  console.info('getDiosphere', this.connections)
56
70
  if (this.connections) {
@@ -84,14 +98,6 @@ class DioryClient implements IDioryClient {
84
98
  return
85
99
  }
86
100
 
87
- enterRoom = async (roomObject: IRoomObject): Promise<IRoom> => {
88
- this.room = this.diosphere.getRoom(roomObject)
89
-
90
- await this.getDiograph()
91
-
92
- return this.room
93
- }
94
-
95
101
  getDiograph = async (): Promise<void> => {
96
102
  console.info('getDiograph', this.room?.connections)
97
103
  if (this.room?.connections) {
@@ -124,10 +130,6 @@ class DioryClient implements IDioryClient {
124
130
 
125
131
  return
126
132
  }
127
-
128
- focusDiory = (dioryObject: IDioryObject): IDiory => {
129
- return (this.diory = this.diograph.getDiory(dioryObject))
130
- }
131
133
  }
132
134
 
133
135
  export { DioryClient }
package/src/types.ts CHANGED
@@ -39,10 +39,10 @@ export interface IDioryClient {
39
39
  diograph: IDiograph
40
40
  diory?: IDiory
41
41
  initialise: (connections: IConnectionObject[]) => Promise<void>
42
+ enterRoom: (roomObject: IRoomObject) => Promise<void>
43
+ focusDiory: (dioryObject: IDioryObject) => IDiory
42
44
  getDiosphere: () => void
43
45
  saveDiosphere: () => void
44
- enterRoom: (roomObject: IRoomObject) => Promise<IRoom>
45
46
  getDiograph: () => void
46
47
  saveDiograph: () => void
47
- focusDiory: (dioryObject: IDioryObject) => IDiory
48
48
  }