collection fix
This commit is contained in:
@@ -126,7 +126,7 @@ public class CollectionService {
|
||||
savedCollection = findById(savedCollection.getId());
|
||||
}
|
||||
|
||||
// Collections are not indexed in search engine yet
|
||||
searchServiceAdapter.indexCollection(savedCollection);
|
||||
|
||||
logger.info("Created collection: {} with {} stories", name, initialStoryIds != null ? initialStoryIds.size() : 0);
|
||||
return savedCollection;
|
||||
@@ -155,8 +155,7 @@ public class CollectionService {
|
||||
}
|
||||
|
||||
Collection savedCollection = collectionRepository.save(collection);
|
||||
|
||||
// Collections are not indexed in search engine yet
|
||||
searchServiceAdapter.updateCollection(findById(savedCollection.getId()));
|
||||
|
||||
logger.info("Updated collection: {}", id);
|
||||
return savedCollection;
|
||||
@@ -167,9 +166,7 @@ public class CollectionService {
|
||||
*/
|
||||
public void deleteCollection(UUID id) {
|
||||
Collection collection = findByIdBasic(id);
|
||||
|
||||
// Collections are not indexed in search engine yet
|
||||
|
||||
searchServiceAdapter.deleteCollection(id);
|
||||
collectionRepository.delete(collection);
|
||||
logger.info("Deleted collection: {}", id);
|
||||
}
|
||||
@@ -182,8 +179,7 @@ public class CollectionService {
|
||||
collection.setIsArchived(archived);
|
||||
|
||||
Collection savedCollection = collectionRepository.save(collection);
|
||||
|
||||
// Collections are not indexed in search engine yet
|
||||
searchServiceAdapter.updateCollection(findById(savedCollection.getId()));
|
||||
|
||||
logger.info("{} collection: {}", archived ? "Archived" : "Unarchived", id);
|
||||
return savedCollection;
|
||||
@@ -227,8 +223,7 @@ public class CollectionService {
|
||||
position += 1000; // Gap-based positioning
|
||||
}
|
||||
|
||||
// Update collection in Typesense
|
||||
// Collections are not indexed in search engine yet
|
||||
searchServiceAdapter.updateCollection(findById(collectionId));
|
||||
|
||||
long totalStories = collectionStoryRepository.countByCollectionId(collectionId);
|
||||
|
||||
@@ -251,9 +246,7 @@ public class CollectionService {
|
||||
|
||||
CollectionStory collectionStory = collectionStoryRepository.findByCollectionIdAndStoryId(collectionId, storyId);
|
||||
collectionStoryRepository.delete(collectionStory);
|
||||
|
||||
// Update collection in Typesense
|
||||
// Collections are not indexed in search engine yet
|
||||
searchServiceAdapter.updateCollection(findById(collectionId));
|
||||
|
||||
logger.info("Removed story {} from collection {}", storyId, collectionId);
|
||||
}
|
||||
@@ -285,8 +278,7 @@ public class CollectionService {
|
||||
collectionStoryRepository.updatePosition(collectionId, storyId, position * 1000); // Gap-based positioning
|
||||
}
|
||||
|
||||
// Update collection in Typesense
|
||||
// Collections are not indexed in search engine yet
|
||||
searchServiceAdapter.updateCollection(findById(collectionId));
|
||||
|
||||
logger.info("Reordered {} stories in collection {}", storyOrders.size(), collectionId);
|
||||
}
|
||||
|
||||
@@ -110,6 +110,7 @@ export default function EditCollectionPage() {
|
||||
description: collection.description,
|
||||
tags: collection.tags?.map(tag => tag.name) || [],
|
||||
storyIds: collection.collectionStories?.map(cs => cs.story.id) || [],
|
||||
stories: collection.collectionStories?.map(cs => cs.story) || [],
|
||||
coverImagePath: collection.coverImagePath,
|
||||
};
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ interface CollectionFormProps {
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
storyIds?: string[];
|
||||
stories?: Story[];
|
||||
coverImagePath?: string;
|
||||
};
|
||||
onSubmit: (data: {
|
||||
@@ -42,11 +43,12 @@ export default function CollectionForm({
|
||||
const [selectedStoryIds, setSelectedStoryIds] = useState<string[]>(initialData?.storyIds || []);
|
||||
const [coverImage, setCoverImage] = useState<File | null>(null);
|
||||
const [coverImagePreview, setCoverImagePreview] = useState<string | null>(null);
|
||||
// Pre-populate from initialData.stories to avoid a redundant search fetch
|
||||
const [selectedStories, setSelectedStories] = useState<Story[]>(initialData?.stories || []);
|
||||
|
||||
// Story selection state
|
||||
const [storySearchQuery, setStorySearchQuery] = useState('');
|
||||
const [availableStories, setAvailableStories] = useState<Story[]>([]);
|
||||
const [selectedStories, setSelectedStories] = useState<Story[]>([]);
|
||||
const [loadingStories, setLoadingStories] = useState(false);
|
||||
const [showStorySelection, setShowStorySelection] = useState(false);
|
||||
|
||||
@@ -93,26 +95,6 @@ export default function CollectionForm({
|
||||
}
|
||||
}, [storySearchQuery, showStorySelection]);
|
||||
|
||||
// Load selected stories data on mount
|
||||
useEffect(() => {
|
||||
if (selectedStoryIds.length > 0) {
|
||||
const loadSelectedStories = async () => {
|
||||
try {
|
||||
const result = await searchApi.search({
|
||||
query: '*',
|
||||
page: 0,
|
||||
size: 100,
|
||||
});
|
||||
const stories = result.results.filter(story => selectedStoryIds.includes(story.id));
|
||||
setSelectedStories(stories);
|
||||
} catch (error) {
|
||||
console.error('Failed to load selected stories:', error);
|
||||
}
|
||||
};
|
||||
loadSelectedStories();
|
||||
}
|
||||
}, [selectedStoryIds]);
|
||||
|
||||
const handleTagInputKeyDown = (e: React.KeyboardEvent) => {
|
||||
if (e.key === 'Enter' && tagInput.trim()) {
|
||||
e.preventDefault();
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user