tangled
alpha
login
or
join now
robinwobin.dev
/
witchsky.app
forked from
jollywhoppers.com/witchsky.app
0
fork
atom
Bluesky app fork with some witchin' additions 💫
0
fork
atom
overview
issues
pulls
pipelines
fix(pds badge): favicon fetching & dialog link
xan.lol
1 week ago
4f10f44e
719154b3
verified
This commit was signed with the committer's
known signature
.
xan.lol
SSH Key Fingerprint:
SHA256:7Zs+dcly5YqxBg7v8XsE1uPMYCobHKBw7CDiNxpmSrY=
+17
-11
3 changed files
expand all
collapse all
unified
split
src
components
PdsBadge.tsx
PdsDialog.tsx
state
queries
pds-label.ts
+2
-3
src/components/PdsBadge.tsx
···
1
1
import {View} from 'react-native'
2
2
-
import {msg} from '@lingui/macro'
2
2
+
import {msg} from '@lingui/core/macro'
3
3
import {useLingui} from '@lingui/react'
4
4
5
5
import {
···
32
32
)
33
33
34
34
const isBskyHandle =
35
35
-
!!handle &&
36
36
-
(handle.endsWith('.bsky.social') || handle === 'bsky.social')
35
35
+
!!handle && (handle.endsWith('.bsky.social') || handle === 'bsky.social')
37
36
38
37
if (!enabled) return null
39
38
if (isLoading) return <PdsBadgeLoading size={size} isBsky={isBskyHandle} />
+7
-5
src/components/PdsDialog.tsx
···
84
84
{isBridged ? <Trans>Fediverse</Trans> : displayName}
85
85
</Text>
86
86
}
87
87
-
<Text style={[a.text_sm, a.leading_tight]}>
88
88
-
{isBsky && <Trans>Bluesky Social</Trans>}
89
89
-
</Text>
87
87
+
{isBsky &&
88
88
+
<Text style={[a.text_sm, a.leading_tight]}>
89
89
+
<Trans>Bluesky Social</Trans>
90
90
+
</Text>
91
91
+
}
90
92
</View>
91
93
</View>
92
94
···
138
140
</InlineLinkText>{' '}
139
141
about what a PDS is and how to{' '}
140
142
<InlineLinkText
141
141
-
to="https://atproto.com/guides/glossary#pds-personal-data-server"
142
142
-
label="PDS Glossary definition"
143
143
+
to="https://atproto.com/guides/self-hosting#pds"
144
144
+
label="Self-hosting PDS documentation"
143
145
style={[a.text_md, a.font_semi_bold]}>
144
146
self-host
145
147
</InlineLinkText>{' '}
+8
-3
src/state/queries/pds-label.ts
···
55
55
return `${origin}/${href}`
56
56
}
57
57
58
58
-
async function fetchFaviconUrl(pdsUrl: string): Promise<string | undefined> {
58
58
+
async function getFaviconUrl(pdsUrl: string): Promise<string | undefined> {
59
59
let origin = ''
60
60
try {
61
61
origin = new URL(pdsUrl).origin
···
136
136
if (ok) return url
137
137
}
138
138
139
139
-
return undefined
139
139
+
try {
140
140
+
const hostname = new URL(pdsUrl).hostname
141
141
+
return `https://favicon.im/${hostname}?throw-error-on-404=true`
142
142
+
} catch {
143
143
+
return undefined
144
144
+
}
140
145
}
141
146
142
147
export const RQKEY_ROOT = 'pds-label'
···
165
170
queryKey: RQKEY_FAVICON(pdsUrl ?? ''),
166
171
queryFn: async () => {
167
172
if (!pdsUrl) return undefined
168
168
-
return await fetchFaviconUrl(pdsUrl)
173
173
+
return await getFaviconUrl(pdsUrl)
169
174
},
170
175
enabled: !!pdsUrl,
171
176
staleTime: 1000 * 60 * 60, // 1 hour