File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -19,14 +19,24 @@ interface IRecentQuib extends Quib {
1919
2020const stored_recent_quibs = browser ? localStorage . getItem ( 'recent_posts_store' ) : null ;
2121const parsed_stored_recent_quibs : IRecentQuib [ ] = stored_recent_quibs
22- ? JSON . parse ( stored_recent_quibs )
22+ ? // convert string to Date object
23+ ( JSON . parse ( stored_recent_quibs ) as IRecentQuib [ ] ) . map ( ( q ) => ( {
24+ ...q ,
25+ timestamp : new Date ( q . timestamp )
26+ } ) )
2327 : [ ] ;
2428
2529let recent_quibs_state = $state < IRecentQuib [ ] > ( parsed_stored_recent_quibs ) ;
2630
2731function sync_to_localstorage ( ) {
2832 if ( browser ) {
29- localStorage . setItem ( 'recent_posts_store' , JSON . stringify ( recent_quibs_state ) ) ;
33+ // convert Date object to string
34+ localStorage . setItem (
35+ 'recent_posts_store' ,
36+ JSON . stringify (
37+ recent_quibs_state . map ( ( q ) => ( { ...q , timestamp : q . timestamp . toISOString ( ) } ) )
38+ )
39+ ) ;
3040 }
3141}
3242
You can’t perform that action at this time.
0 commit comments