Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| cff421bc53 | |||
| bca925d385 | |||
| 9abde89805 | |||
| ea4f639fcb |
@@ -79,8 +79,8 @@ android {
|
|||||||
applicationId "com.ariacockpit"
|
applicationId "com.ariacockpit"
|
||||||
minSdkVersion rootProject.ext.minSdkVersion
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
targetSdkVersion rootProject.ext.targetSdkVersion
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
versionCode 303
|
versionCode 305
|
||||||
versionName "0.0.3.3"
|
versionName "0.0.3.5"
|
||||||
// Fallback fuer Libraries mit Product Flavors
|
// Fallback fuer Libraries mit Product Flavors
|
||||||
missingDimensionStrategy 'react-native-camera', 'general'
|
missingDimensionStrategy 'react-native-camera', 'general'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "aria-cockpit",
|
"name": "aria-cockpit",
|
||||||
"version": "0.0.3.3",
|
"version": "0.0.3.5",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"android": "react-native run-android",
|
"android": "react-native run-android",
|
||||||
|
|||||||
@@ -373,13 +373,26 @@ const ChatScreen: React.FC = () => {
|
|||||||
const shouldAutoScroll = useRef(true);
|
const shouldAutoScroll = useRef(true);
|
||||||
const lastMessageCount = useRef(0);
|
const lastMessageCount = useRef(0);
|
||||||
|
|
||||||
// Bei neuen Nachrichten: sofort nach unten
|
// Bei neuen Nachrichten oder App-Start: nach unten springen
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (messages.length > lastMessageCount.current && shouldAutoScroll.current) {
|
if (messages.length > 0 && shouldAutoScroll.current) {
|
||||||
// Kurzer Delay damit FlatList rendern kann
|
const isInitial = lastMessageCount.current === 0;
|
||||||
setTimeout(() => {
|
const scrollToBottom = () => {
|
||||||
flatListRef.current?.scrollToEnd({ animated: messages.length > lastMessageCount.current + 1 ? false : true });
|
try {
|
||||||
}, 150);
|
flatListRef.current?.scrollToIndex({
|
||||||
|
index: messages.length - 1,
|
||||||
|
animated: !isInitial,
|
||||||
|
viewPosition: 1, // 1 = Item am unteren Rand
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
// Fallback wenn Index nicht berechnet werden kann
|
||||||
|
flatListRef.current?.scrollToEnd({ animated: !isInitial });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const delays = isInitial ? [200, 500, 1000] : [150];
|
||||||
|
for (const delay of delays) {
|
||||||
|
setTimeout(scrollToBottom, delay);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
lastMessageCount.current = messages.length;
|
lastMessageCount.current = messages.length;
|
||||||
}, [messages]);
|
}, [messages]);
|
||||||
@@ -687,6 +700,11 @@ const ChatScreen: React.FC = () => {
|
|||||||
showsVerticalScrollIndicator={false}
|
showsVerticalScrollIndicator={false}
|
||||||
onScrollBeginDrag={handleScrollBeginDrag}
|
onScrollBeginDrag={handleScrollBeginDrag}
|
||||||
onScrollEndDrag={handleScrollEndDrag}
|
onScrollEndDrag={handleScrollEndDrag}
|
||||||
|
onScrollToIndexFailed={(info) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
flatListRef.current?.scrollToEnd({ animated: false });
|
||||||
|
}, 200);
|
||||||
|
}}
|
||||||
ListEmptyComponent={
|
ListEmptyComponent={
|
||||||
<View style={styles.emptyContainer}>
|
<View style={styles.emptyContainer}>
|
||||||
<Text style={styles.emptyIcon}>{'\uD83E\uDD16'}</Text>
|
<Text style={styles.emptyIcon}>{'\uD83E\uDD16'}</Text>
|
||||||
|
|||||||
Reference in New Issue
Block a user