mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-20 13:21:18 +02:00
- Add uload project with apps/web structure
- Reorganize from flat to monorepo structure
- Remove PocketBase binary and local data
- Update to pnpm and @uload/web namespace
- Add picture project to monorepo
- Remove embedded git repository
- Unify all package names to @{project}/{app} schema:
- @maerchenzauber/* (was @storyteller/*)
- @manacore/* (was manacore-*, manacore)
- @manadeck/* (was web, backend, manadeck)
- @memoro/* (was memoro-web, landing, memoro)
- @picture/* (already unified)
- @uload/web
- Add convenient dev scripts for all apps:
- pnpm dev:{project}:web
- pnpm dev:{project}:landing
- pnpm dev:{project}:mobile
- pnpm dev:{project}:backend
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
48 lines
1.6 KiB
TypeScript
48 lines
1.6 KiB
TypeScript
import { useCallback, RefObject } from 'react';
|
|
import { FlatList } from 'react-native';
|
|
import { useFocusEffect } from 'expo-router';
|
|
import { ImageItem } from '~/types/gallery';
|
|
import { SCROLL_TO_INDEX_DELAY, CLEAR_LAST_VIEWED_DELAY } from '~/constants/gallery';
|
|
|
|
type UseScrollRestorationProps = {
|
|
flatListRef: RefObject<FlatList>;
|
|
lastViewedImageId: string | null;
|
|
filteredImages: ImageItem[];
|
|
onClearLastViewed: () => void;
|
|
};
|
|
|
|
export function useScrollRestoration({
|
|
flatListRef,
|
|
lastViewedImageId,
|
|
filteredImages,
|
|
onClearLastViewed,
|
|
}: UseScrollRestorationProps) {
|
|
// Scroll to last viewed image when screen comes into focus
|
|
useFocusEffect(
|
|
useCallback(() => {
|
|
if (!lastViewedImageId || filteredImages.length === 0) return;
|
|
|
|
const index = filteredImages.findIndex(img => img.id === lastViewedImageId);
|
|
if (index === -1 || !flatListRef.current) return;
|
|
|
|
// Use scrollToIndex for grid layouts
|
|
setTimeout(() => {
|
|
try {
|
|
flatListRef.current?.scrollToIndex({
|
|
index,
|
|
animated: false, // No animation for instant appearance
|
|
viewPosition: 0.5, // Center the item
|
|
});
|
|
} catch (error) {
|
|
// Fallback if scrollToIndex fails
|
|
console.log('ScrollToIndex failed, trying offset method');
|
|
}
|
|
}, SCROLL_TO_INDEX_DELAY);
|
|
|
|
// Clear the last viewed ID after scrolling
|
|
setTimeout(() => {
|
|
onClearLastViewed();
|
|
}, CLEAR_LAST_VIEWED_DELAY);
|
|
}, [lastViewedImageId, filteredImages, flatListRef, onClearLastViewed])
|
|
);
|
|
}
|