grain.social is a photo sharing platform built on atproto. grain.social
atproto photography appview
47
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 47 lines 1.8 kB view raw
1import { callXrpc } from "$hatk/client"; 2import type { QueryClient } from "@tanstack/svelte-query"; 3import { get } from "svelte/store"; 4import { viewer as viewerStore } from "$lib/stores"; 5 6function invalidateFeedsAndProfile(did: string, queryClient: QueryClient) { 7 queryClient.invalidateQueries({ queryKey: ["actorProfile", did] }); 8 queryClient.invalidateQueries({ queryKey: ["getFeed"] }); 9 queryClient.invalidateQueries({ queryKey: ["storyAuthors"] }); 10 queryClient.invalidateQueries({ queryKey: ["notifications"] }); 11} 12 13export async function blockActor(did: string, queryClient: QueryClient) { 14 if (get(viewerStore)?.did === did) return; 15 await callXrpc("dev.hatk.createRecord", { 16 collection: "social.grain.graph.block", 17 record: { subject: did, createdAt: new Date().toISOString() }, 18 }); 19 invalidateFeedsAndProfile(did, queryClient); 20 queryClient.invalidateQueries({ queryKey: ["blocks"] }); 21} 22 23export async function unblockActor( 24 did: string, 25 blockUri: string, 26 queryClient: QueryClient, 27) { 28 const rkey = blockUri.split("/").pop()!; 29 await callXrpc("dev.hatk.deleteRecord", { 30 collection: "social.grain.graph.block", 31 rkey, 32 }); 33 invalidateFeedsAndProfile(did, queryClient); 34 queryClient.invalidateQueries({ queryKey: ["blocks"] }); 35} 36 37export async function muteActor(did: string, queryClient: QueryClient) { 38 await callXrpc("social.grain.graph.muteActor", { actor: did }); 39 invalidateFeedsAndProfile(did, queryClient); 40 queryClient.invalidateQueries({ queryKey: ["mutes"] }); 41} 42 43export async function unmuteActor(did: string, queryClient: QueryClient) { 44 await callXrpc("social.grain.graph.unmuteActor", { actor: did }); 45 invalidateFeedsAndProfile(did, queryClient); 46 queryClient.invalidateQueries({ queryKey: ["mutes"] }); 47}