thread fetch filter

This commit is contained in:
tezlm 2024-01-16 01:12:02 -08:00
parent 51a50430a4
commit f58838cee4
Signed by: tezlm
GPG key ID: 649733FCD94AFBBA
9 changed files with 33 additions and 14 deletions

3
dist/src/net.d.ts vendored
View file

@ -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
View file

@ -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

File diff suppressed because one or more lines are too long

6
dist/src/room.d.ts vendored
View file

@ -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
View file

@ -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,
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -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,
}
});
}

View file

@ -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,
});