forked from andyburke/autonomous.contact
feature/refactor: smartfeeds to reduce the client complexity
This commit is contained in:
parent
46090d944a
commit
f6cd05beac
19 changed files with 782 additions and 800 deletions
|
|
@ -63,11 +63,13 @@ export async function GET(request: Request, meta: Record<string, any>): Promise<
|
|||
}
|
||||
} = /^.*\/events\/(?<event_type>.*?)\/.*\/(?<event_id>[A-Za-z-]+)\.json$/.exec(entry.path) ?? { groups: {} };
|
||||
|
||||
if (meta.query.after_id && event_id <= meta.query.after_id) {
|
||||
const id = `${event_type}:${event_id}`;
|
||||
|
||||
if (meta.query.after_id && id <= meta.query.after_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (meta.query.before_id && event_id >= meta.query.before_id) {
|
||||
if (meta.query.before_id && id >= meta.query.before_id) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -91,6 +93,10 @@ export async function GET(request: Request, meta: Record<string, any>): Promise<
|
|||
if (results.length === 0 && meta.query.wait) {
|
||||
return new Promise((resolve, reject) => {
|
||||
function on_create(create_event: any) {
|
||||
if (meta.query.type && create_event.item.type !== meta.query.type) {
|
||||
return;
|
||||
}
|
||||
|
||||
results.push(create_event.item);
|
||||
clearTimeout(timeout);
|
||||
events.off('create', on_create);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue