diff --git a/src/adapters/action/dispatcher-http.ts b/src/adapters/action/dispatcher-http.ts index b1abfde4..a1d572ee 100644 --- a/src/adapters/action/dispatcher-http.ts +++ b/src/adapters/action/dispatcher-http.ts @@ -24,7 +24,7 @@ export class HttpActionDispatcher implements ActionDispatcher { private readonly params: HttpActionDispatcherParams = {}, ) {} - async dispatch(action: Action): Promise { + dispatch(action: Action): T | Promise { const actionType = this.toPrimitiveAction(action.type); const path = this.isPrimitiveAction(action.type) ? action.path @@ -38,12 +38,11 @@ export class HttpActionDispatcher implements ActionDispatcher { } case "create": { if (path === "/api/v2/media") { - const media = await this.http.post( - path, - action.data, - meta, - ); - return this.waitForMediaAttachment(media.id) as T; + return this.http + .post(path, action.data, meta) + .then((media) => { + return this.waitForMediaAttachment(media.id) as T; + }); } return this.http.post(path, action.data, meta); } @@ -54,7 +53,7 @@ export class HttpActionDispatcher implements ActionDispatcher { return this.http.delete(path, action.data, meta); } case "list": { - return new PaginatorHttp(this.http, path, action.data); + return new PaginatorHttp(this.http, path, action.data) as T; } } } diff --git a/tests/rest/v1/timelines.spec.ts b/tests/rest/v1/timelines.spec.ts index 2860b042..fb973b73 100644 --- a/tests/rest/v1/timelines.spec.ts +++ b/tests/rest/v1/timelines.spec.ts @@ -2,6 +2,17 @@ import { type mastodon } from "../../../src"; import { waitForCondition } from "../../../test-utils/wait-for-condition"; describe("timeline", () => { + it("can iterate over timeline", () => { + return sessions.use(async (client) => { + let statuses: mastodon.v1.Status[] | undefined; + for await (const entry of client.rest.v1.timelines.public.list()) { + statuses = entry; + break; + } + expect(statuses).not.toBeUndefined(); + }); + }); + it("returns home", () => { return sessions.use(async (client) => { const status = await client.rest.v1.statuses.create({