From 81fbbf802e08c8c38f182c4ecbdff873105abe53 Mon Sep 17 00:00:00 2001 From: Roj Serbest Date: Fri, 5 Nov 2021 17:48:08 +0300 Subject: [PATCH] Fix response types of some timeline methods and add `unlike` --- examples/deno/post.ts | 6 ++++++ socialvoid/methods/timeline.ts | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 examples/deno/post.ts diff --git a/examples/deno/post.ts b/examples/deno/post.ts new file mode 100644 index 0000000..9fb4ab3 --- /dev/null +++ b/examples/deno/post.ts @@ -0,0 +1,6 @@ +import { client, login } from "./mod.ts"; + +await login(); + +const a = await client.timeline.retrieveFeed(); +console.log(a); diff --git a/socialvoid/methods/timeline.ts b/socialvoid/methods/timeline.ts index 0ed0f80..01e42d5 100644 --- a/socialvoid/methods/timeline.ts +++ b/socialvoid/methods/timeline.ts @@ -32,7 +32,7 @@ export class Timeline extends MethodBase { * * @param post The ID or instance of the post to be deleted. */ - delete(post: string | Post): Promise { + delete(post: string | Post): Promise { return this.client.invokeRequest( new Request("timeline.delete", { post: typeof post === "string" ? post : post.id, @@ -124,7 +124,7 @@ export class Timeline extends MethodBase { * * @param post The ID or instance of the post to like. */ - like(post: string | Post): Promise { + like(post: string | Post): Promise { return this.client.invokeRequest( new Request("timeline.like", { post: typeof post === "string" ? post : post.id, @@ -133,6 +133,20 @@ export class Timeline extends MethodBase { ); } + /** + * Likes an existing post on the timeline. + * + * @param post The ID or instance of the post to like. + */ + unlike(post: string | Post): Promise { + return this.client.invokeRequest( + new Request("timeline.unlike", { + post: typeof post === "string" ? post : post.id, + }), + true, + ); + } + /** * Returns an array of posts from the users timeline. *