polfan-server-js-client 0.2.95 → 0.2.96
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/.idea/workspace.xml +16 -17
- package/build/index.cjs.js +180 -152
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/state-tracker/MessagesManager.ts +18 -9
package/package.json
CHANGED
|
@@ -57,24 +57,32 @@ export class MessagesManager {
|
|
|
57
57
|
throw new Error(`You are not in space ${spaceId}`);
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
const
|
|
60
|
+
const rooms = await this.tracker.rooms.get();
|
|
61
|
+
const roomIds = spaceId
|
|
62
|
+
? rooms.findBy('spaceId', spaceId).items.map(r => r.id)
|
|
63
|
+
: rooms.items.filter(r => !r.spaceId).map(r => r.id);
|
|
61
64
|
|
|
62
|
-
if (!
|
|
63
|
-
// We don't need to ping server for followed topics for this space, if user has no joined rooms
|
|
65
|
+
if (!roomIds.length) {
|
|
64
66
|
return;
|
|
65
67
|
}
|
|
66
68
|
|
|
67
|
-
const
|
|
69
|
+
const isAlreadyCached = roomIds.every(roomId => this.followedTopics.has(roomId));
|
|
70
|
+
if (isAlreadyCached) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
68
73
|
|
|
69
|
-
|
|
74
|
+
const spaceRegistryKey = `space_fetch_${spaceId || 'spaceless'}`;
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
if (this.followedTopicsPromises.notExist(spaceRegistryKey)) {
|
|
77
|
+
this.followedTopicsPromises.registerByFunction(async () => {
|
|
78
|
+
const result = await this.tracker.client.send('GetFollowedTopics', {location: {spaceId}});
|
|
79
|
+
if (result.error) throw result.error;
|
|
72
80
|
|
|
73
|
-
|
|
74
|
-
|
|
81
|
+
this.setFollowedTopicsArray(roomIds, result.data.followedTopics);
|
|
82
|
+
}, spaceRegistryKey);
|
|
75
83
|
}
|
|
76
84
|
|
|
77
|
-
this.
|
|
85
|
+
await this.followedTopicsPromises.get(spaceRegistryKey);
|
|
78
86
|
}
|
|
79
87
|
|
|
80
88
|
/**
|
|
@@ -155,6 +163,7 @@ export class MessagesManager {
|
|
|
155
163
|
await this.cacheSpaceFollowedTopics(location.spaceId);
|
|
156
164
|
roomIds = rooms.findBy('spaceId', location.spaceId).items.map(r => r.id);
|
|
157
165
|
} else {
|
|
166
|
+
await this.cacheSpaceFollowedTopics(null);
|
|
158
167
|
roomIds = rooms.items.filter(r => !r.spaceId).map(r => r.id);
|
|
159
168
|
}
|
|
160
169
|
|