polfan-server-js-client 0.2.97 → 0.2.99
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 +30 -42
- package/build/index.cjs.js +17 -17
- package/build/index.cjs.js.map +1 -1
- package/build/index.umd.js +1 -1
- package/build/index.umd.js.map +1 -1
- package/build/types/state-tracker/FollowedTopicsManager.d.ts +3 -3
- package/package.json +1 -1
- package/src/state-tracker/FollowedTopicsManager.ts +8 -8
|
@@ -15,14 +15,14 @@ export declare class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
15
15
|
/**
|
|
16
16
|
* Cache followed topics for all joined rooms in a space and fetch them in bulk if necessary.
|
|
17
17
|
* Then you can get them using getRoomFollowedTopics().
|
|
18
|
-
* @see
|
|
18
|
+
* @see getForRoom
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
cacheForSpace(spaceId: string | null): Promise<void>;
|
|
21
21
|
/**
|
|
22
22
|
* Get followed topics for the given room.
|
|
23
23
|
* @return Undefined if you are not in the room, collection otherwise.
|
|
24
24
|
*/
|
|
25
|
-
|
|
25
|
+
getForRoom(roomId: string): Promise<ObservableIndexedObjectCollection<FollowedTopic> | undefined>;
|
|
26
26
|
/**
|
|
27
27
|
* Batch acknowledge all messages for given room.
|
|
28
28
|
*/
|
package/package.json
CHANGED
|
@@ -40,9 +40,9 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
40
40
|
/**
|
|
41
41
|
* Cache followed topics for all joined rooms in a space and fetch them in bulk if necessary.
|
|
42
42
|
* Then you can get them using getRoomFollowedTopics().
|
|
43
|
-
* @see
|
|
43
|
+
* @see getForRoom
|
|
44
44
|
*/
|
|
45
|
-
public async
|
|
45
|
+
public async cacheForSpace(spaceId: string | null): Promise<void> {
|
|
46
46
|
if (spaceId && ! (await this.tracker.spaces.get()).has(spaceId)) {
|
|
47
47
|
throw new Error(`You are not in space ${spaceId}`);
|
|
48
48
|
}
|
|
@@ -79,7 +79,7 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
79
79
|
* Get followed topics for the given room.
|
|
80
80
|
* @return Undefined if you are not in the room, collection otherwise.
|
|
81
81
|
*/
|
|
82
|
-
public async
|
|
82
|
+
public async getForRoom(roomId: string): Promise<ObservableIndexedObjectCollection<FollowedTopic> | undefined> {
|
|
83
83
|
if (! (await this.tracker.rooms.get()).has(roomId)) {
|
|
84
84
|
return undefined;
|
|
85
85
|
}
|
|
@@ -107,7 +107,7 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
107
107
|
* Batch acknowledge all messages for given room.
|
|
108
108
|
*/
|
|
109
109
|
public async ackRoom(roomId: string): Promise<void> {
|
|
110
|
-
const collection = await this.
|
|
110
|
+
const collection = await this.getForRoom(roomId);
|
|
111
111
|
|
|
112
112
|
if (! collection) {
|
|
113
113
|
return;
|
|
@@ -152,10 +152,10 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
152
152
|
} else if (location.roomId) {
|
|
153
153
|
roomIds = [location.roomId];
|
|
154
154
|
} else if (location.spaceId) {
|
|
155
|
-
await this.
|
|
155
|
+
await this.cacheForSpace(location.spaceId);
|
|
156
156
|
roomIds = rooms.findBy('spaceId', location.spaceId).items.map(r => r.id);
|
|
157
157
|
} else {
|
|
158
|
-
await this.
|
|
158
|
+
await this.cacheForSpace(null);
|
|
159
159
|
roomIds = rooms.items.filter(r => !r.spaceId).map(r => r.id);
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -163,7 +163,7 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
163
163
|
let isUnread = false;
|
|
164
164
|
|
|
165
165
|
for (const roomId of roomIds) {
|
|
166
|
-
const collection = await this.
|
|
166
|
+
const collection = await this.getForRoom(roomId);
|
|
167
167
|
|
|
168
168
|
if (!collection) {
|
|
169
169
|
continue;
|
|
@@ -321,7 +321,7 @@ export class FollowedTopicsManager extends EventTarget<EventMap> {
|
|
|
321
321
|
} else if (ev.message.type === 'Text') {
|
|
322
322
|
// ...check for mentions if it's text message...
|
|
323
323
|
const member = await this.tracker.rooms.getMe(ev.message.location.roomId);
|
|
324
|
-
const roleIds = [...(member.spaceMember?.roles ?? []), ...member.roles];
|
|
324
|
+
const roleIds = [...(member.spaceMember?.roles ?? []), ...(member.roles ?? [])];
|
|
325
325
|
const mentionHandlers = [
|
|
326
326
|
...roleIds.map(id => `<@&${id}>`),
|
|
327
327
|
`<@${me.id}>`,
|