fix(frontend): tag remaining GET fetches for cache invalidation
This commit is contained in:
@@ -215,7 +215,7 @@ export const updateProfile = (data: z.infer<typeof UpdateProfileSchema>, token:
|
||||
apiFetch("/users/me", { method: "PATCH", body: JSON.stringify(data) }, UserSchema, token);
|
||||
|
||||
export const getMeFollowingList = (token: string) =>
|
||||
apiFetch("/users/me/following", {}, z.object({ total: z.number(), items: z.array(UserSchema) }), token);
|
||||
apiFetch("/users/me/following", { next: { tags: ['me'] } }, z.object({ total: z.number(), items: z.array(UserSchema) }), token);
|
||||
|
||||
// ── Users ─────────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -261,7 +261,7 @@ export const markAllNotificationsRead = (token: string) =>
|
||||
export const lookupRemoteActor = (handle: string, token: string | null) =>
|
||||
apiFetch(
|
||||
`/users/lookup?handle=${encodeURIComponent(handle)}`,
|
||||
{},
|
||||
{ next: { tags: [`remote-actor:${handle}`] } },
|
||||
RemoteActorSchema,
|
||||
token
|
||||
);
|
||||
@@ -273,7 +273,7 @@ export const getRemoteActorPosts = (
|
||||
) =>
|
||||
apiFetch(
|
||||
`/federation/actors/${encodeURIComponent(handle)}/posts?page=${page}&per_page=20`,
|
||||
{},
|
||||
{ next: { tags: [`remote-actor:${handle}`] } },
|
||||
z.object({
|
||||
total: z.number(),
|
||||
page: z.number(),
|
||||
@@ -304,7 +304,7 @@ export const getActorFollowers = (
|
||||
) =>
|
||||
apiFetch(
|
||||
`/federation/actors/${encodeURIComponent(handle)}/followers-list?page=${page}`,
|
||||
{},
|
||||
{ next: { tags: [`remote-actor:${handle}`] } },
|
||||
ActorConnectionPageSchema,
|
||||
token
|
||||
);
|
||||
@@ -316,7 +316,7 @@ export const getActorFollowing = (
|
||||
) =>
|
||||
apiFetch(
|
||||
`/federation/actors/${encodeURIComponent(handle)}/following-list?page=${page}`,
|
||||
{},
|
||||
{ next: { tags: [`remote-actor:${handle}`] } },
|
||||
ActorConnectionPageSchema,
|
||||
token
|
||||
);
|
||||
@@ -324,13 +324,13 @@ export const getActorFollowing = (
|
||||
export const getAllUsers = (page: number = 1, pageSize: number = 20) =>
|
||||
apiFetch(
|
||||
`/users?page=${page}&per_page=${pageSize}`,
|
||||
{},
|
||||
{ next: { tags: ['users'] } },
|
||||
z.object({ items: z.array(UserSchema), total: z.number(), page: z.number(), per_page: z.number() })
|
||||
.transform((d) => ({ ...d, totalPages: Math.ceil(d.total / d.per_page) }))
|
||||
);
|
||||
|
||||
export const getAllUsersCount = () =>
|
||||
apiFetch("/users/count", {}, z.object({ count: z.number() }));
|
||||
apiFetch("/users/count", { next: { tags: ['users'] } }, z.object({ count: z.number() }));
|
||||
|
||||
// ── Thoughts ──────────────────────────────────────────────────────────────
|
||||
|
||||
@@ -361,7 +361,7 @@ export const getThoughtById = (thoughtId: string, token: string | null) =>
|
||||
apiFetch(`/thoughts/${thoughtId}`, { next: { tags: [`thought:${thoughtId}`] } }, ThoughtSchema, token);
|
||||
|
||||
export const getThoughtThread = async (thoughtId: string, token: string | null): Promise<ThoughtThread> => {
|
||||
const thoughts = await apiFetch(`/thoughts/${thoughtId}/thread`, {}, z.array(ThoughtSchema), token);
|
||||
const thoughts = await apiFetch(`/thoughts/${thoughtId}/thread`, { next: { tags: [`thought:${thoughtId}`] } }, z.array(ThoughtSchema), token);
|
||||
type T = z.infer<typeof ThoughtSchema>;
|
||||
const repliesMap: Record<string, T[]> = {};
|
||||
for (const t of thoughts) {
|
||||
@@ -390,7 +390,7 @@ export const getThoughtsByTag = (tagName: string, token: string | null) =>
|
||||
export const getPopularTags = () =>
|
||||
apiFetch(
|
||||
"/tags/popular",
|
||||
{},
|
||||
{ next: { tags: ['tags:popular'] } },
|
||||
z.object({ tags: z.array(z.object({ name: z.string(), thought_count: z.number() })) })
|
||||
.transform((d) => d.tags.map((t) => t.name))
|
||||
);
|
||||
@@ -403,7 +403,7 @@ export const search = (query: string, token: string | null) =>
|
||||
// ── API Keys ──────────────────────────────────────────────────────────────
|
||||
|
||||
export const getApiKeys = (token: string) =>
|
||||
apiFetch("/api-keys", {}, z.object({ keys: z.array(ApiKeySchema) }), token);
|
||||
apiFetch("/api-keys", { next: { tags: ['api-keys'] } }, z.object({ keys: z.array(ApiKeySchema) }), token);
|
||||
|
||||
export const createApiKey = (data: z.infer<typeof CreateApiKeySchema>, token: string) =>
|
||||
apiFetch("/api-keys", { method: "POST", body: JSON.stringify(data) }, ApiKeyResponseSchema, token);
|
||||
@@ -421,7 +421,7 @@ export const getFriends = (token: string) =>
|
||||
export const getPendingFollowRequests = (token: string) =>
|
||||
apiFetch(
|
||||
"/federation/me/followers/pending",
|
||||
{},
|
||||
{ next: { tags: ['federation:pending'] } },
|
||||
z.array(RemoteActorSchema),
|
||||
token
|
||||
);
|
||||
@@ -445,7 +445,7 @@ export const rejectFollowRequest = (actorUrl: string, token: string) =>
|
||||
export const getRemoteFollowers = (token: string) =>
|
||||
apiFetch(
|
||||
"/federation/me/followers",
|
||||
{},
|
||||
{ next: { tags: ['federation:followers'] } },
|
||||
z.array(RemoteActorSchema),
|
||||
token
|
||||
);
|
||||
@@ -453,7 +453,7 @@ export const getRemoteFollowers = (token: string) =>
|
||||
export const getRemoteFollowing = (token: string) =>
|
||||
apiFetch(
|
||||
"/federation/me/following",
|
||||
{},
|
||||
{ next: { tags: ['federation:following'] } },
|
||||
z.array(RemoteActorSchema),
|
||||
token
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user