Refactor regex handling and improve null checks across various components
Updated regex patterns in episode parsing and metadata handling to use String.raw for better readability and maintainability. Enhanced null checks in BlockBuilder, MediaPanel, and ShowMetadataCard components to prevent potential runtime errors. Consolidated imports in UsersPanel for cleaner code structure.
This commit is contained in:
@@ -25,25 +25,23 @@ type RequestOptions = {
|
||||
}
|
||||
|
||||
export async function refreshAccessToken(): Promise<boolean> {
|
||||
if (!refreshInFlight) {
|
||||
refreshInFlight = (async () => {
|
||||
try {
|
||||
const response = await fetch('/api/auth/refresh', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
})
|
||||
if (!response.ok) return false
|
||||
const data = (await response.json()) as { accessToken?: unknown }
|
||||
if (typeof data?.accessToken !== 'string') return false
|
||||
setAccessToken(data.accessToken)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
} finally {
|
||||
refreshInFlight = null
|
||||
}
|
||||
})()
|
||||
}
|
||||
refreshInFlight ??= (async () => {
|
||||
try {
|
||||
const response = await fetch('/api/auth/refresh', {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
})
|
||||
if (!response.ok) return false
|
||||
const data = (await response.json()) as { accessToken?: unknown }
|
||||
if (typeof data?.accessToken !== 'string') return false
|
||||
setAccessToken(data.accessToken)
|
||||
return true
|
||||
} catch {
|
||||
return false
|
||||
} finally {
|
||||
refreshInFlight = null
|
||||
}
|
||||
})()
|
||||
return refreshInFlight
|
||||
}
|
||||
|
||||
|
||||
@@ -237,8 +237,7 @@ export const en = {
|
||||
toShowAuto: 'auto',
|
||||
toShowRegex: 'Episode regex',
|
||||
toShowRegexInvalid: 'invalid regex',
|
||||
toShowHint:
|
||||
'Season and regex are optional: numbers are usually detected automatically (see below). Regex: 1 group = episode, 2 groups = season and episode. Example: ^(\\d+) for “01. Title.mkv”.',
|
||||
toShowHint: String.raw`Season and regex are optional: numbers are usually detected automatically (see below). Regex: 1 group = episode, 2 groups = season and episode. Example: ^(\d+) for “01. Title.mkv”.`,
|
||||
toShowPreview: 'What we detect',
|
||||
toShowMatched: 'show detected for {{matched}} of {{total}}',
|
||||
applyToAll: 'Set for all…',
|
||||
|
||||
@@ -238,8 +238,7 @@ export const ru = {
|
||||
toShowAuto: 'авто',
|
||||
toShowRegex: 'Regex серии',
|
||||
toShowRegexInvalid: 'некорректный regex',
|
||||
toShowHint:
|
||||
'Сезон и regex — необязательны: обычно номера распознаются сами (см. ниже). Regex: 1 группа = серия, 2 группы = сезон и серия. Пример: ^(\\d+) для «01. Название.mkv».',
|
||||
toShowHint: String.raw`Сезон и regex — необязательны: обычно номера распознаются сами (см. ниже). Regex: 1 группа = серия, 2 группы = сезон и серия. Пример: ^(\d+) для «01. Название.mkv».`,
|
||||
toShowPreview: 'Что распознаем',
|
||||
toShowMatched: 'шоу распознано у {{matched}} из {{total}}',
|
||||
applyToAll: 'Задать всем…',
|
||||
|
||||
Reference in New Issue
Block a user