thread fetch filter
This commit is contained in:
parent
51a50430a4
commit
f58838cee4
9 changed files with 33 additions and 14 deletions
3
dist/src/net.d.ts
vendored
3
dist/src/net.d.ts
vendored
|
@ -36,8 +36,9 @@ export declare class Network {
|
|||
from?: string;
|
||||
limit?: number;
|
||||
roomIds?: Array<t.RoomId>;
|
||||
muted?: boolean;
|
||||
watching?: boolean;
|
||||
include?: Array<t.IncludeThreads>;
|
||||
unread?: boolean;
|
||||
}): Promise<t.ThreadsResponse>;
|
||||
fetchInbox(opts: {
|
||||
roomIds?: Array<t.RoomId>;
|
||||
|
|
5
dist/src/net.js
vendored
5
dist/src/net.js
vendored
|
@ -171,9 +171,10 @@ export class Network {
|
|||
method: "POST",
|
||||
path: `/_matrix/client/v1/threads?limit=${opts.limit || 50}${opts.from ? `&from=${e(opts.from)}` : ""}`,
|
||||
body: {
|
||||
watching: opts.watching,
|
||||
room_ids: opts.roomIds,
|
||||
include: opts.include,
|
||||
muted: opts.muted,
|
||||
watching: opts.watching,
|
||||
unread: opts.unread,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
2
dist/src/net.js.map
vendored
2
dist/src/net.js.map
vendored
File diff suppressed because one or more lines are too long
6
dist/src/room.d.ts
vendored
6
dist/src/room.d.ts
vendored
|
@ -48,16 +48,18 @@ export declare class ThreadPaginator extends Map<EventId, Thread> {
|
|||
rooms: Array<Room>;
|
||||
opts: {
|
||||
from?: string;
|
||||
muted?: boolean;
|
||||
watching?: boolean;
|
||||
include?: Array<IncludeThreads>;
|
||||
unread?: boolean;
|
||||
};
|
||||
list: Array<Thread>;
|
||||
isAtEnd: boolean;
|
||||
private nextBatch;
|
||||
constructor(client: Client, rooms: Array<Room>, opts: {
|
||||
from?: string;
|
||||
muted?: boolean;
|
||||
watching?: boolean;
|
||||
include?: Array<IncludeThreads>;
|
||||
unread?: boolean;
|
||||
});
|
||||
paginate(limit?: number): Promise<boolean>;
|
||||
}
|
||||
|
|
3
dist/src/room.js
vendored
3
dist/src/room.js
vendored
|
@ -213,8 +213,9 @@ export class ThreadPaginator extends Map {
|
|||
return false;
|
||||
const data = await this.client.net.fetchThreads({
|
||||
roomIds: this.rooms.map(i => i.id),
|
||||
muted: this.opts.muted,
|
||||
watching: this.opts.watching,
|
||||
include: this.opts.include,
|
||||
unread: this.opts.unread,
|
||||
from: this.nextBatch,
|
||||
limit,
|
||||
});
|
||||
|
|
2
dist/src/room.js.map
vendored
2
dist/src/room.js.map
vendored
File diff suppressed because one or more lines are too long
2
dist/tsconfig.tsbuildinfo
vendored
2
dist/tsconfig.tsbuildinfo
vendored
File diff suppressed because one or more lines are too long
14
src/net.ts
14
src/net.ts
|
@ -193,14 +193,22 @@ export class Network {
|
|||
return this.fetch({ method: "GET", path });
|
||||
}
|
||||
|
||||
public async fetchThreads(opts: { from?: string, limit?: number, roomIds?: Array<t.RoomId>, watching?: boolean, include?: Array<t.IncludeThreads> }): Promise<t.ThreadsResponse> {
|
||||
public async fetchThreads(opts: {
|
||||
from?: string,
|
||||
limit?: number,
|
||||
roomIds?: Array<t.RoomId>,
|
||||
muted?: boolean,
|
||||
watching?: boolean,
|
||||
unread?: boolean,
|
||||
}): Promise<t.ThreadsResponse> {
|
||||
return this.fetch({
|
||||
method: "POST",
|
||||
path: `/_matrix/client/v1/threads?limit=${opts.limit || 50}${opts.from ? `&from=${e(opts.from)}`: ""}`,
|
||||
body: {
|
||||
watching: opts.watching,
|
||||
room_ids: opts.roomIds,
|
||||
include: opts.include,
|
||||
muted: opts.muted,
|
||||
watching: opts.watching,
|
||||
unread: opts.unread,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
10
src/room.ts
10
src/room.ts
|
@ -167,7 +167,12 @@ export class ThreadPaginator extends Map<EventId, Thread> {
|
|||
public client: Client,
|
||||
// i need the user to pass a room, not id, so that its guaranteed to exist on the client
|
||||
public rooms: Array<Room>,
|
||||
public opts: { from?: string, watching?: boolean, include?: Array<IncludeThreads> },
|
||||
public opts: {
|
||||
from?: string,
|
||||
muted?: boolean,
|
||||
watching?: boolean,
|
||||
unread?: boolean,
|
||||
},
|
||||
) {
|
||||
super();
|
||||
if (opts.from) this.nextBatch = opts.from;
|
||||
|
@ -177,8 +182,9 @@ export class ThreadPaginator extends Map<EventId, Thread> {
|
|||
if (this.isAtEnd) return false;
|
||||
const data = await this.client.net.fetchThreads({
|
||||
roomIds: this.rooms.map(i => i.id),
|
||||
muted: this.opts.muted,
|
||||
watching: this.opts.watching,
|
||||
include: this.opts.include,
|
||||
unread: this.opts.unread,
|
||||
from: this.nextBatch,
|
||||
limit,
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue