diff options
| author | MohamedBassem <me@mbassem.com> | 2024-08-25 00:48:37 +0300 |
|---|---|---|
| committer | MohamedBassem <me@mbassem.com> | 2024-08-25 00:52:15 +0300 |
| commit | d8cf7c17a2b0a437cf4a2f983f5ab48fba775a64 (patch) | |
| tree | 7732dbb08a5272b11a5e4c8c638b25110c65c33a /packages/shared-react | |
| parent | 6fba4aac850c831365e61954c49f653401da33bb (diff) | |
| download | karakeep-d8cf7c17a2b0a437cf4a2f983f5ab48fba775a64.tar.zst | |
feature(mobile): Allow editing notes from the mobile app
Diffstat (limited to 'packages/shared-react')
| -rw-r--r-- | packages/shared-react/hooks/bookmarks.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/packages/shared-react/hooks/bookmarks.ts b/packages/shared-react/hooks/bookmarks.ts index 402bfae4..43f97fc1 100644 --- a/packages/shared-react/hooks/bookmarks.ts +++ b/packages/shared-react/hooks/bookmarks.ts @@ -21,6 +21,20 @@ export function useAutoRefreshingBookmarkQuery( }); } +export function useCreateBookmark( + ...opts: Parameters<typeof api.bookmarks.createBookmark.useMutation> +) { + const apiUtils = api.useUtils(); + return api.bookmarks.createBookmark.useMutation({ + ...opts[0], + onSuccess: (res, req, meta) => { + apiUtils.bookmarks.getBookmarks.invalidate(); + apiUtils.bookmarks.searchBookmarks.invalidate(); + return opts[0]?.onSuccess?.(res, req, meta); + }, + }); +} + export function useCreateBookmarkWithPostHook( ...opts: Parameters<typeof api.bookmarks.createBookmark.useMutation> ) { @@ -67,6 +81,21 @@ export function useUpdateBookmark( }); } +export function useUpdateBookmarkText( + ...opts: Parameters<typeof api.bookmarks.updateBookmarkText.useMutation> +) { + const apiUtils = api.useUtils(); + return api.bookmarks.updateBookmarkText.useMutation({ + ...opts[0], + onSuccess: (res, req, meta) => { + apiUtils.bookmarks.getBookmarks.invalidate(); + apiUtils.bookmarks.searchBookmarks.invalidate(); + apiUtils.bookmarks.getBookmark.invalidate({ bookmarkId: req.bookmarkId }); + return opts[0]?.onSuccess?.(res, req, meta); + }, + }); +} + export function useRecrawlBookmark( ...opts: Parameters<typeof api.bookmarks.recrawlBookmark.useMutation> ) { |
