feat: ship Wave 5-6 multi-surface hygiene, optimization, and bug fixes
This commit is contained in:
parent
01ef3293cf
commit
66b6b45ba9
399 changed files with 17828 additions and 11330 deletions
|
|
@ -24,6 +24,7 @@ import {
|
|||
d3roNativeFonts,
|
||||
} from '@d3ro/ui-native'
|
||||
import { useI18n } from '@d3ro/i18n'
|
||||
import { LOCALE_META } from '@d3ro/i18n/shared'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { supabase } from '../lib/supabase'
|
||||
import { performAccountLogout } from '../lib/account-exit'
|
||||
|
|
@ -107,11 +108,24 @@ export default function AccountScreen({
|
|||
const [authCapabilities, setAuthCapabilities] = useState<AuthCapabilities | null>(null)
|
||||
const identityAccountRef = useRef<string | null>(null)
|
||||
const identityRequestRef = useRef(0)
|
||||
const profileRequestRef = useRef(0)
|
||||
const mountedRef = useRef(true)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
profileRequestRef.current += 1
|
||||
identityRequestRef.current += 1
|
||||
}
|
||||
}, [])
|
||||
|
||||
const providers = useMemo(() => user ? collectProviders(user) : [], [user])
|
||||
|
||||
const loadProfile = useCallback(async (): Promise<void> => {
|
||||
const request = ++profileRequestRef.current
|
||||
if (!user) {
|
||||
if (!mountedRef.current) return
|
||||
setProfile(null)
|
||||
setLoadingProfile(false)
|
||||
return
|
||||
|
|
@ -128,6 +142,7 @@ export default function AccountScreen({
|
|||
.eq('id', user.id)
|
||||
.single()
|
||||
|
||||
if (!mountedRef.current || profileRequestRef.current !== request) return
|
||||
if (error) throw error
|
||||
if (!data) throw new Error(t('mobile.account.profileMissing'))
|
||||
|
||||
|
|
@ -138,10 +153,13 @@ export default function AccountScreen({
|
|||
setProfileLocale(loadedProfile.locale || 'ko')
|
||||
setAvatarFailed(false)
|
||||
} catch (error) {
|
||||
if (!mountedRef.current || profileRequestRef.current !== request) return
|
||||
setProfile(null)
|
||||
setErrorMessage(error instanceof Error ? error.message : String(error))
|
||||
} finally {
|
||||
setLoadingProfile(false)
|
||||
if (mountedRef.current && profileRequestRef.current === request) {
|
||||
setLoadingProfile(false)
|
||||
}
|
||||
}
|
||||
}, [t, user])
|
||||
|
||||
|
|
@ -193,7 +211,7 @@ export default function AccountScreen({
|
|||
}, [refreshIdentities, user])
|
||||
|
||||
const isCurrentIdentityAccount = useCallback((expectedUserId: string): boolean => (
|
||||
identityAccountRef.current === expectedUserId
|
||||
mountedRef.current && identityAccountRef.current === expectedUserId
|
||||
), [])
|
||||
|
||||
async function linkIdentity(provider: ManagedOAuthProvider): Promise<void> {
|
||||
|
|
@ -294,6 +312,8 @@ export default function AccountScreen({
|
|||
|
||||
async function saveProfile(): Promise<void> {
|
||||
if (!user || !profile || activeAction) return
|
||||
const expectedUserId = user.id
|
||||
const request = ++profileRequestRef.current
|
||||
|
||||
const normalizedName = name.trim()
|
||||
const normalizedAvatarUrl = avatarUrl.trim()
|
||||
|
|
@ -330,10 +350,17 @@ export default function AccountScreen({
|
|||
avatar_url: normalizedAvatarUrl || null,
|
||||
locale: profileLocale,
|
||||
})
|
||||
.eq('id', user.id)
|
||||
.eq('id', expectedUserId)
|
||||
.select(PROFILE_COLUMNS)
|
||||
.single()
|
||||
|
||||
if (
|
||||
!mountedRef.current
|
||||
|| identityAccountRef.current !== expectedUserId
|
||||
|| profileRequestRef.current !== request
|
||||
) {
|
||||
return
|
||||
}
|
||||
if (error) throw error
|
||||
if (!data) throw new Error(t('mobile.account.profileUpdateMissing'))
|
||||
|
||||
|
|
@ -344,6 +371,13 @@ export default function AccountScreen({
|
|||
setProfileLocale(savedProfile.locale || 'ko')
|
||||
setSuccessMessage(t('mobile.account.profileSaved'))
|
||||
} catch (error) {
|
||||
if (
|
||||
!mountedRef.current
|
||||
|| identityAccountRef.current !== expectedUserId
|
||||
|| profileRequestRef.current !== request
|
||||
) {
|
||||
return
|
||||
}
|
||||
// Roll every optimistic field back to the last server-confirmed row.
|
||||
setProfile(previous)
|
||||
setName(previous.name ?? '')
|
||||
|
|
@ -351,7 +385,7 @@ export default function AccountScreen({
|
|||
setProfileLocale(previous.locale || 'ko')
|
||||
setErrorMessage(error instanceof Error ? error.message : String(error))
|
||||
} finally {
|
||||
setActiveAction(null)
|
||||
if (mountedRef.current) setActiveAction(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -368,11 +402,12 @@ export default function AccountScreen({
|
|||
purgeLocalSession,
|
||||
})
|
||||
} catch {
|
||||
if (!mountedRef.current) return
|
||||
const message = t('mobile.auth.logoutFailed')
|
||||
setErrorMessage(message)
|
||||
Alert.alert(t('mobile.auth.errorTitle'), message)
|
||||
} finally {
|
||||
setActiveAction(null)
|
||||
if (mountedRef.current) setActiveAction(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -406,6 +441,7 @@ export default function AccountScreen({
|
|||
},
|
||||
purgeLocalSession,
|
||||
})
|
||||
if (!mountedRef.current) return
|
||||
if (!result.ok) {
|
||||
const message = t(accountDeletionFailureMessageKey(result.code))
|
||||
setErrorMessage(message)
|
||||
|
|
@ -413,11 +449,12 @@ export default function AccountScreen({
|
|||
return
|
||||
}
|
||||
} catch {
|
||||
if (!mountedRef.current) return
|
||||
const message = t('mobile.auth.localDataCleanupBody')
|
||||
setErrorMessage(message)
|
||||
Alert.alert(t('mobile.auth.errorTitle'), message)
|
||||
} finally {
|
||||
setActiveAction(null)
|
||||
if (mountedRef.current) setActiveAction(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -535,28 +572,24 @@ export default function AccountScreen({
|
|||
{t('mobile.account.locale')}
|
||||
</PhosphorText>
|
||||
<View style={styles.localeRow}>
|
||||
{(['ko', 'en'] as const).map((candidate) => (
|
||||
{LOCALE_META.map((item) => (
|
||||
<Pressable
|
||||
key={candidate}
|
||||
key={item.code}
|
||||
accessibilityRole="radio"
|
||||
accessibilityLabel={candidate === 'ko'
|
||||
? t('mobile.account.languageKorean')
|
||||
: t('mobile.account.languageEnglish')}
|
||||
accessibilityState={{ selected: profileLocale === candidate }}
|
||||
accessibilityLabel={item.nativeName}
|
||||
accessibilityState={{ selected: profileLocale === item.code }}
|
||||
style={[
|
||||
styles.localeButton,
|
||||
profileLocale === candidate && styles.localeButtonActive,
|
||||
profileLocale === item.code && styles.localeButtonActive,
|
||||
]}
|
||||
onPress={() => setProfileLocale(candidate)}
|
||||
onPress={() => setProfileLocale(item.code)}
|
||||
disabled={Boolean(activeAction)}
|
||||
>
|
||||
<PhosphorText
|
||||
variant="small"
|
||||
color={profileLocale === candidate ? 'amber' : 'muted'}
|
||||
color={profileLocale === item.code ? 'amber' : 'muted'}
|
||||
>
|
||||
{candidate === 'ko'
|
||||
? t('mobile.account.languageKorean')
|
||||
: t('mobile.account.languageEnglish')}
|
||||
{item.nativeName}
|
||||
</PhosphorText>
|
||||
</Pressable>
|
||||
))}
|
||||
|
|
@ -994,15 +1027,17 @@ function createStyles(palette: Palette) {
|
|||
paddingHorizontal: 13,
|
||||
paddingVertical: 12,
|
||||
},
|
||||
localeRow: { flexDirection: 'row', gap: 9 },
|
||||
localeRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 9 },
|
||||
localeButton: {
|
||||
flex: 1,
|
||||
minWidth: '30%',
|
||||
flexGrow: 1,
|
||||
minHeight: 48,
|
||||
alignItems: 'center',
|
||||
borderRadius: 8,
|
||||
borderWidth: 1,
|
||||
borderColor: palette.border.default,
|
||||
backgroundColor: palette.bg.inset,
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 11,
|
||||
},
|
||||
localeButtonActive: { borderColor: palette.accent.main, backgroundColor: palette.accent.dim },
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import { useFocusEffect, useNavigation } from '@react-navigation/native'
|
|||
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { useResponsiveLayout } from '@d3ro/ui-native'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
import { supabase } from '../lib/supabase'
|
||||
|
|
@ -93,6 +94,7 @@ export default function CommandsScreen(): React.ReactElement {
|
|||
const { t } = useI18n()
|
||||
const { user, session } = useAuth()
|
||||
const { palette, preferences } = useMobilePreferences()
|
||||
const { contentMaxWidth, isLargeScreen, wideContentMaxWidth } = useResponsiveLayout()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const alive = useRef(true)
|
||||
const request = useRef<AbortController | null>(null)
|
||||
|
|
@ -309,7 +311,7 @@ export default function CommandsScreen(): React.ReactElement {
|
|||
<ScrollView
|
||||
contentContainerStyle={[
|
||||
styles.content,
|
||||
{ paddingTop: insets.top + 10, paddingBottom: Math.max(insets.bottom, 24) },
|
||||
{ maxWidth: wideContentMaxWidth, paddingTop: insets.top + 10, paddingBottom: Math.max(insets.bottom, 24) },
|
||||
]}
|
||||
refreshControl={(
|
||||
<RefreshControl
|
||||
|
|
@ -361,7 +363,7 @@ export default function CommandsScreen(): React.ReactElement {
|
|||
<ThemeText color="muted">{t('mobile.commands.loading')}</ThemeText>
|
||||
</View>
|
||||
) : (
|
||||
<View style={styles.list}>
|
||||
<View style={[styles.list, isLargeScreen && styles.listGrid]}>
|
||||
{commands.map((command) => {
|
||||
const selectedNow = selected?.id === command.id
|
||||
const active = activeId === command.id
|
||||
|
|
@ -369,7 +371,12 @@ export default function CommandsScreen(): React.ReactElement {
|
|||
return (
|
||||
<ThemeCard
|
||||
key={command.id}
|
||||
style={[styles.card, selectedNow && styles.selected, active && styles.active]}
|
||||
style={[
|
||||
styles.card,
|
||||
isLargeScreen && styles.cardGridItem,
|
||||
selectedNow && styles.selected,
|
||||
active && styles.active,
|
||||
]}
|
||||
testID={'commands-item-' + command.id}
|
||||
>
|
||||
<Pressable
|
||||
|
|
@ -415,7 +422,7 @@ export default function CommandsScreen(): React.ReactElement {
|
|||
<ThemeText variant="label" color="muted" style={styles.sectionLabel}>
|
||||
{t('mobile.commands.testBench')}
|
||||
</ThemeText>
|
||||
<ThemeCard style={styles.bench}>
|
||||
<ThemeCard style={[styles.bench, { maxWidth: contentMaxWidth }]}>
|
||||
<ThemeText variant="small" color="muted">
|
||||
{selected
|
||||
? t('mobile.commands.selected', { name: displayName(selected) })
|
||||
|
|
@ -574,7 +581,7 @@ type Palette = ReturnType<typeof useMobilePreferences>['palette']
|
|||
function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
||||
return StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: palette.bg.app },
|
||||
content: { paddingHorizontal: 20 },
|
||||
content: { paddingHorizontal: 20, width: '100%', alignSelf: 'center' },
|
||||
header: { minHeight: 76, flexDirection: 'row', alignItems: 'center', gap: 10 },
|
||||
back: { minWidth: 48, minHeight: 48, alignItems: 'center', justifyContent: 'center' },
|
||||
headerCopy: { flex: 1, gap: 3 },
|
||||
|
|
@ -583,7 +590,9 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
loading: { minHeight: 160, alignItems: 'center', justifyContent: 'center', gap: 10 },
|
||||
error: { gap: 10, marginBottom: 12, borderColor: palette.tag.red },
|
||||
list: { gap: 10, marginBottom: 24 },
|
||||
listGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 12 },
|
||||
card: { gap: 10 },
|
||||
cardGridItem: { width: '48.5%', flexGrow: 1 },
|
||||
selected: { borderColor: palette.accent.main, backgroundColor: palette.accent.dim },
|
||||
active: { borderColor: palette.tag.green },
|
||||
copy: { gap: 7 },
|
||||
|
|
@ -591,7 +600,7 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
name: { flex: 1 },
|
||||
actions: { flexDirection: 'row', flexWrap: 'wrap', gap: 7 },
|
||||
sectionLabel: { marginBottom: 8, letterSpacing: 2 },
|
||||
bench: { gap: 13 },
|
||||
bench: { gap: 13, width: '100%' },
|
||||
input: {
|
||||
minHeight: 130,
|
||||
maxHeight: 250,
|
||||
|
|
@ -607,8 +616,8 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
output: { gap: 7, padding: 12, borderWidth: 1, borderRadius: 9, borderColor: palette.accent.main },
|
||||
outputHeader: { flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between' },
|
||||
outputText: { lineHeight: 21 },
|
||||
backdrop: { flex: 1, justifyContent: 'flex-end', padding: 18, backgroundColor: palette.scrim },
|
||||
editor: { gap: 13, maxHeight: '92%' },
|
||||
backdrop: { flex: 1, justifyContent: 'flex-end', alignItems: 'center', padding: 18, backgroundColor: palette.scrim },
|
||||
editor: { gap: 13, maxHeight: '92%', maxWidth: 560, width: '100%' },
|
||||
editorActions: { flexDirection: 'row', justifyContent: 'flex-end', gap: 9 },
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
import { useIsFocused } from '@react-navigation/native'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { useResponsiveLayout } from '@d3ro/ui-native'
|
||||
import type { DictionaryEntry } from '@d3ro/api-client'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
|
|
@ -90,6 +91,7 @@ export default function DictionaryScreen(): React.ReactElement {
|
|||
const { user } = useAuth()
|
||||
const isFocused = useIsFocused()
|
||||
const { palette } = useMobilePreferences()
|
||||
const { gridColumns, wideContentMaxWidth } = useResponsiveLayout()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const requestGeneration = useRef(0)
|
||||
const realtimeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
|
|
@ -277,7 +279,10 @@ export default function DictionaryScreen(): React.ReactElement {
|
|||
}, [deletingId, load, t, user?.id])
|
||||
|
||||
const renderEntry = useCallback(({ item }: { item: DictionaryEntry }): React.ReactElement => (
|
||||
<ThemeCard style={styles.entryCard} testID={`dictionary-entry-${item.id}`}>
|
||||
<ThemeCard
|
||||
style={[styles.entryCard, gridColumns > 1 && styles.entryCardGrid]}
|
||||
testID={`dictionary-entry-${item.id}`}
|
||||
>
|
||||
<View style={styles.entryHeader}>
|
||||
<View style={styles.entryText}>
|
||||
<ThemeText variant="title" accessibilityRole="header">{item.word}</ThemeText>
|
||||
|
|
@ -312,7 +317,7 @@ export default function DictionaryScreen(): React.ReactElement {
|
|||
/>
|
||||
</View>
|
||||
</ThemeCard>
|
||||
), [deletingId, openEdit, removeEntry, styles, t])
|
||||
), [deletingId, gridColumns, openEdit, removeEntry, styles, t])
|
||||
|
||||
const listEmpty = loading ? (
|
||||
<View style={styles.centerState} testID="dictionary-loading">
|
||||
|
|
@ -368,7 +373,7 @@ export default function DictionaryScreen(): React.ReactElement {
|
|||
</View>
|
||||
)}
|
||||
|
||||
<View style={styles.searchArea}>
|
||||
<View style={[styles.searchArea, { maxWidth: wideContentMaxWidth }]}>
|
||||
<TextInput
|
||||
accessibilityLabel={t('mobile.dictionary.search')}
|
||||
value={search}
|
||||
|
|
@ -419,12 +424,15 @@ export default function DictionaryScreen(): React.ReactElement {
|
|||
)}
|
||||
|
||||
<FlatList
|
||||
key={`dictionary-cols-${gridColumns}`}
|
||||
data={entries}
|
||||
numColumns={gridColumns}
|
||||
columnWrapperStyle={gridColumns > 1 ? styles.columnRow : undefined}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={renderEntry}
|
||||
contentContainerStyle={entries.length === 0
|
||||
? styles.emptyList
|
||||
: [styles.listContent, { paddingBottom: Math.max(insets.bottom, 24) }]}
|
||||
? [styles.emptyList, { maxWidth: wideContentMaxWidth }]
|
||||
: [styles.listContent, { maxWidth: wideContentMaxWidth, paddingBottom: Math.max(insets.bottom, 24) }]}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
refreshControl={(
|
||||
<RefreshControl
|
||||
|
|
@ -586,6 +594,8 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
backgroundColor: palette.accent.dim,
|
||||
},
|
||||
searchArea: {
|
||||
width: '100%',
|
||||
alignSelf: 'center',
|
||||
paddingHorizontal: 20,
|
||||
paddingTop: 12,
|
||||
paddingBottom: 10,
|
||||
|
|
@ -631,8 +641,9 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
backgroundColor: palette.accent.main,
|
||||
borderColor: palette.accent.main,
|
||||
},
|
||||
listContent: { padding: 20 },
|
||||
emptyList: { flexGrow: 1 },
|
||||
listContent: { padding: 20, width: '100%', alignSelf: 'center' },
|
||||
columnRow: { gap: 12 },
|
||||
emptyList: { flexGrow: 1, width: '100%', alignSelf: 'center' },
|
||||
centerState: {
|
||||
flex: 1,
|
||||
minHeight: 280,
|
||||
|
|
@ -643,6 +654,7 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
},
|
||||
centerText: { textAlign: 'center', lineHeight: 21 },
|
||||
entryCard: { marginBottom: 12, gap: 10 },
|
||||
entryCardGrid: { flex: 1 },
|
||||
entryHeader: {
|
||||
flexDirection: 'row',
|
||||
alignItems: 'flex-start',
|
||||
|
|
@ -660,7 +672,7 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
borderColor: palette.border.subtle,
|
||||
},
|
||||
entryActions: { flexDirection: 'row', gap: 10, marginTop: 4 },
|
||||
entryButton: { flex: 1, minHeight: 48 },
|
||||
entryButton: { flex: 1, maxWidth: 180, minHeight: 48 },
|
||||
loadMore: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'center',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useCallback, useEffect, useMemo, useState } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
|
||||
import {
|
||||
ActivityIndicator,
|
||||
Alert,
|
||||
|
|
@ -18,6 +18,7 @@ import {
|
|||
PhysicalButton,
|
||||
} from '@d3ro/ui-native'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { formatBytes, formatDurationClockFromMs } from '@d3ro/core/format'
|
||||
import type { AudioFile, HistoryEntry } from '@d3ro/api-client'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import {
|
||||
|
|
@ -84,6 +85,10 @@ export default function HistoryDetailScreen({
|
|||
const { palette } = useMobilePreferences()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const player = useSoundWithStates()
|
||||
const playerRef = useRef(player)
|
||||
playerRef.current = player
|
||||
const mountedRef = useRef(true)
|
||||
const loadGenerationRef = useRef(0)
|
||||
const [detail, setDetail] = useState<HistoryDetail | null>(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState<string | null>(null)
|
||||
|
|
@ -99,6 +104,15 @@ export default function HistoryDetailScreen({
|
|||
const [paused, setPaused] = useState(false)
|
||||
const [audioBusy, setAudioBusy] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
loadGenerationRef.current += 1
|
||||
void Promise.resolve(playerRef.current.stopPlayer()).catch(() => undefined)
|
||||
}
|
||||
}, [])
|
||||
|
||||
const applyEntry = useCallback((entry: HistoryEntry): void => {
|
||||
setTitle(entry.title ?? '')
|
||||
setOriginalText(entry.original_text)
|
||||
|
|
@ -106,7 +120,9 @@ export default function HistoryDetailScreen({
|
|||
}, [])
|
||||
|
||||
const load = useCallback(async (): Promise<void> => {
|
||||
const generation = ++loadGenerationRef.current
|
||||
if (user === null) {
|
||||
if (!mountedRef.current) return
|
||||
setError(t('mobile.account.loginRequired'))
|
||||
setLoading(false)
|
||||
return
|
||||
|
|
@ -116,14 +132,17 @@ export default function HistoryDetailScreen({
|
|||
setError(null)
|
||||
try {
|
||||
const nextDetail = await getHistoryDetail(user.id, route.params.historyId)
|
||||
if (!mountedRef.current || loadGenerationRef.current !== generation) return
|
||||
setDetail(nextDetail)
|
||||
applyEntry(nextDetail.entry)
|
||||
setOffline(false)
|
||||
setConflict(false)
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current || loadGenerationRef.current !== generation) return
|
||||
if (requestError instanceof HistoryServiceError && requestError.code === 'network') {
|
||||
try {
|
||||
const cached = await loadHistoryCache(user.id)
|
||||
if (!mountedRef.current || loadGenerationRef.current !== generation) return
|
||||
const entry = cached?.entries.find((item) => item.id === route.params.historyId)
|
||||
if (entry !== undefined) {
|
||||
setDetail({ entry, audioFiles: [], jobs: [] })
|
||||
|
|
@ -135,13 +154,16 @@ export default function HistoryDetailScreen({
|
|||
// The request error below remains authoritative when secure cache access fails.
|
||||
}
|
||||
}
|
||||
if (!mountedRef.current || loadGenerationRef.current !== generation) return
|
||||
setError(
|
||||
requestError instanceof HistoryServiceError && requestError.code === 'not-found'
|
||||
? t('mobile.hist.notFound')
|
||||
: t('mobile.hist.loadError'),
|
||||
)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
if (mountedRef.current && loadGenerationRef.current === generation) {
|
||||
setLoading(false)
|
||||
}
|
||||
}
|
||||
}, [applyEntry, route.params.historyId, t, user])
|
||||
|
||||
|
|
@ -194,11 +216,13 @@ export default function HistoryDetailScreen({
|
|||
detail.entry.revision,
|
||||
patch,
|
||||
)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : { ...current, entry: updated })
|
||||
applyEntry(updated)
|
||||
setEditing(false)
|
||||
setConflict(false)
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
if (requestError instanceof HistoryServiceError && requestError.code === 'conflict') {
|
||||
setConflict(true)
|
||||
setError(t('mobile.hist.conflict'))
|
||||
|
|
@ -206,7 +230,7 @@ export default function HistoryDetailScreen({
|
|||
setError(t('mobile.hist.editFailed'))
|
||||
}
|
||||
} finally {
|
||||
setSaving(false)
|
||||
if (mountedRef.current) setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -223,12 +247,14 @@ export default function HistoryDetailScreen({
|
|||
previous.revision,
|
||||
{ is_favorite: optimistic.is_favorite },
|
||||
)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : { ...current, entry: updated })
|
||||
} catch {
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : { ...current, entry: previous })
|
||||
setError(t('mobile.hist.favoriteFailed'))
|
||||
} finally {
|
||||
setSaving(false)
|
||||
if (mountedRef.current) setSaving(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -254,8 +280,10 @@ export default function HistoryDetailScreen({
|
|||
setError(null)
|
||||
try {
|
||||
await deleteHistoryRevisionSafe(user.id, detail.entry.id, detail.entry.revision)
|
||||
if (!mountedRef.current) return
|
||||
navigation.goBack()
|
||||
} catch {
|
||||
if (!mountedRef.current) return
|
||||
setError(t('mobile.hist.deleteFailed'))
|
||||
setDeleting(false)
|
||||
}
|
||||
|
|
@ -272,7 +300,7 @@ export default function HistoryDetailScreen({
|
|||
message,
|
||||
})
|
||||
} catch {
|
||||
setError(t('mobile.hist.shareFailed'))
|
||||
if (mountedRef.current) setError(t('mobile.hist.shareFailed'))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,25 +311,34 @@ export default function HistoryDetailScreen({
|
|||
try {
|
||||
if (activeAudioId === audioFile.id && player.state.isPlaying) {
|
||||
await player.pausePlayer()
|
||||
setPaused(true)
|
||||
if (mountedRef.current) setPaused(true)
|
||||
return
|
||||
}
|
||||
if (activeAudioId === audioFile.id && paused) {
|
||||
await player.resumePlayer()
|
||||
setPaused(false)
|
||||
if (mountedRef.current) setPaused(false)
|
||||
return
|
||||
}
|
||||
if (activeAudioId !== null) await player.stopPlayer()
|
||||
if (activeAudioId !== null) {
|
||||
await player.stopPlayer()
|
||||
if (!mountedRef.current) return
|
||||
}
|
||||
const signedUrl = await createAudioPlaybackUrl(user.id, audioFile)
|
||||
if (!mountedRef.current) return
|
||||
await player.startPlayer(signedUrl)
|
||||
if (!mountedRef.current) {
|
||||
void Promise.resolve(player.stopPlayer()).catch(() => undefined)
|
||||
return
|
||||
}
|
||||
setActiveAudioId(audioFile.id)
|
||||
setPaused(false)
|
||||
} catch {
|
||||
if (!mountedRef.current) return
|
||||
setActiveAudioId(null)
|
||||
setPaused(false)
|
||||
setError(t('mobile.hist.audioError'))
|
||||
} finally {
|
||||
setAudioBusy(false)
|
||||
if (mountedRef.current) setAudioBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -309,12 +346,13 @@ export default function HistoryDetailScreen({
|
|||
setAudioBusy(true)
|
||||
try {
|
||||
await player.stopPlayer()
|
||||
if (!mountedRef.current) return
|
||||
setActiveAudioId(null)
|
||||
setPaused(false)
|
||||
} catch {
|
||||
setError(t('mobile.hist.audioError'))
|
||||
if (mountedRef.current) setError(t('mobile.hist.audioError'))
|
||||
} finally {
|
||||
setAudioBusy(false)
|
||||
if (mountedRef.current) setAudioBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -633,18 +671,10 @@ function MetaRow({ label, value }: { label: string; value: string }): React.Reac
|
|||
)
|
||||
}
|
||||
|
||||
export function formatDuration(durationMs: number): string {
|
||||
const totalSeconds = Math.max(0, Math.floor(durationMs / 1000))
|
||||
const minutes = Math.floor(totalSeconds / 60)
|
||||
const seconds = totalSeconds % 60
|
||||
return `${minutes}:${String(seconds).padStart(2, '0')}`
|
||||
}
|
||||
export { formatBytes }
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (!Number.isFinite(bytes) || bytes <= 0) return '0 B'
|
||||
if (bytes < 1024) return `${Math.round(bytes)} B`
|
||||
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`
|
||||
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`
|
||||
export function formatDuration(durationMs: number): string {
|
||||
return formatDurationClockFromMs(durationMs)
|
||||
}
|
||||
|
||||
type Palette = ReturnType<typeof useMobilePreferences>['palette']
|
||||
|
|
|
|||
|
|
@ -345,7 +345,7 @@ function createStyles(palette: Palette) {
|
|||
return StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: palette.bg.app },
|
||||
center: { flex: 1, justifyContent: 'center', alignItems: 'center', padding: 32, backgroundColor: palette.bg.app },
|
||||
searchRow: { paddingHorizontal: 20, paddingTop: 12 },
|
||||
searchRow: { paddingHorizontal: 20, paddingTop: 12, width: '100%', maxWidth: 720, alignSelf: 'center' },
|
||||
searchInput: {
|
||||
minHeight: 48,
|
||||
paddingHorizontal: 14,
|
||||
|
|
@ -356,12 +356,12 @@ function createStyles(palette: Palette) {
|
|||
color: palette.text.primary,
|
||||
fontSize: 14,
|
||||
},
|
||||
filters: { flexDirection: 'row', paddingHorizontal: 20, paddingVertical: 12, gap: 12, borderBottomWidth: 1, borderBottomColor: palette.border.subtle },
|
||||
filters: { flexDirection: 'row', paddingHorizontal: 20, paddingVertical: 12, gap: 12, borderBottomWidth: 1, borderBottomColor: palette.border.subtle, width: '100%', maxWidth: 720, alignSelf: 'center' },
|
||||
offlineBanner: { gap: 4, paddingHorizontal: 20, paddingVertical: 10, backgroundColor: palette.accent.dim },
|
||||
warningBanner: { paddingHorizontal: 20, paddingVertical: 8 },
|
||||
errorBanner: { flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', gap: 12, paddingHorizontal: 20, paddingVertical: 10, backgroundColor: palette.bg.card, borderBottomWidth: 1, borderBottomColor: palette.tag.red },
|
||||
retryButton: { minWidth: 72, minHeight: 48, alignItems: 'center', justifyContent: 'center' },
|
||||
listContent: { padding: 20 },
|
||||
listContent: { padding: 20, width: '100%', maxWidth: 720, alignSelf: 'center' },
|
||||
emptyList: { flexGrow: 1, alignItems: 'center', justifyContent: 'center', padding: 32 },
|
||||
emptyText: { textAlign: 'center' },
|
||||
dateHeader: { letterSpacing: 3, marginBottom: 8, marginTop: 16 },
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
|||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import type { Meeting } from '@d3ro/api-client'
|
||||
import { useI18n, type TFunction } from '@d3ro/i18n'
|
||||
import { CONTENT_MAX_WIDTH_DP } from '@d3ro/ui-native'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useEntitlement } from '../lib/entitlement-context'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
|
|
@ -345,7 +346,7 @@ const stylesStatic = StyleSheet.create({
|
|||
function createStyles(palette: Palette) {
|
||||
return StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: palette.bg.app },
|
||||
content: { paddingHorizontal: 20 },
|
||||
content: { paddingHorizontal: 20, width: '100%', maxWidth: CONTENT_MAX_WIDTH_DP, alignSelf: 'center' },
|
||||
header: { gap: 2 },
|
||||
searchEntry: {
|
||||
minHeight: 64,
|
||||
|
|
|
|||
|
|
@ -355,6 +355,9 @@ function createStyles(palette: Palette) {
|
|||
flexGrow: 1,
|
||||
justifyContent: 'center',
|
||||
paddingHorizontal: 24,
|
||||
width: '100%',
|
||||
maxWidth: 480,
|
||||
alignSelf: 'center',
|
||||
},
|
||||
branding: { alignItems: 'center', marginBottom: 40 },
|
||||
leds: { flexDirection: 'row', gap: 10, marginBottom: 20 },
|
||||
|
|
|
|||
|
|
@ -21,6 +21,11 @@ import type {
|
|||
MeetingMemo,
|
||||
UserTemplate,
|
||||
} from '@d3ro/api-client'
|
||||
import {
|
||||
extractDistinctSpeakers,
|
||||
resolveSpeakerColorIndex,
|
||||
} from '@d3ro/core/meeting-transcript'
|
||||
import { formatDurationClockFromMs } from '@d3ro/core/format'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
|
|
@ -39,6 +44,7 @@ import {
|
|||
loadTemplateLibrary,
|
||||
TemplateServiceError,
|
||||
} from '../features/templates'
|
||||
import { resolveMeetingErrorMessage } from '../features/meetings/meeting-error-message'
|
||||
import {
|
||||
buildMeetingTranscriptView,
|
||||
createMeetingMemo,
|
||||
|
|
@ -96,6 +102,7 @@ export default function MeetingDetailScreen({
|
|||
const { user, session } = useAuth()
|
||||
const { palette } = useMobilePreferences()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const mountedRef = useRef(true)
|
||||
const refreshTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
const requestGeneration = useRef(0)
|
||||
const templateGeneration = useRef(0)
|
||||
|
|
@ -116,6 +123,20 @@ export default function MeetingDetailScreen({
|
|||
const [selectedDocumentTemplate, setSelectedDocumentTemplate] = useState<UserTemplate | null>(null)
|
||||
const [reportTarget, setReportTarget] = useState<ContentReportTarget | null>(null)
|
||||
const [currentPositionMs, setCurrentPositionMs] = useState<number | null>(initialAudioPositionMs)
|
||||
const [selectedSpeaker, setSelectedSpeaker] = useState<string | null>(null)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
requestGeneration.current += 1
|
||||
templateGeneration.current += 1
|
||||
if (refreshTimer.current !== null) {
|
||||
clearTimeout(refreshTimer.current)
|
||||
refreshTimer.current = null
|
||||
}
|
||||
}
|
||||
}, [])
|
||||
|
||||
const handleSeekTimestamp = useCallback((timestampMs: number): void => {
|
||||
const clamped = Math.max(0, Math.floor(timestampMs))
|
||||
|
|
@ -129,6 +150,7 @@ export default function MeetingDetailScreen({
|
|||
): Promise<void> => {
|
||||
const generation = ++requestGeneration.current
|
||||
if (user === null) {
|
||||
if (!mountedRef.current) return
|
||||
setDetail(null)
|
||||
setError(t('mobile.meetings.loginRequired'))
|
||||
setLoading(false)
|
||||
|
|
@ -140,15 +162,15 @@ export default function MeetingDetailScreen({
|
|||
if (!keepCurrent) setError(null)
|
||||
try {
|
||||
const loaded = await getMeetingDetail(user.id, route.params.meetingId)
|
||||
if (generation !== requestGeneration.current) return
|
||||
if (!mountedRef.current || generation !== requestGeneration.current) return
|
||||
setDetail(loaded)
|
||||
setError(null)
|
||||
setConflict(false)
|
||||
} catch (requestError) {
|
||||
if (generation !== requestGeneration.current) return
|
||||
if (!mountedRef.current || generation !== requestGeneration.current) return
|
||||
setError(meetingErrorMessage(requestError, t))
|
||||
} finally {
|
||||
if (generation === requestGeneration.current) {
|
||||
if (mountedRef.current && generation === requestGeneration.current) {
|
||||
setLoading(false)
|
||||
setRefreshing(false)
|
||||
}
|
||||
|
|
@ -160,12 +182,12 @@ export default function MeetingDetailScreen({
|
|||
): Promise<void> => {
|
||||
const generation = ++templateGeneration.current
|
||||
if (user === null) {
|
||||
setSelectedDocumentTemplate(null)
|
||||
if (mountedRef.current) setSelectedDocumentTemplate(null)
|
||||
return
|
||||
}
|
||||
try {
|
||||
const library = await loadTemplateLibrary(user.id, 'meeting_document')
|
||||
if (generation !== templateGeneration.current) return
|
||||
if (!mountedRef.current || generation !== templateGeneration.current) return
|
||||
const selectedId = meetingTemplateId
|
||||
?? library.selections.meeting_document?.template_id
|
||||
setSelectedDocumentTemplate(
|
||||
|
|
@ -176,7 +198,7 @@ export default function MeetingDetailScreen({
|
|||
?? null,
|
||||
)
|
||||
} catch (requestError) {
|
||||
if (generation !== templateGeneration.current) return
|
||||
if (!mountedRef.current || generation !== templateGeneration.current) return
|
||||
setSelectedDocumentTemplate(null)
|
||||
setError(templateErrorMessage(requestError, t))
|
||||
}
|
||||
|
|
@ -201,12 +223,16 @@ export default function MeetingDetailScreen({
|
|||
const subscription = subscribeToMeetingDetail(
|
||||
route.params.meetingId,
|
||||
() => {
|
||||
if (!mountedRef.current) return
|
||||
if (refreshTimer.current !== null) clearTimeout(refreshTimer.current)
|
||||
refreshTimer.current = setTimeout(() => {
|
||||
void load(false, true)
|
||||
refreshTimer.current = null
|
||||
if (mountedRef.current) void load(false, true)
|
||||
}, 250)
|
||||
},
|
||||
(status) => setRealtimeConnected(status === 'SUBSCRIBED'),
|
||||
(status) => {
|
||||
if (mountedRef.current) setRealtimeConnected(status === 'SUBSCRIBED')
|
||||
},
|
||||
)
|
||||
return () => {
|
||||
if (refreshTimer.current !== null) {
|
||||
|
|
@ -254,10 +280,12 @@ export default function MeetingDetailScreen({
|
|||
try {
|
||||
if (editor.kind === 'meeting') {
|
||||
const updated = await updateMeetingTitleRevisionSafe(editor.current, editorTitle)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : { ...current, meeting: updated })
|
||||
} else if (editor.kind === 'memo') {
|
||||
if (user === null) return
|
||||
const updated = await updateMeetingMemoConflictSafe(user.id, editor.current, editorContent)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : {
|
||||
...current,
|
||||
memos: current.memos.map((memo) => memo.id === updated.id ? updated : memo),
|
||||
|
|
@ -268,6 +296,7 @@ export default function MeetingDetailScreen({
|
|||
editorTitle,
|
||||
editorContent,
|
||||
)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : {
|
||||
...current,
|
||||
documents: current.documents.map((document) => (
|
||||
|
|
@ -279,12 +308,13 @@ export default function MeetingDetailScreen({
|
|||
setConflict(false)
|
||||
setError(null)
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
const isConflict = requestError instanceof MeetingServiceError
|
||||
&& requestError.code === 'conflict'
|
||||
setConflict(isConflict)
|
||||
setEditorError(meetingErrorMessage(requestError, t))
|
||||
} finally {
|
||||
setEditorBusy(false)
|
||||
if (mountedRef.current) setEditorBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,15 +324,17 @@ export default function MeetingDetailScreen({
|
|||
setError(null)
|
||||
try {
|
||||
const created = await createMeetingMemo(user.id, detail.meeting, memoDraft)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : {
|
||||
...current,
|
||||
memos: [...current.memos, created].sort(compareMemos),
|
||||
})
|
||||
setMemoDraft('')
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
setError(meetingErrorMessage(requestError, t))
|
||||
} finally {
|
||||
setBusyKey(null)
|
||||
if (mountedRef.current) setBusyKey(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -328,8 +360,10 @@ export default function MeetingDetailScreen({
|
|||
setError(null)
|
||||
try {
|
||||
await deleteMeetingRevisionSafe(user.id, detail.meeting)
|
||||
if (!mountedRef.current) return
|
||||
navigation.goBack()
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
handleMutationError(requestError)
|
||||
setBusyKey(null)
|
||||
}
|
||||
|
|
@ -356,14 +390,16 @@ export default function MeetingDetailScreen({
|
|||
setError(null)
|
||||
try {
|
||||
await deleteMeetingMemoConflictSafe(user.id, memo)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : {
|
||||
...current,
|
||||
memos: current.memos.filter((candidate) => candidate.id !== memo.id),
|
||||
})
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
handleMutationError(requestError)
|
||||
} finally {
|
||||
setBusyKey(null)
|
||||
if (mountedRef.current) setBusyKey(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -388,15 +424,17 @@ export default function MeetingDetailScreen({
|
|||
setError(null)
|
||||
try {
|
||||
await deleteMeetingDocumentRevisionSafe(user.id, document)
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => current === null ? null : {
|
||||
...current,
|
||||
documents: current.documents.filter((candidate) => candidate.id !== document.id),
|
||||
})
|
||||
setExpandedDocumentId((current) => current === document.id ? null : current)
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
handleMutationError(requestError)
|
||||
} finally {
|
||||
setBusyKey(null)
|
||||
if (mountedRef.current) setBusyKey(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -420,12 +458,16 @@ export default function MeetingDetailScreen({
|
|||
memos: detail.memos,
|
||||
documents: detail.documents,
|
||||
}, format)
|
||||
if (!mountedRef.current) {
|
||||
await prepared.dispose().catch(() => undefined)
|
||||
return
|
||||
}
|
||||
await sharePreparedPortableFile(prepared, t('mobile.meetings.exportShareTitle'))
|
||||
} catch {
|
||||
await prepared?.dispose().catch(() => undefined)
|
||||
setError(t('mobile.meetings.exportFailed'))
|
||||
if (mountedRef.current) setError(t('mobile.meetings.exportFailed'))
|
||||
} finally {
|
||||
setBusyKey((current) => current === key ? null : current)
|
||||
if (mountedRef.current) setBusyKey((current) => current === key ? null : current)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -451,6 +493,7 @@ export default function MeetingDetailScreen({
|
|||
templateId,
|
||||
title,
|
||||
})
|
||||
if (!mountedRef.current) return
|
||||
setDetail((current) => {
|
||||
if (current === null) return null
|
||||
const existing = current.documents.some((document) => document.id === generated.document.id)
|
||||
|
|
@ -465,9 +508,10 @@ export default function MeetingDetailScreen({
|
|||
})
|
||||
setExpandedDocumentId(generated.document.id)
|
||||
} catch (requestError) {
|
||||
if (!mountedRef.current) return
|
||||
setError(templateErrorMessage(requestError, t))
|
||||
} finally {
|
||||
setBusyKey(null)
|
||||
if (mountedRef.current) setBusyKey(null)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -477,6 +521,33 @@ export default function MeetingDetailScreen({
|
|||
const seekableSegments = useMemo(() => (
|
||||
detail === null ? [] : parseTranscriptSeekSegments(detail.meeting, detail.transcripts)
|
||||
), [detail])
|
||||
const distinctSpeakers = useMemo(
|
||||
() => extractDistinctSpeakers(seekableSegments),
|
||||
[seekableSegments],
|
||||
)
|
||||
useEffect(() => {
|
||||
if (selectedSpeaker !== null && !distinctSpeakers.includes(selectedSpeaker)) {
|
||||
setSelectedSpeaker(null)
|
||||
}
|
||||
}, [distinctSpeakers, selectedSpeaker])
|
||||
const visibleSegments = useMemo(
|
||||
() => (
|
||||
selectedSpeaker === null
|
||||
? seekableSegments
|
||||
: seekableSegments.filter((segment) => segment.speaker?.trim() === selectedSpeaker)
|
||||
),
|
||||
[seekableSegments, selectedSpeaker],
|
||||
)
|
||||
const speakerColors = useMemo(
|
||||
() => [
|
||||
palette.tag.purple,
|
||||
palette.tag.green,
|
||||
palette.tag.orange,
|
||||
palette.tag.red,
|
||||
palette.tag.blue,
|
||||
],
|
||||
[palette],
|
||||
)
|
||||
const activeSegmentId = useMemo(() => (
|
||||
findActiveTranscriptSegmentId(seekableSegments, currentPositionMs)
|
||||
), [currentPositionMs, seekableSegments])
|
||||
|
|
@ -671,14 +742,62 @@ export default function MeetingDetailScreen({
|
|||
{formatElapsedMs(currentPositionMs)}
|
||||
</ThemeText>
|
||||
)}
|
||||
{distinctSpeakers.length >= 2 && (
|
||||
<View style={styles.speakerFilterRow} testID="meeting-speaker-filter-bar">
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected: selectedSpeaker === null }}
|
||||
onPress={() => setSelectedSpeaker(null)}
|
||||
style={[
|
||||
styles.speakerFilterChip,
|
||||
selectedSpeaker === null && styles.speakerFilterChipActive,
|
||||
]}
|
||||
testID="meeting-speaker-filter-all"
|
||||
>
|
||||
<ThemeText variant="label" color={selectedSpeaker === null ? 'accent' : 'muted'}>
|
||||
{t('mobile.hist.all')}
|
||||
</ThemeText>
|
||||
</Pressable>
|
||||
{distinctSpeakers.map((sp) => {
|
||||
const active = selectedSpeaker === sp
|
||||
const spColor = speakerColors[resolveSpeakerColorIndex(sp, speakerColors.length)]
|
||||
return (
|
||||
<Pressable
|
||||
key={sp}
|
||||
accessibilityRole="button"
|
||||
accessibilityState={{ selected: active }}
|
||||
onPress={() => setSelectedSpeaker(active ? null : sp)}
|
||||
style={[
|
||||
styles.speakerFilterChip,
|
||||
active && { borderColor: spColor, backgroundColor: palette.overlay.soft },
|
||||
]}
|
||||
testID={`meeting-speaker-filter-${sp}`}
|
||||
>
|
||||
<ThemeText
|
||||
variant="label"
|
||||
style={active ? { color: spColor } : undefined}
|
||||
color={active ? undefined : 'muted'}
|
||||
>
|
||||
{sp}
|
||||
</ThemeText>
|
||||
</Pressable>
|
||||
)
|
||||
})}
|
||||
</View>
|
||||
)}
|
||||
{transcript?.source === 'segments' || seekableSegments.some((segment) => segment.timed) ? (
|
||||
seekableSegments.map((segment) => {
|
||||
visibleSegments.map((segment) => {
|
||||
const isActive = activeSegmentId === segment.id
|
||||
const speakerLabel = segment.speaker?.trim() || null
|
||||
const speakerColor = speakerLabel
|
||||
? speakerColors[resolveSpeakerColorIndex(speakerLabel, speakerColors.length)]
|
||||
: null
|
||||
return (
|
||||
<View
|
||||
key={segment.id}
|
||||
style={[
|
||||
styles.transcriptSegment,
|
||||
speakerColor !== null && !isActive && { borderLeftWidth: 3, borderLeftColor: speakerColor },
|
||||
isActive && styles.transcriptSegmentActive,
|
||||
]}
|
||||
testID={`meeting-transcript-${segment.id}`}
|
||||
|
|
@ -696,8 +815,18 @@ export default function MeetingDetailScreen({
|
|||
</ThemeText>
|
||||
</Pressable>
|
||||
) : null}
|
||||
{segment.speaker !== null && (
|
||||
<ThemeText variant="label" color="muted">{segment.speaker}</ThemeText>
|
||||
{speakerLabel !== null && speakerColor !== null && (
|
||||
<View
|
||||
style={[
|
||||
styles.speakerBadge,
|
||||
{ borderColor: speakerColor, backgroundColor: palette.overlay.soft },
|
||||
]}
|
||||
testID={`meeting-transcript-speaker-${segment.id}`}
|
||||
>
|
||||
<ThemeText variant="label" style={{ color: speakerColor }}>
|
||||
{speakerLabel}
|
||||
</ThemeText>
|
||||
</View>
|
||||
)}
|
||||
{segment.edited && (
|
||||
<ThemeText variant="label" color="muted">
|
||||
|
|
@ -1052,12 +1181,7 @@ function compareMemos(left: MeetingMemo, right: MeetingMemo): number {
|
|||
}
|
||||
|
||||
export function formatElapsedMs(value: number): string {
|
||||
const totalSeconds = Math.max(0, Math.floor(value / 1_000))
|
||||
const hours = Math.floor(totalSeconds / 3_600)
|
||||
const minutes = Math.floor((totalSeconds % 3_600) / 60)
|
||||
const seconds = totalSeconds % 60
|
||||
const base = `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`
|
||||
return hours > 0 ? `${hours}:${base}` : base
|
||||
return formatDurationClockFromMs(value, { padMinutes: true, showHours: true })
|
||||
}
|
||||
|
||||
export function formatMinutesJson(value: Record<string, unknown>): string {
|
||||
|
|
@ -1071,14 +1195,7 @@ export function formatMinutesJson(value: Record<string, unknown>): string {
|
|||
type Translate = ReturnType<typeof useI18n>['t']
|
||||
|
||||
function meetingErrorMessage(error: unknown, t: Translate): string {
|
||||
if (!(error instanceof MeetingServiceError)) return t('mobile.meetings.errorServer')
|
||||
if (error.code === 'auth') return t('mobile.meetings.loginRequired')
|
||||
if (error.code === 'conflict') return t('mobile.meetings.errorConflict')
|
||||
if (error.code === 'forbidden') return t('mobile.meetings.errorForbidden')
|
||||
if (error.code === 'network') return t('mobile.meetings.errorNetwork')
|
||||
if (error.code === 'not-found') return t('mobile.meetings.errorNotFound')
|
||||
if (error.code === 'validation') return t('mobile.meetings.errorValidation')
|
||||
return t('mobile.meetings.errorServer')
|
||||
return resolveMeetingErrorMessage(error, t)
|
||||
}
|
||||
|
||||
function templateErrorMessage(error: unknown, t: Translate): string {
|
||||
|
|
@ -1164,7 +1281,26 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
borderLeftWidth: 3,
|
||||
borderLeftColor: palette.accent.main,
|
||||
},
|
||||
segmentMeta: { flexDirection: 'row', alignItems: 'center', gap: 10 },
|
||||
segmentMeta: { flexDirection: 'row', alignItems: 'center', flexWrap: 'wrap', gap: 8 },
|
||||
speakerFilterRow: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, marginBottom: 4 },
|
||||
speakerFilterChip: {
|
||||
paddingHorizontal: 10,
|
||||
paddingVertical: 4,
|
||||
borderRadius: 999,
|
||||
borderWidth: 1,
|
||||
borderColor: palette.border.default,
|
||||
backgroundColor: palette.bg.card,
|
||||
},
|
||||
speakerFilterChipActive: {
|
||||
borderColor: palette.accent.main,
|
||||
backgroundColor: palette.accent.dim,
|
||||
},
|
||||
speakerBadge: {
|
||||
paddingHorizontal: 8,
|
||||
paddingVertical: 2,
|
||||
borderRadius: 999,
|
||||
borderWidth: 1,
|
||||
},
|
||||
readingText: { lineHeight: 23 },
|
||||
codeText: {
|
||||
lineHeight: 21,
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import type { NavigationProp, ParamListBase } from '@react-navigation/native'
|
|||
import { useFocusEffect } from '@react-navigation/native'
|
||||
import type { Meeting, MeetingLanguage, UserTemplate } from '@d3ro/api-client'
|
||||
import { useI18n } from '@d3ro/i18n'
|
||||
import { useResponsiveLayout } from '@d3ro/ui-native'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
import { ThemeButton, ThemeCard, ThemeText } from '../theme/themed-components'
|
||||
|
|
@ -29,6 +30,7 @@ import {
|
|||
MeetingServiceError,
|
||||
updateMeetingTitleRevisionSafe,
|
||||
} from '../features/meetings/meetings-service'
|
||||
import { resolveMeetingErrorMessage } from '../features/meetings/meeting-error-message'
|
||||
import { loadTemplateLibrary } from '../features/templates'
|
||||
import { useTabScreenBottomPadding } from '../navigation/tab-layout'
|
||||
|
||||
|
|
@ -53,6 +55,7 @@ export default function MeetingsScreen({
|
|||
const { t, formatDate } = useI18n()
|
||||
const { user } = useAuth()
|
||||
const { palette } = useMobilePreferences()
|
||||
const { gridColumns, wideContentMaxWidth } = useResponsiveLayout()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const requestGeneration = useRef(0)
|
||||
const templateRequestGeneration = useRef(0)
|
||||
|
|
@ -362,7 +365,7 @@ export default function MeetingsScreen({
|
|||
testID="meetings-header"
|
||||
/>
|
||||
|
||||
<View style={styles.searchWrap}>
|
||||
<View style={[styles.searchWrap, { maxWidth: wideContentMaxWidth }]}>
|
||||
<TextInput
|
||||
accessibilityLabel={t('mobile.meetings.search')}
|
||||
value={search}
|
||||
|
|
@ -379,7 +382,7 @@ export default function MeetingsScreen({
|
|||
</View>
|
||||
|
||||
{error !== null && (
|
||||
<View style={styles.errorBanner} testID="meetings-error">
|
||||
<View style={[styles.errorBanner, { maxWidth: wideContentMaxWidth - 40 }]} testID="meetings-error">
|
||||
<ThemeText color="danger" style={styles.errorText}>{error}</ThemeText>
|
||||
<ThemeButton
|
||||
label={t('mobile.meetings.retry')}
|
||||
|
|
@ -397,11 +400,14 @@ export default function MeetingsScreen({
|
|||
</View>
|
||||
) : (
|
||||
<FlatList
|
||||
key={`meetings-cols-${gridColumns}`}
|
||||
data={meetings}
|
||||
numColumns={gridColumns}
|
||||
columnWrapperStyle={gridColumns > 1 ? styles.columnRow : undefined}
|
||||
keyExtractor={(meeting) => meeting.id}
|
||||
contentContainerStyle={[
|
||||
meetings.length === 0 ? styles.emptyList : styles.list,
|
||||
{ paddingBottom: bottomPadding },
|
||||
{ maxWidth: wideContentMaxWidth, paddingBottom: bottomPadding },
|
||||
]}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
refreshControl={(
|
||||
|
|
@ -432,7 +438,10 @@ export default function MeetingsScreen({
|
|||
const busy = busyId === meeting.id
|
||||
const owned = meeting.user_id === user?.id
|
||||
return (
|
||||
<ThemeCard style={styles.card} testID={`meeting-card-${meeting.id}`}>
|
||||
<ThemeCard
|
||||
style={[styles.card, gridColumns > 1 && styles.cardGridItem]}
|
||||
testID={`meeting-card-${meeting.id}`}
|
||||
>
|
||||
<Pressable
|
||||
accessibilityRole="button"
|
||||
accessibilityLabel={meeting.title ?? t('mobile.meetings.untitled')}
|
||||
|
|
@ -732,14 +741,7 @@ export function mergeMeetings(current: Meeting[], incoming: Meeting[]): Meeting[
|
|||
type Translate = ReturnType<typeof useI18n>['t']
|
||||
|
||||
function meetingErrorMessage(error: unknown, t: Translate): string {
|
||||
if (!(error instanceof MeetingServiceError)) return t('mobile.meetings.errorServer')
|
||||
if (error.code === 'auth') return t('mobile.meetings.loginRequired')
|
||||
if (error.code === 'conflict') return t('mobile.meetings.errorConflict')
|
||||
if (error.code === 'forbidden') return t('mobile.meetings.errorForbidden')
|
||||
if (error.code === 'network') return t('mobile.meetings.errorNetwork')
|
||||
if (error.code === 'not-found') return t('mobile.meetings.errorNotFound')
|
||||
if (error.code === 'validation') return t('mobile.meetings.errorValidation')
|
||||
return t('mobile.meetings.errorServer')
|
||||
return resolveMeetingErrorMessage(error, t)
|
||||
}
|
||||
|
||||
type Palette = ReturnType<typeof useMobilePreferences>['palette']
|
||||
|
|
@ -768,7 +770,7 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
},
|
||||
headerCopy: { flex: 1, gap: 4 },
|
||||
headerActions: { flexDirection: 'row', gap: 8, flexShrink: 0 },
|
||||
searchWrap: { paddingHorizontal: 20, paddingBottom: 12 },
|
||||
searchWrap: { paddingHorizontal: 20, paddingBottom: 12, width: '100%', alignSelf: 'center' },
|
||||
searchInput: {
|
||||
minHeight: 48,
|
||||
borderWidth: 1,
|
||||
|
|
@ -784,6 +786,8 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
marginBottom: 10,
|
||||
paddingHorizontal: 12,
|
||||
minHeight: 52,
|
||||
width: '100%',
|
||||
alignSelf: 'center',
|
||||
flexDirection: 'row',
|
||||
alignItems: 'center',
|
||||
gap: 10,
|
||||
|
|
@ -794,11 +798,13 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
},
|
||||
errorText: { flex: 1 },
|
||||
center: { flex: 1, alignItems: 'center', justifyContent: 'center', gap: 12, padding: 32 },
|
||||
list: { paddingHorizontal: 20, paddingTop: 4 },
|
||||
emptyList: { flexGrow: 1, justifyContent: 'center', paddingHorizontal: 20 },
|
||||
list: { paddingHorizontal: 20, paddingTop: 4, width: '100%', alignSelf: 'center' },
|
||||
columnRow: { gap: 12 },
|
||||
emptyList: { flexGrow: 1, justifyContent: 'center', paddingHorizontal: 20, width: '100%', alignSelf: 'center' },
|
||||
emptyCard: { alignItems: 'center', paddingVertical: 36 },
|
||||
emptyText: { textAlign: 'center' },
|
||||
card: { marginBottom: 12, padding: 0, overflow: 'hidden' },
|
||||
cardGridItem: { flex: 1 },
|
||||
cardBody: { padding: 16, gap: 7 },
|
||||
cardTop: { flexDirection: 'row', alignItems: 'flex-start', gap: 12 },
|
||||
cardTitle: { flex: 1 },
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import type { BottomTabNavigationProp } from '@react-navigation/bottom-tabs'
|
|||
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { useResponsiveLayout } from '@d3ro/ui-native'
|
||||
import { currentAdminRole } from '../features/admin/admin-service'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useEntitlement, type MobileSubscriptionTier } from '../lib/entitlement-context'
|
||||
|
|
@ -170,6 +171,7 @@ export default function MoreScreen(): React.ReactElement {
|
|||
const { user } = useAuth()
|
||||
const { snapshot } = useEntitlement()
|
||||
const { palette } = useMobilePreferences()
|
||||
const { isLargeScreen, wideContentMaxWidth } = useResponsiveLayout()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const accountItems = currentAdminRole(user?.app_metadata) === null
|
||||
? ACCOUNT_ITEMS
|
||||
|
|
@ -186,7 +188,7 @@ export default function MoreScreen(): React.ReactElement {
|
|||
style={styles.container}
|
||||
contentContainerStyle={[
|
||||
styles.content,
|
||||
{ paddingTop: insets.top + 16, paddingBottom: bottomPadding },
|
||||
{ maxWidth: wideContentMaxWidth, paddingTop: insets.top + 16, paddingBottom: bottomPadding },
|
||||
]}
|
||||
testID="more-screen"
|
||||
>
|
||||
|
|
@ -198,12 +200,14 @@ export default function MoreScreen(): React.ReactElement {
|
|||
title={t('mobile.more.section.tools')}
|
||||
items={TOOL_ITEMS}
|
||||
describe={description}
|
||||
isLargeScreen={isLargeScreen}
|
||||
onOpen={(route) => navigation.navigate(route)}
|
||||
/>
|
||||
<MoreSection
|
||||
title={t('mobile.more.section.account')}
|
||||
items={accountItems}
|
||||
describe={description}
|
||||
isLargeScreen={isLargeScreen}
|
||||
onOpen={(route) => navigation.navigate(route)}
|
||||
/>
|
||||
</ScrollView>
|
||||
|
|
@ -214,11 +218,13 @@ function MoreSection({
|
|||
title,
|
||||
items,
|
||||
describe,
|
||||
isLargeScreen,
|
||||
onOpen,
|
||||
}: {
|
||||
title: string
|
||||
items: readonly MoreItem[]
|
||||
describe: (item: MoreItem) => string
|
||||
isLargeScreen: boolean
|
||||
onOpen: (route: MoreRoute) => void
|
||||
}): React.ReactElement {
|
||||
const { t } = useI18n()
|
||||
|
|
@ -229,7 +235,13 @@ function MoreSection({
|
|||
<ThemeText variant="label" color="muted" style={styles.sectionTitle}>
|
||||
{title}
|
||||
</ThemeText>
|
||||
<View style={[styles.rows, { borderColor: palette.border.subtle }]}>
|
||||
<View
|
||||
style={[
|
||||
isLargeScreen ? styles.rowsGrid : styles.rows,
|
||||
{ borderColor: palette.border.subtle },
|
||||
]}
|
||||
testID={`more-rows-${isLargeScreen ? 'grid' : 'list'}`}
|
||||
>
|
||||
{items.map((item, index) => {
|
||||
const itemDescription = describe(item)
|
||||
return (
|
||||
|
|
@ -242,7 +254,9 @@ function MoreSection({
|
|||
testID={item.testID}
|
||||
style={({ pressed }) => [
|
||||
styles.row,
|
||||
index > 0 && { borderTopColor: palette.border.subtle, borderTopWidth: 1 },
|
||||
isLargeScreen
|
||||
? [styles.rowGridCard, { borderColor: palette.border.subtle }]
|
||||
: index > 0 && { borderTopColor: palette.border.subtle, borderTopWidth: 1 },
|
||||
pressed && { backgroundColor: palette.bg.cardHover },
|
||||
]}
|
||||
>
|
||||
|
|
@ -306,11 +320,12 @@ type Palette = ReturnType<typeof useMobilePreferences>['palette']
|
|||
function createStyles(palette: Palette) {
|
||||
return StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: palette.bg.app },
|
||||
content: { paddingHorizontal: 20 },
|
||||
content: { paddingHorizontal: 20, width: '100%', alignSelf: 'center' },
|
||||
title: { marginBottom: 8 },
|
||||
section: { marginTop: 20 },
|
||||
sectionTitle: { minHeight: 32, justifyContent: 'center', letterSpacing: 0 },
|
||||
rows: { borderTopWidth: 1, borderBottomWidth: 1 },
|
||||
rowsGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 12 },
|
||||
row: {
|
||||
minHeight: 72,
|
||||
flexDirection: 'row',
|
||||
|
|
@ -318,6 +333,14 @@ function createStyles(palette: Palette) {
|
|||
gap: 14,
|
||||
paddingVertical: 10,
|
||||
},
|
||||
rowGridCard: {
|
||||
width: '48.5%',
|
||||
flexGrow: 1,
|
||||
paddingHorizontal: 14,
|
||||
borderWidth: 1,
|
||||
borderRadius: 12,
|
||||
backgroundColor: palette.bg.card,
|
||||
},
|
||||
copy: { flex: 1, gap: 3 },
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useRef, useState } from 'react'
|
||||
import {
|
||||
Pressable,
|
||||
ScrollView,
|
||||
|
|
@ -8,6 +8,7 @@ import {
|
|||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import type { NativeStackScreenProps } from '@react-navigation/native-stack'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { LOCALE_META } from '@d3ro/i18n/shared'
|
||||
import type { RootStackParamList } from '../../App'
|
||||
import {
|
||||
MOBILE_THEME_MODES,
|
||||
|
|
@ -119,11 +120,21 @@ export default function OnboardingScreen({
|
|||
updatePreferences,
|
||||
completeOnboarding,
|
||||
} = useMobilePreferences()
|
||||
const mountedRef = useRef(true)
|
||||
const localeRequestRef = useRef(0)
|
||||
const [step, setStep] = useState(0)
|
||||
const [audience, setAudience] = useState<OnboardingAudience | null>(null)
|
||||
const [saving, setSaving] = useState(false)
|
||||
const [localSaveFailed, setLocalSaveFailed] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
localeRequestRef.current += 1
|
||||
}
|
||||
}, [])
|
||||
|
||||
const isReplay = route.params?.replay === true
|
||||
const isLastStep = step === SLIDES.length - 1
|
||||
const slide = SLIDES[step]
|
||||
|
|
@ -132,10 +143,27 @@ export default function OnboardingScreen({
|
|||
[step],
|
||||
)
|
||||
|
||||
async function applyLocaleSelection(nextLocale: SupportedMobileLocale): Promise<void> {
|
||||
const request = ++localeRequestRef.current
|
||||
try {
|
||||
const result = await updatePreferences({ locale: nextLocale })
|
||||
if (!mountedRef.current || localeRequestRef.current !== request) return
|
||||
if (!result.localSaved) {
|
||||
setLocalSaveFailed(true)
|
||||
return
|
||||
}
|
||||
setLocalSaveFailed(false)
|
||||
setLocale(nextLocale)
|
||||
} catch {
|
||||
if (mountedRef.current && localeRequestRef.current === request) {
|
||||
setLocalSaveFailed(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function selectLocale(nextLocale: SupportedMobileLocale): void {
|
||||
if (locale === nextLocale) return
|
||||
setLocale(nextLocale)
|
||||
void updatePreferences({ locale: nextLocale })
|
||||
void applyLocaleSelection(nextLocale)
|
||||
}
|
||||
|
||||
function selectTheme(nextTheme: MobileThemeMode): void {
|
||||
|
|
@ -149,18 +177,24 @@ export default function OnboardingScreen({
|
|||
onFreshFinish?.(selectedAudience)
|
||||
setSaving(true)
|
||||
setLocalSaveFailed(false)
|
||||
const result = await completeOnboarding(outcome)
|
||||
if (!result.localSaved) {
|
||||
setLocalSaveFailed(true)
|
||||
setSaving(false)
|
||||
return
|
||||
try {
|
||||
const result = await completeOnboarding(outcome)
|
||||
if (!mountedRef.current) return
|
||||
if (!result.localSaved) {
|
||||
setLocalSaveFailed(true)
|
||||
return
|
||||
}
|
||||
const exit = resolveOnboardingExit(true, user !== null, isReplay, navigation.canGoBack())
|
||||
// Authenticated fresh completion changes the root navigator branch. The
|
||||
// parent observes needsOnboarding true -> false and resets to Main after
|
||||
// the new branch mounts; replacing here targets the already-stale
|
||||
// onboarding navigator and produces an unhandled REPLACE warning.
|
||||
if (exit === 'back') navigation.goBack()
|
||||
} catch {
|
||||
if (mountedRef.current) setLocalSaveFailed(true)
|
||||
} finally {
|
||||
if (mountedRef.current) setSaving(false)
|
||||
}
|
||||
const exit = resolveOnboardingExit(true, user !== null, isReplay, navigation.canGoBack())
|
||||
// Authenticated fresh completion changes the root navigator branch. The
|
||||
// parent observes needsOnboarding true -> false and resets to Main after
|
||||
// the new branch mounts; replacing here targets the already-stale
|
||||
// onboarding navigator and produces an unhandled REPLACE warning.
|
||||
if (exit === 'back') navigation.goBack()
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
@ -188,26 +222,29 @@ export default function OnboardingScreen({
|
|||
: t('mobile.onboarding.setupLabel')}
|
||||
</ThemeText>
|
||||
</View>
|
||||
<View
|
||||
style={styles.localeRow}
|
||||
<ScrollView
|
||||
horizontal
|
||||
showsHorizontalScrollIndicator={false}
|
||||
style={styles.localeScroll}
|
||||
contentContainerStyle={styles.localeRow}
|
||||
accessibilityRole="radiogroup"
|
||||
accessibilityLabel={t('mobile.onboarding.languageLabel')}
|
||||
>
|
||||
{(['ko', 'en'] as const).map((candidate) => (
|
||||
{LOCALE_META.map((item) => (
|
||||
<Pressable
|
||||
key={candidate}
|
||||
key={item.code}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{ selected: locale === candidate }}
|
||||
accessibilityLabel={candidate === 'ko' ? '한국어' : 'English'}
|
||||
testID={`onboarding-language-${candidate}`}
|
||||
onPress={() => selectLocale(candidate)}
|
||||
accessibilityState={{ selected: locale === item.code }}
|
||||
accessibilityLabel={item.nativeName}
|
||||
testID={`onboarding-language-${item.code}`}
|
||||
onPress={() => selectLocale(item.code)}
|
||||
style={({ pressed }) => [
|
||||
styles.localeButton,
|
||||
{
|
||||
borderColor: locale === candidate
|
||||
borderColor: locale === item.code
|
||||
? palette.accent.main
|
||||
: palette.border.default,
|
||||
backgroundColor: locale === candidate
|
||||
backgroundColor: locale === item.code
|
||||
? palette.accent.dim
|
||||
: 'transparent',
|
||||
opacity: pressed ? 0.72 : 1,
|
||||
|
|
@ -216,13 +253,13 @@ export default function OnboardingScreen({
|
|||
>
|
||||
<ThemeText
|
||||
variant="small"
|
||||
color={locale === candidate ? 'accent' : 'muted'}
|
||||
color={locale === item.code ? 'accent' : 'muted'}
|
||||
>
|
||||
{candidate.toUpperCase()}
|
||||
{item.code.toUpperCase()}
|
||||
</ThemeText>
|
||||
</Pressable>
|
||||
))}
|
||||
</View>
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
||||
<ScrollView
|
||||
|
|
@ -529,17 +566,19 @@ const styles = StyleSheet.create({
|
|||
gap: 12,
|
||||
},
|
||||
brand: { letterSpacing: 2.6, marginBottom: 4 },
|
||||
localeRow: { flexDirection: 'row', gap: 8 },
|
||||
localeScroll: { flexShrink: 1, maxWidth: '62%' },
|
||||
localeRow: { flexDirection: 'row', gap: 8, paddingHorizontal: 2 },
|
||||
localeButton: {
|
||||
minWidth: 52,
|
||||
minHeight: 48,
|
||||
paddingHorizontal: 8,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderRadius: 9,
|
||||
borderWidth: 1,
|
||||
},
|
||||
scroll: { flex: 1 },
|
||||
content: { paddingHorizontal: 20, paddingTop: 22 },
|
||||
content: { paddingHorizontal: 20, paddingTop: 22, width: '100%', maxWidth: 720, alignSelf: 'center' },
|
||||
progressRow: { flexDirection: 'row', alignItems: 'center', gap: 12, marginBottom: 32 },
|
||||
progressTrack: { height: 4, borderRadius: 2, flex: 1, overflow: 'hidden' },
|
||||
progressFill: { height: 4, borderRadius: 2 },
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import {
|
|||
d3roNativeFonts,
|
||||
d3roNativeNumerals,
|
||||
} from '@d3ro/ui-native';
|
||||
import { formatDurationClockFromMs } from '@d3ro/core/format';
|
||||
import { useI18n } from '@d3ro/i18n';
|
||||
import { useAuth } from '../lib/auth-context';
|
||||
import { ScreenHeader } from '../components/ScreenHeader';
|
||||
|
|
@ -77,10 +78,7 @@ function errorMessage(error: unknown, fallback: string): string {
|
|||
}
|
||||
|
||||
function formatTime(milliseconds: number): string {
|
||||
const totalSeconds = Math.floor(milliseconds / 1000);
|
||||
const minutes = Math.floor(totalSeconds / 60);
|
||||
const seconds = totalSeconds % 60;
|
||||
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
|
||||
return formatDurationClockFromMs(milliseconds, { padMinutes: true });
|
||||
}
|
||||
|
||||
type TranslationKey = Parameters<ReturnType<typeof useI18n>['t']>[0];
|
||||
|
|
@ -398,15 +396,23 @@ export default function RecordScreen({ route, navigation }: RecordScreenProps):
|
|||
recorderActiveRef.current = true;
|
||||
const meetingToBegin = armedMeetingIdRef.current;
|
||||
let meetingBegun = false;
|
||||
let recorder: RecorderSession | null = null;
|
||||
try {
|
||||
// Re-check on every start (not the cached handle) so a busy recorder is
|
||||
// reported before a meeting is marked as recording.
|
||||
const recorder = await audioRecorder.acquire('record');
|
||||
recorder = await audioRecorder.acquire('record');
|
||||
recorderSessionRef.current = recorder;
|
||||
const granted = await audioRecorder.requestPermission();
|
||||
if (!mountedRef.current) return;
|
||||
if (!mountedRef.current) {
|
||||
recorderActiveRef.current = false;
|
||||
if (recorderSessionRef.current === recorder) recorderSessionRef.current = null;
|
||||
await recorder.cancel().catch(() => undefined);
|
||||
return;
|
||||
}
|
||||
if (!granted) {
|
||||
recorderActiveRef.current = false;
|
||||
if (recorderSessionRef.current === recorder) recorderSessionRef.current = null;
|
||||
await recorder.cancel().catch(() => undefined);
|
||||
setError(t('mobile.rec.micDenied'));
|
||||
setState('error');
|
||||
return;
|
||||
|
|
@ -423,9 +429,19 @@ export default function RecordScreen({ route, navigation }: RecordScreenProps):
|
|||
meetingId: activeMeetingIdRef.current ?? undefined,
|
||||
onStateChange: applyRecorderSnapshot,
|
||||
});
|
||||
if (mountedRef.current) setState('recording');
|
||||
if (!mountedRef.current) {
|
||||
recorderActiveRef.current = false;
|
||||
if (recorderSessionRef.current === recorder) recorderSessionRef.current = null;
|
||||
await recorder.cancel().catch(() => undefined);
|
||||
return;
|
||||
}
|
||||
setState('recording');
|
||||
} catch (recordingError) {
|
||||
recorderActiveRef.current = false;
|
||||
if (recorder !== null) {
|
||||
if (recorderSessionRef.current === recorder) recorderSessionRef.current = null;
|
||||
await recorder.cancel().catch(() => undefined);
|
||||
}
|
||||
if (meetingBegun && user !== null && meetingToBegin !== null) {
|
||||
await failMeetingRecording(
|
||||
user.id,
|
||||
|
|
@ -1014,7 +1030,7 @@ type Palette = ReturnType<typeof useMobilePreferences>['palette'];
|
|||
function createStyles(palette: Palette) {
|
||||
return StyleSheet.create({
|
||||
container: { flex: 1, backgroundColor: palette.bg.app },
|
||||
content: { paddingBottom: 100 },
|
||||
content: { paddingBottom: 100, width: '100%', maxWidth: 720, alignSelf: 'center' },
|
||||
headerRight: { flexDirection: 'row', alignItems: 'center', gap: 8 },
|
||||
headerTime: { ...d3roNativeNumerals },
|
||||
meetingContext: { paddingHorizontal: 20, paddingTop: 12, gap: 4 },
|
||||
|
|
@ -1029,7 +1045,7 @@ function createStyles(palette: Palette) {
|
|||
errorText: { color: palette.tag.red },
|
||||
listeningRow: { flexDirection: 'row', alignItems: 'center', justifyContent: 'center', flexWrap: 'wrap', gap: 8, paddingHorizontal: 16, paddingBottom: 16 },
|
||||
listeningText: { letterSpacing: 2 },
|
||||
buttons: { paddingHorizontal: 20, paddingBottom: 16 },
|
||||
buttons: { paddingHorizontal: 20, paddingBottom: 16, width: '100%', maxWidth: 360, alignSelf: 'center' },
|
||||
buttonSpacer: { height: 12 },
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import { useState } from 'react'
|
||||
import { useEffect, useRef, useState } from 'react'
|
||||
import {
|
||||
Alert,
|
||||
Linking,
|
||||
|
|
@ -11,6 +11,7 @@ import {
|
|||
import { useNavigation } from '@react-navigation/native'
|
||||
import type { NativeStackNavigationProp } from '@react-navigation/native-stack'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { LOCALE_META } from '@d3ro/i18n/shared'
|
||||
import { SITE_URLS } from '@d3ro/core/web-urls'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { useEntitlement } from '../lib/entitlement-context'
|
||||
|
|
@ -75,6 +76,8 @@ export default function SettingsScreen(): React.ReactElement {
|
|||
updatePreferences,
|
||||
retrySync,
|
||||
} = useMobilePreferences()
|
||||
const mountedRef = useRef(true)
|
||||
const localeRequestRef = useRef(0)
|
||||
const [savingPreference, setSavingPreference] = useState<SavingPreference>(null)
|
||||
const [loggingOut, setLoggingOut] = useState(false)
|
||||
const [retrying, setRetrying] = useState(false)
|
||||
|
|
@ -83,6 +86,14 @@ export default function SettingsScreen(): React.ReactElement {
|
|||
const { currentDevice } = useDevice()
|
||||
const adminRole = currentAdminRole(user?.app_metadata)
|
||||
|
||||
useEffect(() => {
|
||||
mountedRef.current = true
|
||||
return () => {
|
||||
mountedRef.current = false
|
||||
localeRequestRef.current += 1
|
||||
}
|
||||
}, [])
|
||||
|
||||
const initials = user?.email
|
||||
? user.email.substring(0, 2).toUpperCase()
|
||||
: 'US'
|
||||
|
|
@ -95,23 +106,38 @@ export default function SettingsScreen(): React.ReactElement {
|
|||
async function persistPreference(
|
||||
key: Exclude<SavingPreference, null>,
|
||||
patch: MobilePreferencesPatch,
|
||||
): Promise<void> {
|
||||
if (savingPreference !== null) return
|
||||
): Promise<boolean> {
|
||||
if (savingPreference !== null) return false
|
||||
setSavingPreference(key)
|
||||
const result = await updatePreferences(patch)
|
||||
setSavingPreference(null)
|
||||
if (!result.localSaved) {
|
||||
let saved = false
|
||||
try {
|
||||
const result = await updatePreferences(patch)
|
||||
saved = result.localSaved
|
||||
} catch {
|
||||
saved = false
|
||||
} finally {
|
||||
if (mountedRef.current) setSavingPreference(null)
|
||||
}
|
||||
if (!mountedRef.current) return false
|
||||
if (!saved) {
|
||||
Alert.alert(
|
||||
t('mobile.preferences.saveFailedTitle'),
|
||||
t('mobile.preferences.cacheWriteError'),
|
||||
)
|
||||
}
|
||||
return saved
|
||||
}
|
||||
|
||||
async function applyLocaleSelection(nextLocale: SupportedMobileLocale): Promise<void> {
|
||||
const request = ++localeRequestRef.current
|
||||
const saved = await persistPreference('locale', { locale: nextLocale })
|
||||
if (!saved || !mountedRef.current || localeRequestRef.current !== request) return
|
||||
setLocale(nextLocale)
|
||||
}
|
||||
|
||||
function selectLocale(nextLocale: SupportedMobileLocale): void {
|
||||
if (locale === nextLocale || savingPreference !== null) return
|
||||
setLocale(nextLocale)
|
||||
void persistPreference('locale', { locale: nextLocale })
|
||||
void applyLocaleSelection(nextLocale)
|
||||
}
|
||||
|
||||
async function performLogout(): Promise<void> {
|
||||
|
|
@ -124,9 +150,11 @@ export default function SettingsScreen(): React.ReactElement {
|
|||
purgeLocalSession,
|
||||
})
|
||||
} catch {
|
||||
Alert.alert(t('mobile.auth.errorTitle'), t('mobile.auth.logoutFailed'))
|
||||
if (mountedRef.current) {
|
||||
Alert.alert(t('mobile.auth.errorTitle'), t('mobile.auth.logoutFailed'))
|
||||
}
|
||||
} finally {
|
||||
setLoggingOut(false)
|
||||
if (mountedRef.current) setLoggingOut(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,13 +172,16 @@ export default function SettingsScreen(): React.ReactElement {
|
|||
async function handleRetry(): Promise<void> {
|
||||
if (retrying) return
|
||||
setRetrying(true)
|
||||
await retrySync()
|
||||
setRetrying(false)
|
||||
try {
|
||||
await retrySync()
|
||||
} finally {
|
||||
if (mountedRef.current) setRetrying(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function openAdPrivacyOptions(): Promise<void> {
|
||||
const opened = await mobileAds.showPrivacyOptions()
|
||||
if (!opened) {
|
||||
if (!opened && mountedRef.current) {
|
||||
Alert.alert(
|
||||
t('mobile.set.adPrivacy'),
|
||||
t('mobile.set.adPrivacyUnavailable'),
|
||||
|
|
@ -326,24 +357,33 @@ export default function SettingsScreen(): React.ReactElement {
|
|||
description={t('mobile.set.languageDesc')}
|
||||
/>
|
||||
<View
|
||||
style={styles.segmentRow}
|
||||
style={styles.localeGrid}
|
||||
accessibilityRole="radiogroup"
|
||||
accessibilityLabel={t('mobile.set.language')}
|
||||
>
|
||||
<SegmentOption
|
||||
label="한국어"
|
||||
selected={locale === 'ko'}
|
||||
disabled={savingPreference !== null}
|
||||
testID="settings-language-ko"
|
||||
onPress={() => selectLocale('ko')}
|
||||
/>
|
||||
<SegmentOption
|
||||
label="English"
|
||||
selected={locale === 'en'}
|
||||
disabled={savingPreference !== null}
|
||||
testID="settings-language-en"
|
||||
onPress={() => selectLocale('en')}
|
||||
/>
|
||||
{LOCALE_META.map((item) => (
|
||||
<Pressable
|
||||
key={item.code}
|
||||
accessibilityRole="radio"
|
||||
accessibilityState={{ selected: locale === item.code, disabled: savingPreference !== null }}
|
||||
accessibilityLabel={item.nativeName}
|
||||
disabled={savingPreference !== null}
|
||||
testID={`settings-language-${item.code}`}
|
||||
onPress={() => selectLocale(item.code)}
|
||||
style={({ pressed }) => [
|
||||
styles.localeOption,
|
||||
{
|
||||
borderColor: locale === item.code ? palette.accent.main : palette.border.default,
|
||||
backgroundColor: locale === item.code ? palette.accent.dim : palette.bg.inset,
|
||||
opacity: savingPreference !== null ? 0.5 : pressed ? 0.72 : 1,
|
||||
},
|
||||
]}
|
||||
>
|
||||
<ThemeText variant="small" color={locale === item.code ? 'accent' : 'primary'}>
|
||||
{item.nativeName}
|
||||
</ThemeText>
|
||||
</Pressable>
|
||||
))}
|
||||
</View>
|
||||
</View>
|
||||
</ThemeCard>
|
||||
|
|
@ -760,6 +800,17 @@ const styles = StyleSheet.create({
|
|||
settingHeader: { gap: 4, padding: 15, paddingBottom: 10 },
|
||||
settingBlock: { borderTopWidth: 1, marginTop: 15, paddingTop: 2 },
|
||||
segmentRow: { flexDirection: 'row', gap: 8, paddingHorizontal: 15, paddingBottom: 15 },
|
||||
localeGrid: { flexDirection: 'row', flexWrap: 'wrap', gap: 8, paddingHorizontal: 15, paddingBottom: 15 },
|
||||
localeOption: {
|
||||
minHeight: 48,
|
||||
minWidth: '30%',
|
||||
flexGrow: 1,
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
borderWidth: 1,
|
||||
borderRadius: 9,
|
||||
paddingHorizontal: 8,
|
||||
},
|
||||
segmentOption: {
|
||||
minHeight: 48,
|
||||
flex: 1,
|
||||
|
|
|
|||
|
|
@ -14,10 +14,12 @@ import {
|
|||
import { useFocusEffect } from '@react-navigation/native'
|
||||
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
||||
import { useI18n } from '@d3ro/i18n'
|
||||
import { formatDurationClockFromMs } from '@d3ro/core/format'
|
||||
import { ThemeButton, ThemeText } from '../theme/themed-components'
|
||||
import { useAuth } from '../lib/auth-context'
|
||||
import { createLogger } from '../lib/logger'
|
||||
import { useMobilePreferences } from '../lib/preferences-context'
|
||||
import { toSpeechLanguageTag } from '../lib/locale-speech'
|
||||
import {
|
||||
audioRecorder,
|
||||
type RecordedAudio,
|
||||
|
|
@ -102,12 +104,8 @@ function transcriptionErrorCode(error: unknown): TalkErrorCode {
|
|||
}
|
||||
}
|
||||
|
||||
function formatDuration(durationMs: number): string {
|
||||
const seconds = Math.max(0, Math.floor(durationMs / 1000))
|
||||
return `${Math.floor(seconds / 60).toString().padStart(2, '0')}:${(seconds % 60)
|
||||
.toString()
|
||||
.padStart(2, '0')}`
|
||||
}
|
||||
const formatDuration = (durationMs: number): string =>
|
||||
formatDurationClockFromMs(durationMs, { padMinutes: true })
|
||||
|
||||
function phaseTranslationKey(phase: TalkPhase) {
|
||||
switch (phase) {
|
||||
|
|
@ -147,13 +145,25 @@ export default function TalkScreen(): React.ReactElement {
|
|||
const sessionRef = useRef(session)
|
||||
sessionRef.current = session
|
||||
|
||||
const greetingContent = t('mobile.talk.greeting')
|
||||
const initialMessage = useMemo<TalkMessage>(() => ({
|
||||
id: 'welcome',
|
||||
role: 'assistant',
|
||||
content: t('mobile.talk.greeting'),
|
||||
content: greetingContent,
|
||||
createdAt: Date.now(),
|
||||
}), [t])
|
||||
}), [greetingContent])
|
||||
const [messages, setMessages] = useState<TalkMessage[]>(() => [initialMessage])
|
||||
|
||||
useEffect(() => {
|
||||
setMessages((current) => {
|
||||
if (current.length !== 1 || current[0].id !== 'welcome' || current[0].content === greetingContent) {
|
||||
return current
|
||||
}
|
||||
const next = [{ ...current[0], content: greetingContent }]
|
||||
messagesRef.current = next
|
||||
return next
|
||||
})
|
||||
}, [greetingContent])
|
||||
const [input, setInput] = useState('')
|
||||
const [phase, setPhase] = useState<TalkPhase>('idle')
|
||||
const [recordingProgress, setRecordingProgress] = useState<RecordingProgress>({
|
||||
|
|
@ -360,7 +370,7 @@ export default function TalkScreen(): React.ReactElement {
|
|||
await playSpeech(
|
||||
assistantId,
|
||||
content,
|
||||
preferences.locale === 'en' ? 'en-US' : 'ko-KR',
|
||||
toSpeechLanguageTag(preferences.locale),
|
||||
)
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
@ -410,6 +420,7 @@ export default function TalkScreen(): React.ReactElement {
|
|||
if (recordingFinishingRef.current || !recordingActiveRef.current || recorderSession === null) return
|
||||
recordingFinishingRef.current = true
|
||||
recordingActiveRef.current = false
|
||||
if (recorderSessionRef.current === recorderSession) recorderSessionRef.current = null
|
||||
|
||||
try {
|
||||
let recording: RecordedAudio
|
||||
|
|
@ -508,10 +519,20 @@ export default function TalkScreen(): React.ReactElement {
|
|||
// recording on the Record tab holds the microphone.
|
||||
recorderSession = await audioRecorder.acquire('talk')
|
||||
recorderSessionRef.current = recorderSession
|
||||
if (!isCurrentOperation(operationId)) return
|
||||
if (!isCurrentOperation(operationId)) {
|
||||
if (recorderSessionRef.current === recorderSession) recorderSessionRef.current = null
|
||||
await recorderSession.cancel().catch(() => undefined)
|
||||
return
|
||||
}
|
||||
const granted = await audioRecorder.requestPermission()
|
||||
if (!isCurrentOperation(operationId)) return
|
||||
if (!isCurrentOperation(operationId)) {
|
||||
if (recorderSessionRef.current === recorderSession) recorderSessionRef.current = null
|
||||
await recorderSession.cancel().catch(() => undefined)
|
||||
return
|
||||
}
|
||||
if (!granted) {
|
||||
if (recorderSessionRef.current === recorderSession) recorderSessionRef.current = null
|
||||
await recorderSession.cancel().catch(() => undefined)
|
||||
setErrorCode('MIC_PERMISSION_DENIED')
|
||||
return
|
||||
}
|
||||
|
|
@ -520,6 +541,7 @@ export default function TalkScreen(): React.ReactElement {
|
|||
if (isCurrentOperation(operationId)) setRecordingProgress(progress)
|
||||
})
|
||||
if (!isCurrentOperation(operationId)) {
|
||||
if (recorderSessionRef.current === recorderSession) recorderSessionRef.current = null
|
||||
await recorderSession.cancel().catch(() => undefined)
|
||||
return
|
||||
}
|
||||
|
|
@ -533,7 +555,10 @@ export default function TalkScreen(): React.ReactElement {
|
|||
}
|
||||
// A session only discards a capture Talk holds; when acquisition failed
|
||||
// there is nothing of Talk's to clean up.
|
||||
if (recorderSession !== null) await recorderSession.cancel().catch(() => undefined)
|
||||
if (recorderSession !== null) {
|
||||
if (recorderSessionRef.current === recorderSession) recorderSessionRef.current = null
|
||||
await recorderSession.cancel().catch(() => undefined)
|
||||
}
|
||||
} finally {
|
||||
recordingStartingRef.current = false
|
||||
}
|
||||
|
|
@ -584,7 +609,7 @@ export default function TalkScreen(): React.ReactElement {
|
|||
text: preferences.locale === 'en'
|
||||
? 'Mobile voice transcription verified'
|
||||
: '모바일 음성 전사 검증',
|
||||
languageTag: preferences.locale === 'en' ? 'en-US' : 'ko-KR',
|
||||
languageTag: toSpeechLanguageTag(preferences.locale),
|
||||
})
|
||||
if (!isCurrentOperation(operationId)) {
|
||||
await fixture.dispose()
|
||||
|
|
@ -640,7 +665,7 @@ export default function TalkScreen(): React.ReactElement {
|
|||
void playSpeech(
|
||||
message.id,
|
||||
message.content,
|
||||
preferences.locale === 'en' ? 'en-US' : 'ko-KR',
|
||||
toSpeechLanguageTag(preferences.locale),
|
||||
)
|
||||
}, [playSpeech, preferences.locale, speakingMessageId, stopSpeech])
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import {
|
|||
} from 'react-native'
|
||||
import { useIsFocused } from '@react-navigation/native'
|
||||
import { useI18n, type TranslationKey } from '@d3ro/i18n'
|
||||
import { ACTION_BUTTON_MAX_WIDTH_DP, useResponsiveLayout } from '@d3ro/ui-native'
|
||||
import type {
|
||||
DictationTemplateField,
|
||||
DocumentTemplateType,
|
||||
|
|
@ -136,6 +137,7 @@ export default function TemplatesScreen({
|
|||
const { t } = useI18n()
|
||||
const { user } = useAuth()
|
||||
const { palette } = useMobilePreferences()
|
||||
const { gridColumns, wideContentMaxWidth } = useResponsiveLayout()
|
||||
const styles = useMemo(() => createStyles(palette), [palette])
|
||||
const generation = useRef(0)
|
||||
const realtimeTimer = useRef<ReturnType<typeof setTimeout> | null>(null)
|
||||
|
|
@ -335,7 +337,11 @@ export default function TemplatesScreen({
|
|||
const busy = busyId === item.id
|
||||
return (
|
||||
<ThemeCard
|
||||
style={[styles.card, selected && styles.cardSelected]}
|
||||
style={[
|
||||
styles.card,
|
||||
gridColumns > 1 && styles.cardGridItem,
|
||||
selected && styles.cardSelected,
|
||||
]}
|
||||
testID={`template-${item.id}`}
|
||||
>
|
||||
<View style={styles.cardHeader}>
|
||||
|
|
@ -390,7 +396,7 @@ export default function TemplatesScreen({
|
|||
</View>
|
||||
</ThemeCard>
|
||||
)
|
||||
}, [busyId, choose, confirmDelete, selections, styles, t])
|
||||
}, [busyId, choose, confirmDelete, gridColumns, selections, styles, t])
|
||||
|
||||
const empty = loading ? (
|
||||
<View style={styles.center} testID="templates-loading">
|
||||
|
|
@ -426,7 +432,7 @@ export default function TemplatesScreen({
|
|||
<ThemeText variant="small" color="muted">{t('mobile.templates.realtimeWaiting')}</ThemeText>
|
||||
</View>
|
||||
)}
|
||||
<View style={styles.controls}>
|
||||
<View style={[styles.controls, { maxWidth: wideContentMaxWidth }]}>
|
||||
<View style={styles.tabs} accessibilityRole="tablist">
|
||||
{(['dictation', 'meeting_document'] as const).map((value) => {
|
||||
const active = value === kind
|
||||
|
|
@ -463,10 +469,15 @@ export default function TemplatesScreen({
|
|||
</View>
|
||||
)}
|
||||
<FlatList
|
||||
key={`templates-cols-${gridColumns}`}
|
||||
data={templates}
|
||||
numColumns={gridColumns}
|
||||
columnWrapperStyle={gridColumns > 1 ? styles.columnRow : undefined}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={renderTemplate}
|
||||
contentContainerStyle={templates.length === 0 ? styles.emptyList : styles.list}
|
||||
contentContainerStyle={templates.length === 0
|
||||
? [styles.emptyList, { maxWidth: wideContentMaxWidth }]
|
||||
: [styles.list, { maxWidth: wideContentMaxWidth }]}
|
||||
keyboardShouldPersistTaps="handled"
|
||||
refreshControl={(
|
||||
<RefreshControl
|
||||
|
|
@ -678,24 +689,26 @@ function createStyles(palette: Palette): ReturnType<typeof StyleSheet.create> {
|
|||
},
|
||||
headerText: { flex: 1, gap: 4 },
|
||||
banner: { paddingHorizontal: 20, paddingVertical: 8, backgroundColor: palette.accent.dim },
|
||||
controls: { padding: 16, gap: 10, borderBottomWidth: 1, borderBottomColor: palette.border.subtle },
|
||||
controls: { padding: 16, width: '100%', alignSelf: 'center', gap: 10, borderBottomWidth: 1, borderBottomColor: palette.border.subtle },
|
||||
tabs: { flexDirection: 'row', gap: 8 },
|
||||
tab: { flex: 1, minHeight: 48, alignItems: 'center', justifyContent: 'center', borderRadius: 9, borderWidth: 1, borderColor: palette.border.default },
|
||||
tabActive: { backgroundColor: palette.accent.main, borderColor: palette.accent.main },
|
||||
input: { minHeight: 48, borderWidth: 1, borderColor: palette.border.default, borderRadius: 10, backgroundColor: palette.bg.inset, color: palette.text.primary, paddingHorizontal: 12, fontSize: 14 },
|
||||
inlineError: { padding: 12, flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 10, borderBottomWidth: 1, borderBottomColor: palette.tag.red },
|
||||
list: { padding: 16, gap: 12, paddingBottom: 36 },
|
||||
emptyList: { flexGrow: 1 },
|
||||
inlineError: { padding: 12, width: '100%', alignSelf: 'center', flexDirection: 'row', alignItems: 'center', justifyContent: 'space-between', gap: 10, borderBottomWidth: 1, borderBottomColor: palette.tag.red },
|
||||
list: { padding: 16, gap: 12, paddingBottom: 36, width: '100%', alignSelf: 'center' },
|
||||
columnRow: { gap: 12 },
|
||||
emptyList: { flexGrow: 1, width: '100%', alignSelf: 'center' },
|
||||
center: { flex: 1, minHeight: 260, alignItems: 'center', justifyContent: 'center', gap: 14, padding: 32 },
|
||||
centerText: { textAlign: 'center' },
|
||||
card: { gap: 12 },
|
||||
cardGridItem: { flex: 1 },
|
||||
cardSelected: { borderColor: palette.accent.main, borderWidth: 1 },
|
||||
cardHeader: { flexDirection: 'row', alignItems: 'flex-start', gap: 10 },
|
||||
cardTitle: { flex: 1, gap: 5 },
|
||||
titleRow: { flexDirection: 'row', flexWrap: 'wrap', alignItems: 'center', gap: 8 },
|
||||
badge: { paddingHorizontal: 8, paddingVertical: 3, borderRadius: 999, backgroundColor: palette.accent.dim },
|
||||
actions: { flexDirection: 'row', alignItems: 'center', gap: 8 },
|
||||
flexButton: { flex: 1 },
|
||||
flexButton: { flex: 1, maxWidth: ACTION_BUTTON_MAX_WIDTH_DP },
|
||||
modalBackdrop: { flex: 1, justifyContent: 'center', padding: 16, backgroundColor: palette.scrim },
|
||||
modalList: { width: '100%', maxWidth: 680, maxHeight: '94%', alignSelf: 'center', borderRadius: 14, backgroundColor: palette.bg.card },
|
||||
modalCard: { padding: 18, gap: 14 },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue