fixes timeline fetch
This commit is contained in:
37
db/main.go
37
db/main.go
@@ -719,24 +719,6 @@ func deleteListShareHandler(client meilisearch.ServiceManager) func(e *core.Reco
|
|||||||
|
|
||||||
func createFollowHandler() func(e *core.RecordRequestEvent) error {
|
func createFollowHandler() func(e *core.RecordRequestEvent) error {
|
||||||
return func(e *core.RecordRequestEvent) error {
|
return func(e *core.RecordRequestEvent) error {
|
||||||
// record := e.Record
|
|
||||||
// if errs := e.App.ExpandRecord(record, []string{"follower"}, nil); len(errs) > 0 {
|
|
||||||
// return fmt.Errorf("failed to expand: %v", errs)
|
|
||||||
// }
|
|
||||||
// follower := record.ExpandedOne("follower")
|
|
||||||
|
|
||||||
// notification := util.Notification{
|
|
||||||
// Type: util.NewFollower,
|
|
||||||
// Metadata: map[string]string{
|
|
||||||
// "follower": follower.GetString("username"),
|
|
||||||
// },
|
|
||||||
// Seen: false,
|
|
||||||
// Author: record.GetString("follower"),
|
|
||||||
// }
|
|
||||||
// err := util.SendNotification(e.App, notification, record.GetString("followee"))
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
e.Next()
|
e.Next()
|
||||||
federation.CreateFollowActivity(e.App, e.Record)
|
federation.CreateFollowActivity(e.App, e.Record)
|
||||||
|
|
||||||
@@ -746,25 +728,6 @@ func createFollowHandler() func(e *core.RecordRequestEvent) error {
|
|||||||
|
|
||||||
func deleteFollowHandler() func(e *core.RecordRequestEvent) error {
|
func deleteFollowHandler() func(e *core.RecordRequestEvent) error {
|
||||||
return func(e *core.RecordRequestEvent) error {
|
return func(e *core.RecordRequestEvent) error {
|
||||||
// record := e.Record
|
|
||||||
// if errs := e.App.ExpandRecord(record, []string{"follower"}, nil); len(errs) > 0 {
|
|
||||||
// return fmt.Errorf("failed to expand: %v", errs)
|
|
||||||
// }
|
|
||||||
// follower := record.ExpandedOne("follower")
|
|
||||||
|
|
||||||
// notification := util.Notification{
|
|
||||||
// Type: util.NewFollower,
|
|
||||||
// Metadata: map[string]string{
|
|
||||||
// "follower": follower.GetString("username"),
|
|
||||||
// },
|
|
||||||
// Seen: false,
|
|
||||||
// Author: record.GetString("follower"),
|
|
||||||
// }
|
|
||||||
// err := util.SendNotification(e.App, notification, record.GetString("followee"))
|
|
||||||
// if err != nil {
|
|
||||||
// return err
|
|
||||||
// }
|
|
||||||
|
|
||||||
federation.CreateUnfollowActivity(e.App, e.Record)
|
federation.CreateUnfollowActivity(e.App, e.Record)
|
||||||
|
|
||||||
return e.Next()
|
return e.Next()
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
|
import type { ListFilter } from "$lib/models/list";
|
||||||
|
import type { SummitLog, SummitLogFilter } from "$lib/models/summit_log";
|
||||||
import type { TimelineItem } from "$lib/models/timeline";
|
import type { TimelineItem } from "$lib/models/timeline";
|
||||||
import { defaultTrailSearchAttributes, Trail, type TrailFilter, type TrailSearchResult } from "$lib/models/trail";
|
import { defaultTrailSearchAttributes, Trail, type TrailFilter, type TrailSearchResult } from "$lib/models/trail";
|
||||||
import { APIError } from "$lib/util/api_util";
|
import { APIError } from "$lib/util/api_util";
|
||||||
import type { Hits } from "meilisearch";
|
import type { Hits } from "meilisearch";
|
||||||
import type { ListResult } from "pocketbase";
|
import type { ListResult } from "pocketbase";
|
||||||
import { searchResultToTrailList } from "./trail_store";
|
|
||||||
import type { SummitLog, SummitLogFilter } from "$lib/models/summit_log";
|
|
||||||
import { buildFilterText } from "./summit_log_store";
|
|
||||||
import type { ListFilter } from "$lib/models/list";
|
|
||||||
import type { ListSearchResult } from "./search_store";
|
|
||||||
import { searchResultToLists } from "./list_store";
|
import { searchResultToLists } from "./list_store";
|
||||||
|
import type { ListSearchResult } from "./search_store";
|
||||||
|
import { buildFilterText } from "./summit_log_store";
|
||||||
|
import { searchResultToTrailList } from "./trail_store";
|
||||||
|
|
||||||
let timeline: TimelineItem[] = []
|
let timeline: TimelineItem[] = []
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ export async function profile_lists_index(handle: string, filter: ListFilter, pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
export async function profile_timeline_index(handle: string, page: number, perPage: number = 1, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
export async function profile_timeline_index(handle: string, page: number, perPage: number = 10, f: (url: RequestInfo | URL, config?: RequestInit) => Promise<Response> = fetch) {
|
||||||
let r = await f(`/api/v1/profile/${handle}/timeline?` + new URLSearchParams({
|
let r = await f(`/api/v1/profile/${handle}/timeline?` + new URLSearchParams({
|
||||||
page: page.toString(),
|
page: page.toString(),
|
||||||
perPage: perPage.toString(),
|
perPage: perPage.toString(),
|
||||||
|
|||||||
@@ -13,13 +13,13 @@
|
|||||||
|
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
|
|
||||||
let timeline = $derived(data.timeline);
|
let timeline = $state(data.timeline);
|
||||||
|
|
||||||
let loading: boolean = false;
|
let loading: boolean = false;
|
||||||
|
|
||||||
let pagination = $derived({
|
let pagination = $derived({
|
||||||
page: 1,
|
page: timeline.page,
|
||||||
totalPages: data.timeline.totalItems,
|
totalPages: timeline.totalItems,
|
||||||
});
|
});
|
||||||
|
|
||||||
async function onListScroll(e: Event) {
|
async function onListScroll(e: Event) {
|
||||||
@@ -37,17 +37,14 @@
|
|||||||
|
|
||||||
async function loadNextPage() {
|
async function loadNextPage() {
|
||||||
pagination.page += 1;
|
pagination.page += 1;
|
||||||
data.timeline = await profile_timeline_index(
|
timeline = await profile_timeline_index(
|
||||||
data.actor.iri,
|
page.params.handle,
|
||||||
pagination.page,
|
pagination.page,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleTimeLineItemClick(item: TimelineItem) {
|
function handleTimeLineItemClick(item: TimelineItem) {
|
||||||
if (item.trail_iri.length) {
|
if (item.trail_iri.length) {
|
||||||
const originalTrailId = item.trail_iri.substring(
|
|
||||||
item.trail_iri.length - 15,
|
|
||||||
);
|
|
||||||
goto(
|
goto(
|
||||||
`/trail/view/@${item.trail_author_username}@${item.trail_author_domain}/${item.trail_id}`,
|
`/trail/view/@${item.trail_author_username}@${item.trail_author_domain}/${item.trail_id}`,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
|
|
||||||
<svelte:window onscroll={onListScroll} />
|
<svelte:window onscroll={onListScroll} />
|
||||||
|
|
||||||
<div>
|
<div style="min-height: 70vh">
|
||||||
<h1 class="text-3xl font-semibold mb-4">{$_(page.params.type)}</h1>
|
<h1 class="text-3xl font-semibold mb-4">{$_(page.params.type)}</h1>
|
||||||
<ul class="space-y-4">
|
<ul class="space-y-4">
|
||||||
{#each follows.items as follow}
|
{#each follows.items as follow}
|
||||||
|
|||||||
Reference in New Issue
Block a user