-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show labeler info in labels and adjust color coding (#61)
* 💄 Handle reviewNone, labeler account display and sticky note more prominent * 🐛 Change icon for reviewNone * 💄 Handle user badge in dark mode * 💄 Show labels with mod service details * 💄 Color code labels based on blur and hide config * 💄 Add ModerationLabel in record and repo view * ✨ Cleanup * 🧹 Cleanup
- Loading branch information
Showing
15 changed files
with
395 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import clientManager from '@/lib/client' | ||
import { AppBskyLabelerDefs, ComAtprotoLabelDefs } from '@atproto/api' | ||
import { useQuery } from '@tanstack/react-query' | ||
import { ExtendedLabelerServiceDef } from './util' | ||
|
||
export const useLabelerServiceDef = (did: string) => { | ||
const { data: labelerDef } = useQuery({ | ||
queryKey: ['labelerDef', { did }], | ||
queryFn: async () => { | ||
const { data } = await clientManager.api.app.bsky.labeler.getServices({ | ||
dids: [did], | ||
detailed: true, | ||
}) | ||
if (!data.views?.[0]) { | ||
return null | ||
} | ||
|
||
const labelerDef = data.views[0] as ExtendedLabelerServiceDef | ||
if (labelerDef?.policies.labelValueDefinitions) { | ||
const definitionsById: Record< | ||
string, | ||
ComAtprotoLabelDefs.LabelValueDefinition | ||
> = {} | ||
labelerDef.policies.labelValueDefinitions.forEach((def) => { | ||
definitionsById[def.identifier] = def | ||
}) | ||
labelerDef.policies.definitionById = definitionsById | ||
} | ||
|
||
return labelerDef | ||
}, | ||
// These are not super likely to change frequently but labels will be rendered quite a lot | ||
// so caching them for longer period is ideal | ||
staleTime: 60 * 60 * 1000, | ||
cacheTime: 60 * 60 * 1000, | ||
}) | ||
|
||
return labelerDef || null | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.