feat: partial favourites
This commit is contained in:
parent
c51a0b1e5d
commit
99def58c8b
3 changed files with 81 additions and 8 deletions
|
@ -242,6 +242,8 @@ export async function rejectFollowRequest(host, token, account_id) {
|
|||
* @param {string} token - The application token.
|
||||
* @param {string} timeline - The name of the timeline to pull (default "home").
|
||||
* @param {string} max_id - If provided, only shows posts after this ID.
|
||||
* @param {boolean} local_only - If provided, only shows posts from the local instance
|
||||
* @param {boolean} remote_only - If provided, only shows posts from other instances
|
||||
*/
|
||||
export async function getTimeline(host, token, timeline, max_id, local_only, remote_only) {
|
||||
let url = `https://${host}/api/v1/timelines/${timeline || "home"}`;
|
||||
|
@ -558,3 +560,25 @@ export async function getUserPinnedPosts(host, token, user_id) {
|
|||
|
||||
return data;
|
||||
}
|
||||
|
||||
/**
|
||||
* GET /api/v1/favourites
|
||||
* @param {string} host - The domain of the target server.
|
||||
* @param {string} token - The application token.
|
||||
* @param {string} max_id - If provided, only shows posts after this ID.
|
||||
*/
|
||||
export async function getFavourites(host, token, timeline, max_id) {
|
||||
let url = `https://${host}/api/v1/favourites`;
|
||||
|
||||
let params = new URLSearchParams();
|
||||
if (max_id) params.append("max_id", max_id);
|
||||
const params_string = params.toString();
|
||||
if (params_string) url += '?' + params_string;
|
||||
|
||||
const data = await fetch(url, {
|
||||
method: 'GET',
|
||||
headers: { "Authorization": token ? `Bearer ${token}` : null }
|
||||
}).then(res => res.json());
|
||||
|
||||
return data;
|
||||
}
|
||||
|
|
|
@ -19,14 +19,27 @@ export async function getTimeline(timelineType = "home", clean, localOnly = fals
|
|||
if (!clean && get(timeline).length > 0)
|
||||
last_post = get(timeline)[get(timeline).length - 1].id;
|
||||
|
||||
const timeline_data = await api.getTimeline(
|
||||
get(server).host,
|
||||
get(app).token,
|
||||
timelineType,
|
||||
last_post,
|
||||
localOnly,
|
||||
remoteOnly
|
||||
);
|
||||
let timeline_data;
|
||||
switch(timelineType) {
|
||||
case "favourites":
|
||||
timeline_data = await api.getFavourites(
|
||||
get(server).host,
|
||||
get(app).token,
|
||||
last_post,
|
||||
)
|
||||
break;
|
||||
|
||||
default:
|
||||
timeline_data = await api.getTimeline(
|
||||
get(server).host,
|
||||
get(app).token,
|
||||
timelineType,
|
||||
last_post,
|
||||
localOnly,
|
||||
remoteOnly
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!timeline_data) {
|
||||
console.error(lang.string('logs.timeline_fetch_failed'));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue