1
0
Fork 0
mirror of https://github.com/pawelmalak/flame.git synced 2025-08-07 11:55:17 +02:00

Update bookmark. Changes to CSS. Changes to WeatherJob

This commit is contained in:
unknown 2021-06-01 14:54:47 +02:00
parent 519b6d0746
commit 96aa1f7d69
11 changed files with 165 additions and 36 deletions

View file

@ -107,8 +107,38 @@ const deleteBookmark = (state: State, action: Action): State => {
}
const updateBookmark = (state: State, action: Action): State => {
const { bookmark, categoryWasChanged } = action.payload;
const tmpCategories = [...state.categories];
let categoryIndex = state.categories.findIndex((category: Category) => category.id === bookmark.categoryId);
let bookmarkIndex = state.categories[categoryIndex].bookmarks.findIndex((bookmark: Bookmark) => bookmark.id === bookmark.id);
// if (categoryWasChanged) {
// const categoryInUpdate = tmpCategories.find((category: Category) => category.id === bookmark.categoryId);
// if (categoryInUpdate) {
// categoryInUpdate.bookmarks = categoryInUpdate.bookmarks.filter((_bookmark: Bookmark) => _bookmark.id === bookmark.id);
// }
// console.log(categoryInUpdate);
// }
return {
...state
...state,
categories: [
...state.categories.slice(0, categoryIndex),
{
...state.categories[categoryIndex],
bookmarks: [
...state.categories[categoryIndex].bookmarks.slice(0, bookmarkIndex),
{
...bookmark
},
...state.categories[categoryIndex].bookmarks.slice(bookmarkIndex + 1)
]
},
...state.categories.slice(categoryIndex + 1)
]
}
}