···11+import { AppBskyActorDefs } from "@atproto/api";
22+33+/**
44+ * formats a user's handle for display, falling back to DID if handle is invalid
55+ */
66+export function formatHandle(
77+ profile: Pick<AppBskyActorDefs.ProfileViewBasic, "handle" | "did">,
88+): string {
99+ if (profile.handle === "handle.invalid") {
1010+ return profile.did;
1111+ }
1212+ return profile.handle;
1313+}
1414+1515+/**
1616+ * formats a user's handle with @ prefix for display, falling back to DID if handle is invalid
1717+ */
1818+export function formatHandleWithAt(
1919+ profile: Pick<AppBskyActorDefs.ProfileViewBasic, "handle" | "did">,
2020+): string {
2121+ return `@${formatHandle(profile)}`;
2222+}