Skip to content

Commit 6f2ec1f

Browse files
committed
style: apply consistent semicolons/formatting and minor style tidy across modules
1 parent 303cc6f commit 6f2ec1f

36 files changed

+2438
-2350
lines changed

src/components/AudioPlayer.tsx

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import React, { useState, useEffect, useRef, useMemo } from 'react'
2-
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native'
3-
import { AudioContext } from 'react-native-audio-api'
4-
import { useTheme } from '../contexts/ThemeContext'
1+
import React, { useState, useEffect, useRef, useMemo } from 'react';
2+
import { View, Text, StyleSheet, TouchableOpacity } from 'react-native';
3+
import { AudioContext } from 'react-native-audio-api';
4+
import { useTheme } from '../contexts/ThemeContext';
55

66
export const AudioPlayer = ({
77
audio,
@@ -10,16 +10,16 @@ export const AudioPlayer = ({
1010
audio: Float32Array
1111
sr: number
1212
}) => {
13-
const { theme } = useTheme()
14-
const ctxRef = useRef<AudioContext | null>(null)
15-
const [isPlaying, setIsPlaying] = useState(false)
16-
const [progress, setProgress] = useState(0)
17-
const [isPressed, setIsPressed] = useState(false)
18-
const duration = useMemo(() => audio.length / sr, [audio, sr])
13+
const { theme } = useTheme();
14+
const ctxRef = useRef<AudioContext | null>(null);
15+
const [isPlaying, setIsPlaying] = useState(false);
16+
const [progress, setProgress] = useState(0);
17+
const [isPressed, setIsPressed] = useState(false);
18+
const duration = useMemo(() => audio.length / sr, [audio, sr]);
1919
const progressPercentage = useMemo(
2020
() => (progress / duration) * 100,
2121
[progress, duration],
22-
)
22+
);
2323

2424
const styles = StyleSheet.create({
2525
container: {
@@ -95,39 +95,39 @@ export const AudioPlayer = ({
9595
marginTop: 4,
9696
fontVariant: ['tabular-nums'],
9797
},
98-
})
98+
});
9999

100100
useEffect(() => {
101101
if (isPlaying) {
102-
setProgress(0)
102+
setProgress(0);
103103
const interval = setInterval(() => {
104-
setProgress(ctxRef.current?.currentTime ?? 0)
105-
}, 10)
106-
ctxRef.current ??= new AudioContext()
107-
const audioBuffer = ctxRef.current.createBuffer(1, audio.length, sr)
108-
audioBuffer.copyToChannel(new Float32Array(audio), 0)
109-
const source = ctxRef.current.createBufferSource()
110-
source.buffer = audioBuffer
111-
source.connect(ctxRef.current.destination)
112-
source.start()
104+
setProgress(ctxRef.current?.currentTime ?? 0);
105+
}, 10);
106+
ctxRef.current ??= new AudioContext();
107+
const audioBuffer = ctxRef.current.createBuffer(1, audio.length, sr);
108+
audioBuffer.copyToChannel(new Float32Array(audio), 0);
109+
const source = ctxRef.current.createBufferSource();
110+
source.buffer = audioBuffer;
111+
source.connect(ctxRef.current.destination);
112+
source.start();
113113
source.onended = () => {
114-
clearInterval(interval)
115-
setIsPlaying(false)
116-
setProgress(duration)
117-
}
118-
return () => clearInterval(interval)
114+
clearInterval(interval);
115+
setIsPlaying(false);
116+
setProgress(duration);
117+
};
118+
return () => clearInterval(interval);
119119
} else {
120-
ctxRef.current?.close()
121-
ctxRef.current = null
122-
return () => {}
120+
ctxRef.current?.close();
121+
ctxRef.current = null;
122+
return () => {};
123123
}
124-
}, [isPlaying, audio, sr, duration])
124+
}, [isPlaying, audio, sr, duration]);
125125

126126
const formatTime = (seconds: number) => {
127-
const mins = Math.floor(seconds / 60)
128-
const secs = Math.floor(seconds % 60)
129-
return `${mins}:${secs.toString().padStart(2, '0')}`
130-
}
127+
const mins = Math.floor(seconds / 60);
128+
const secs = Math.floor(seconds % 60);
129+
return `${mins}:${secs.toString().padStart(2, '0')}`;
130+
};
131131

132132
return (
133133
<View style={styles.container}>
@@ -158,5 +158,5 @@ export const AudioPlayer = ({
158158
{isPlaying ? 'Playing...' : 'Ready to play'}
159159
</Text>
160160
</View>
161-
)
162-
}
161+
);
162+
};

src/components/BaseParameterModal.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { type ReactNode } from 'react'
1+
import React, { type ReactNode } from 'react';
22
import {
33
Modal,
44
View,
@@ -7,10 +7,10 @@ import {
77
StyleSheet,
88
ScrollView,
99
Platform,
10-
} from 'react-native'
11-
import { SafeAreaView } from 'react-native-safe-area-context'
12-
import { createThemedStyles } from '../styles/commonStyles'
13-
import { useTheme } from '../contexts/ThemeContext'
10+
} from 'react-native';
11+
import { SafeAreaView } from 'react-native-safe-area-context';
12+
import { createThemedStyles } from '../styles/commonStyles';
13+
import { useTheme } from '../contexts/ThemeContext';
1414

1515

1616
interface BaseParameterModalProps {
@@ -38,9 +38,9 @@ export default function BaseParameterModal({
3838
warningText = '',
3939
children,
4040
}: BaseParameterModalProps) {
41-
const { theme } = useTheme()
42-
const themedStyles = createThemedStyles(theme.colors)
43-
41+
const { theme } = useTheme();
42+
const themedStyles = createThemedStyles(theme.colors);
43+
4444
const styles = StyleSheet.create({
4545
container: themedStyles.container,
4646
header: {
@@ -112,7 +112,7 @@ export default function BaseParameterModal({
112112
fontWeight: '600',
113113
textAlign: 'center',
114114
},
115-
})
115+
});
116116
return (
117117
<Modal
118118
visible={visible}
@@ -154,5 +154,5 @@ export default function BaseParameterModal({
154154
</ScrollView>
155155
</SafeAreaView>
156156
</Modal>
157-
)
157+
);
158158
}

src/components/Bubble.tsx

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import React, { useContext, useState } from 'react'
2-
import type { ReactNode } from 'react'
3-
import { View, Text, TouchableOpacity, Image } from 'react-native'
4-
import Clipboard from '@react-native-clipboard/clipboard'
5-
import { ThemeContext, UserContext } from '@flyerhq/react-native-chat-ui'
6-
import type { MessageType } from '@flyerhq/react-native-chat-ui'
7-
import { useTheme } from '../contexts/ThemeContext'
1+
import React, { useContext, useState } from 'react';
2+
import type { ReactNode } from 'react';
3+
import { View, Text, TouchableOpacity, Image } from 'react-native';
4+
import Clipboard from '@react-native-clipboard/clipboard';
5+
import { ThemeContext, UserContext } from '@flyerhq/react-native-chat-ui';
6+
import type { MessageType } from '@flyerhq/react-native-chat-ui';
7+
import { useTheme } from '../contexts/ThemeContext';
88

99
export const Bubble = ({
1010
child,
@@ -13,51 +13,51 @@ export const Bubble = ({
1313
child: ReactNode
1414
message: MessageType.Any
1515
}) => {
16-
const { isDark } = useTheme()
17-
const theme = useContext(ThemeContext)
18-
const user = useContext(UserContext)
19-
const currentUserIsAuthor = user?.id === message.author.id
16+
const { isDark } = useTheme();
17+
const theme = useContext(ThemeContext);
18+
const user = useContext(UserContext);
19+
const currentUserIsAuthor = user?.id === message.author.id;
2020
const { copyable, timings, completionResult, partialCompletionResult } =
21-
message.metadata || {}
21+
message.metadata || {};
2222

23-
const [showReasoning, setShowReasoning] = useState(false)
24-
const [showToolCalls, setShowToolCalls] = useState(false)
23+
const [showReasoning, setShowReasoning] = useState(false);
24+
const [showToolCalls, setShowToolCalls] = useState(false);
2525

26-
const Container = copyable ? TouchableOpacity : View
26+
const Container = copyable ? TouchableOpacity : View;
2727

2828
// Theme-aware colors
29-
const overlayBackground = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)'
29+
const overlayBackground = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)';
3030
const sectionBackground = isDark
3131
? 'rgba(255,255,255,0.05)'
32-
: 'rgba(0,0,0,0.05)'
33-
const borderColor = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)'
32+
: 'rgba(0,0,0,0.05)';
33+
const borderColor = isDark ? 'rgba(255,255,255,0.1)' : 'rgba(0,0,0,0.1)';
3434
const textColor = (() => {
3535
if (currentUserIsAuthor) {
36-
return 'rgba(255,255,255,0.8)'
36+
return 'rgba(255,255,255,0.8)';
3737
}
38-
return isDark ? 'rgba(255,255,255,0.8)' : 'rgba(0,0,0,0.6)'
39-
})()
38+
return isDark ? 'rgba(255,255,255,0.8)' : 'rgba(0,0,0,0.6)';
39+
})();
4040
const contentTextColor = (() => {
4141
if (currentUserIsAuthor) {
42-
return 'rgba(255,255,255,0.9)'
42+
return 'rgba(255,255,255,0.9)';
4343
}
44-
return isDark ? 'rgba(255,255,255,0.9)' : 'rgba(0,0,0,0.8)'
45-
})()
44+
return isDark ? 'rgba(255,255,255,0.9)' : 'rgba(0,0,0,0.8)';
45+
})();
4646
const toolCallBackground = isDark
4747
? 'rgba(255,255,255,0.1)'
48-
: 'rgba(0,0,0,0.1)'
49-
const timingTextColor = isDark ? '#999' : '#ccc'
48+
: 'rgba(0,0,0,0.1)';
49+
const timingTextColor = isDark ? '#999' : '#ccc';
5050

5151
// Use partial data during streaming, fall back to final result
52-
const currentResult = partialCompletionResult || completionResult
53-
const hasReasoningContent = currentResult?.reasoning_content
52+
const currentResult = partialCompletionResult || completionResult;
53+
const hasReasoningContent = currentResult?.reasoning_content;
5454
const hasToolCalls =
55-
currentResult?.tool_calls && currentResult.tool_calls.length > 0
55+
currentResult?.tool_calls && currentResult.tool_calls.length > 0;
5656
// Check if we're in a streaming state (partial data available but no final content yet)
5757
const isStreamingReasoning =
58-
partialCompletionResult && partialCompletionResult?.reasoning_content
58+
partialCompletionResult && partialCompletionResult?.reasoning_content;
5959
const isStreamingToolCalls =
60-
partialCompletionResult && partialCompletionResult?.tool_calls
60+
partialCompletionResult && partialCompletionResult?.tool_calls;
6161

6262
return (
6363
<Container
@@ -77,8 +77,8 @@ export const Bubble = ({
7777
overflow: 'hidden',
7878
}}
7979
onPress={() => {
80-
if (message.type !== 'text') return
81-
Clipboard.setString(message.text)
80+
if (message.type !== 'text') {return;}
81+
Clipboard.setString(message.text);
8282
}}
8383
>
8484
{/* Show toggle button for reasoning if available */}
@@ -229,5 +229,5 @@ export const Bubble = ({
229229
</Text>
230230
)}
231231
</Container>
232-
)
233-
}
232+
);
233+
};

0 commit comments

Comments
 (0)