add support to bluesky client forks / bluesky clients that use the same structure as social-app #7

closed
opened by aylac.top targeting main from aylac.top/pdsls: main

it adds a file with a list of some (can easily be extended) bluesky clients. modifies the matching on search so that it treats those the same as bsky.app is treated.

might've gone a bit overboard on the reorganising of the if else chain in there to try to make it try to evaluate as few things as it can, i can tone that back if you want.

Changed files
+30 -13
src
components
utils
+16 -13
src/components/search.tsx
···
import { A, useLocation, useNavigate } from "@solidjs/router";
import { createResource, createSignal, For, onCleanup, onMount, Show } from "solid-js";
import { isTouchDevice } from "../layout";
+
import { BskyClient, bskyClients } from "../utils/bsky-clients";
import { createDebouncedValue } from "../utils/hooks/debounced";
export const [showSearch, setShowSearch] = createSignal(false);
···
setShowSearch(false);
if (input === "me" && localStorage.getItem("lastSignedIn") !== null) {
navigate(`/at://${localStorage.getItem("lastSignedIn")}`);
-
} else if (
-
!input.startsWith("https://bsky.app/") &&
-
(input.startsWith("https://") || input.startsWith("http://"))
-
) {
-
navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`);
} else if (search()?.length) {
navigate(`/at://${search()![0].did}`);
+
} else if (input.startsWith("https://") || input.startsWith("http://")) {
+
const host = input.slice(0, input.indexOf("/profile/", 8)) as BskyClient;
+
if (!bskyClients.has(host)) {
+
navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`);
+
} else {
+
const uri = input
+
.replace("at://", "")
+
.replace(`${host}/profile/`, "")
+
.replace("/post/", "/app.bsky.feed.post/");
+
const uriParts = uri.split("/");
+
navigate(
+
`/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`,
+
);
+
}
} else {
-
const uri = input
-
.replace("at://", "")
-
.replace("https://bsky.app/profile/", "")
-
.replace("/post/", "/app.bsky.feed.post/");
-
const uriParts = uri.split("/");
-
navigate(
-
`/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`,
-
);
+
navigate(`/${input}`);
}
setShowSearch(false);
};
+14
src/utils/bsky-clients.ts
···
+
export type BskyClient = `${"http" | "https"}://${string}`;
+
type BskyClientSet = Set<BskyClient>;
+
+
export const bskyClients: BskyClientSet = new Set<BskyClient>([
+
"http://localhost:19006",
+
"https://blacksky.community",
+
"https://bsky.app",
+
"https://catsky.social",
+
"https://deer.aylac.top",
+
"https://deer-social-ayla.pages.dev",
+
"https://deer.social",
+
"https://main.bsky.dev",
+
"https://social.daniela.lol",
+
]);