BlueSky & more on desktop lazurite.stormlightlabs.org/
tauri rust typescript bluesky appview atproto solid
2
fork

Configure Feed

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

at main 85 lines 2.3 kB view raw
1import { getFeedCommand, parseFeedGeneratorsResponse, parseFeedResponse, parseThreadResponse } from "$/lib/feeds"; 2import type { 3 CreateRecordResult, 4 EmbedInput, 5 FeedViewPrefItem, 6 ReplyRefInput, 7 SavedFeedItem, 8 UserPreferences, 9} from "$/lib/types"; 10import { invoke } from "@tauri-apps/api/core"; 11import * as logger from "@tauri-apps/plugin-log"; 12 13function getPreferences() { 14 return invoke<UserPreferences>("get_preferences"); 15} 16 17async function getFeedGenerators(uris: string[]) { 18 try { 19 return parseFeedGeneratorsResponse(await invoke("get_feed_generators", { uris })); 20 } catch (error) { 21 logger.warn(`getFeedGenerators failed; continuing without hydrated metadata: ${String(error)}`); 22 return { feeds: [] }; 23 } 24} 25 26async function getFeedPage(feed: SavedFeedItem, cursor: string | null, limit: number) { 27 const command = getFeedCommand(feed); 28 return parseFeedResponse(await invoke(command.name, command.args(cursor, limit))); 29} 30 31async function getPostThread(uri: string) { 32 return parseThreadResponse(await invoke("get_post_thread", { uri })); 33} 34 35function createPost(text: string, replyTo: ReplyRefInput | null, embed: EmbedInput | null) { 36 return invoke<CreateRecordResult>("create_post", { embed, replyTo, text }); 37} 38 39function likePost(uri: string, cid: string) { 40 return invoke<CreateRecordResult>("like_post", { cid, uri }); 41} 42 43function unlikePost(likeUri: string) { 44 return invoke("unlike_post", { likeUri }); 45} 46 47function repost(uri: string, cid: string) { 48 return invoke<CreateRecordResult>("repost", { cid, uri }); 49} 50 51function unrepost(repostUri: string) { 52 return invoke("unrepost", { repostUri }); 53} 54 55function bookmarkPost(uri: string, cid: string) { 56 return invoke("bookmark_post", { cid, uri }); 57} 58 59function removeBookmark(uri: string) { 60 return invoke("remove_bookmark", { uri }); 61} 62 63function updateSavedFeeds(feeds: SavedFeedItem[]) { 64 return invoke("update_saved_feeds", { feeds }); 65} 66 67function updateFeedViewPref(pref: FeedViewPrefItem) { 68 return invoke("update_feed_view_pref", { pref }); 69} 70 71export const FeedController = { 72 getPreferences, 73 getFeedGenerators, 74 getFeedPage, 75 getPostThread, 76 createPost, 77 likePost, 78 unlikePost, 79 repost, 80 unrepost, 81 bookmarkPost, 82 removeBookmark, 83 updateSavedFeeds, 84 updateFeedViewPref, 85};