-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #78 from mbret/develop
release
- Loading branch information
Showing
19 changed files
with
584 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useMutation } from "reactjrx" | ||
import { getLatestDatabase } from "../rxdb/useCreateDatabase" | ||
import { from, mergeMap } from "rxjs" | ||
import { MangoQuery } from "rxdb" | ||
import { BookDocType } from "@oboku/shared" | ||
|
||
export const useUpdateBooks = () => { | ||
return useMutation({ | ||
mutationFn: ({ | ||
queryObj, | ||
updateObj | ||
}: { | ||
queryObj: MangoQuery<BookDocType> | ||
updateObj: any | ||
}) => | ||
getLatestDatabase().pipe( | ||
mergeMap((database) => { | ||
const query = database.book.find(queryObj) | ||
|
||
return from(query.update(updateObj)) | ||
}) | ||
) | ||
}) | ||
} |
234 changes: 0 additions & 234 deletions
234
packages/web/src/collections/CollectionActionsDrawer.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useMutation } from "reactjrx" | ||
import { getLatestDatabase } from "../rxdb/useCreateDatabase" | ||
import { from, mergeMap } from "rxjs" | ||
import { useUpdateBooks } from "../books/useUpdateBooks" | ||
|
||
export const useUpdateCollectionBooks = () => { | ||
const { mutateAsync: updateBooks } = useUpdateBooks() | ||
|
||
return useMutation({ | ||
mutationFn: ({ | ||
id, | ||
updateObj | ||
}: { | ||
id: string | ||
updateObj: any | ||
}) => | ||
getLatestDatabase().pipe( | ||
mergeMap((database) => | ||
from( | ||
database.obokucollection | ||
.findOne({ | ||
selector: { | ||
_id: { | ||
$eq: id | ||
} | ||
} | ||
}) | ||
.exec() | ||
) | ||
), | ||
mergeMap((collection) => { | ||
if (!collection) throw new Error("no item") | ||
|
||
return from( | ||
updateBooks({ | ||
queryObj: { | ||
selector: { | ||
_id: { | ||
$in: collection.books | ||
} | ||
} | ||
}, | ||
updateObj | ||
}) | ||
) | ||
}) | ||
) | ||
}) | ||
} |
Oops, something went wrong.