socket in client, new set of icons

This commit is contained in:
michalcourson
2026-02-28 11:17:37 -05:00
parent 69c9d80a82
commit ab57d8ef22
43 changed files with 114 additions and 81 deletions

View File

@ -67,32 +67,11 @@ const metadataSlice = createSlice({
targetState.clips.push(clip);
}
},
addNewClips(state, action) {
const { collections } = action.payload;
Object.keys(collections).forEach((collection) => {
const collectionState = state.collections.find(
(col) => col.name === collection,
);
if (!collectionState) {
state.collections.push({
name: collection,
id: Date.now(),
clips: [],
});
}
const existingFilenames = new Set(
state.collections
.find((col) => col.name === collection)
?.clips.map((clip) => clip.filename) || [],
);
const newClips = collections[collection].filter(
(clip: ClipMetadata) => !existingFilenames.has(clip.filename),
);
// const collectionState = state.collections.find(
// (col) => col.name === collection,
// );
if (collectionState) {
collectionState.clips.push(...newClips);
addNewClip(state, action) {
const { clip } = action.payload;
state.collections.forEach((collection) => {
if (collection.name === 'Uncategorized') {
collection.clips.push(clip);
}
});
},
@ -113,6 +92,6 @@ export type RootState = ReturnType<AppStore['getState']>;
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
export type AppDispatch = AppStore['dispatch'];
export const { setCollections, addNewClips, addCollection } =
export const { setCollections, addNewClip, addCollection } =
metadataSlice.actions;
export default metadataSlice.reducer;