-
Notifications
You must be signed in to change notification settings - Fork 701
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
Serialize to indexdb #658
Serialize to indexdb #658
Conversation
I think all the right stuff is getting serialized now, but there are a few problems:
On that note, here's a link to this PR's build with the Open that if you end up with bad serialized state. |
Going back and forth between Edit: and going back and forth between something other than |
c5dac30
to
05edf84
Compare
@1j01 Okay, the issue where it fails to keep the same position across reloads has now been resolved, I believe. Next before we ship this we need to ensure there is no way to leave the user in a state where a window is outside of their window. |
38c1b40
to
81eb38d
Compare
Update: You now need the https://deploy-preview-658--ecstatic-poincare-fe4c13.netlify.com/?useState=1 |
4f686da
to
e595459
Compare
e595459
to
4caa582
Compare
…hen you construct it This also sets us up for being able to unbind things
This is particularly noticeable when state has been rehydrated from a serialized state.
… it, as a nice side benefit
3579289
to
4d35337
Compare
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.
Pretty impressive stuff. Seems to work very well. I tried to do some quick smoke testing and created the #663. The only thing that doesn't seem to work is saving of the window positions. It used to work, but it seems to be broken now.
I've fixed the types and unified the code for the debounce
and throttle
. I'm not sure why are callbackArgs
are defined in different scope, there doesn't seem to be any reason for that.
Btw. not sure if a mistake or not and I am really sorry for being "that guy", but it's an IndexedDB, not IndexDB. Just pointing it out to prevent some confusion in the future.
skinGenLetterWidths, | ||
skinColors, | ||
skinPlaylistStyle | ||
} = state; |
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.
I know it's not hip like the destructuring, but could this simply return something like { doubled: state.doubled, ... }
to get rid of the repetition?
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.
Yeah, both options kinda suck. Even without the destructuring you still need to write every property twice. My, dubious, rational was that this way I didn't have to write state.
n times, but... I'm not sure how important that is.
@@ -129,7 +138,27 @@ export default (media: Media) => (store: MiddlewareStore) => { | |||
case SET_EQ_ON: | |||
media.enableEq(); | |||
break; | |||
case LOAD_SERIALIZED_STATE: { | |||
// Set ALL THE THINGS! |
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.
genWindows: Utils.objectMap(state.genWindows, w => ({ | ||
...w, | ||
// Not sure why TypeScript can't figure this out for itself. | ||
size: [0, 0] as [number, number] |
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.
This is probably caused by the "return type widening". Size type gets "widened" to number[]. Not sure how to work around this better than you did. Maybe it'll get eventually improved by the TS team. Seems there is a discussion for this.
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.
Makes sense.
Thanks for the correction re indexeddb. I think I've fixed the position serialization issue. I'm going to ship this now, but the serialization will be off by default. |
First stab at serializing state!