diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/link-meta/link-meta.ts | 2 | ||||
-rw-r--r-- | src/lib/routes/types.ts | 2 | ||||
-rw-r--r-- | src/lib/strings/handles.ts | 29 | ||||
-rw-r--r-- | src/lib/strings/time.ts | 2 | ||||
-rw-r--r-- | src/lib/themes.ts | 8 |
5 files changed, 36 insertions, 7 deletions
diff --git a/src/lib/link-meta/link-meta.ts b/src/lib/link-meta/link-meta.ts index c7c8d4130..fa951432e 100644 --- a/src/lib/link-meta/link-meta.ts +++ b/src/lib/link-meta/link-meta.ts @@ -26,7 +26,7 @@ export interface LinkMeta { export async function getLinkMeta( agent: BskyAgent, url: string, - timeout = 5e3, + timeout = 15e3, ): Promise<LinkMeta> { if (isBskyAppUrl(url)) { return extractBskyMeta(agent, url) diff --git a/src/lib/routes/types.ts b/src/lib/routes/types.ts index 90ae75830..0fb36fa7c 100644 --- a/src/lib/routes/types.ts +++ b/src/lib/routes/types.ts @@ -30,7 +30,7 @@ export type CommonNavigatorParams = { CopyrightPolicy: undefined AppPasswords: undefined SavedFeeds: undefined - PreferencesHomeFeed: undefined + PreferencesFollowingFeed: undefined PreferencesThreads: undefined PreferencesExternalEmbeds: undefined } diff --git a/src/lib/strings/handles.ts b/src/lib/strings/handles.ts index 6ce462435..a18fef453 100644 --- a/src/lib/strings/handles.ts +++ b/src/lib/strings/handles.ts @@ -1,3 +1,8 @@ +// Regex from the go implementation +// https://github.com/bluesky-social/indigo/blob/main/atproto/syntax/handle.go#L10 +const VALIDATE_REGEX = + /^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/ + export function makeValidHandle(str: string): string { if (str.length > 20) { str = str.slice(0, 20) @@ -19,3 +24,27 @@ export function isInvalidHandle(handle: string): boolean { export function sanitizeHandle(handle: string, prefix = ''): string { return isInvalidHandle(handle) ? 'ā Invalid Handle' : `${prefix}${handle}` } + +export interface IsValidHandle { + handleChars: boolean + frontLength: boolean + totalLength: boolean + overall: boolean +} + +// More checks from https://github.com/bluesky-social/atproto/blob/main/packages/pds/src/handle/index.ts#L72 +export function validateHandle(str: string, userDomain: string): IsValidHandle { + const fullHandle = createFullHandle(str, userDomain) + + const results = { + handleChars: + !str || (VALIDATE_REGEX.test(fullHandle) && !str.includes('.')), + frontLength: str.length >= 3, + totalLength: fullHandle.length <= 253, + } + + return { + ...results, + overall: !Object.values(results).includes(false), + } +} diff --git a/src/lib/strings/time.ts b/src/lib/strings/time.ts index 05a60e94b..3e162af1a 100644 --- a/src/lib/strings/time.ts +++ b/src/lib/strings/time.ts @@ -23,7 +23,7 @@ export function ago(date: number | string | Date): string { } else if (diffSeconds < DAY) { return `${Math.floor(diffSeconds / HOUR)}h` } else if (diffSeconds < MONTH) { - return `${Math.floor(diffSeconds / DAY)}d` + return `${Math.round(diffSeconds / DAY)}d` } else if (diffSeconds < YEAR) { return `${Math.floor(diffSeconds / MONTH)}mo` } else { diff --git a/src/lib/themes.ts b/src/lib/themes.ts index f75ac8ab4..135d50ab6 100644 --- a/src/lib/themes.ts +++ b/src/lib/themes.ts @@ -306,7 +306,7 @@ export const darkTheme: Theme = { // non-standard textVeryLight: darkPalette.contrast_400, - replyLine: darkPalette.contrast_100, + replyLine: darkPalette.contrast_200, replyLineDot: darkPalette.contrast_200, unreadNotifBg: darkPalette.primary_975, unreadNotifBorder: darkPalette.primary_900, @@ -355,10 +355,10 @@ export const dimTheme: Theme = { // non-standard textVeryLight: dimPalette.contrast_400, - replyLine: dimPalette.contrast_100, + replyLine: dimPalette.contrast_200, replyLineDot: dimPalette.contrast_200, - unreadNotifBg: dimPalette.primary_975, - unreadNotifBorder: dimPalette.primary_900, + unreadNotifBg: `hsl(211, 48%, 17%)`, + unreadNotifBorder: `hsl(211, 48%, 30%)`, postCtrl: dimPalette.contrast_500, brandText: dimPalette.primary_500, emptyStateIcon: dimPalette.contrast_300, |