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:
parent
519b6d0746
commit
96aa1f7d69
11 changed files with 165 additions and 36 deletions
|
@ -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)
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue