-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: implement gallery drafts hook #315
Conversation
…o feat/persist-gallery-drafts
…o feat/persist-gallery-drafts
return allDrafts.filter((draft) => draft.walletAddress === wallet?.address); | ||
}; | ||
|
||
const setDraftCover = (image: ArrayBuffer | null, type: string | null): void => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to use ArrayBuffer
to store images as Safari cannot store Blob
s
If you are storing large, user-generated files such as images or videos, then you may try to store them as File or Blob objects. This will work on some platforms but fail on others. Safari on iOS, in particular, cannot store Blobs in IndexedDB.
Luckily it is not too difficult to convert a Blob into an ArrayBuffer, and vice versa. Storing ArrayBuffers in IndexedDB is very well supported.
Remember, however, that a Blob has a MIME type while an ArrayBuffer does not. You will need to store the type alongside the buffer in order to do the conversion correctly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
code looks good but think we should add some tests, seems complex enough to fail with some minor adjustment
@shahin-hq maybe we should treat this one and #326 a single task with a single pr, testing this requires #326 anyway |
@alfonsobries surely we can do that also note that I added unit tests for the hook, so it can be tested by reading unit tests. |
@shahin-hq think this pr should be against |
# Conflicts: # resources/js/Components/Sidebar/SidebarItem.tsx # resources/js/I18n/Locales/en.json # resources/js/Pages/Settings/Layout.tsx
# Conflicts: # resources/js/Components/Sidebar/SidebarItem.tsx # resources/js/I18n/Locales/en.json
@@ -8,6 +8,7 @@ describe("SidebarItem", () => { | |||
<SidebarItem | |||
icon="Cog" | |||
title="General" | |||
href="/hello" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
had to fix that in order to make CI happy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I don't see any issues other than those that @alfonsobries mentioned and what we discussed in thread. We could also continue reviewing the integration part in #326
Summary
Closes: https://app.clickup.com/t/862kh238w
This PR implements a hook to save/update gallery drafts. It uses
indexed-db
under the hood to avoid potential storage limits oflocalStorage
.Check #326 to see the hook in action or testing
Checklist