File tree 2 files changed +16
-8
lines changed
2 files changed +16
-8
lines changed Original file line number Diff line number Diff line change @@ -873,12 +873,19 @@ function setupListModel(Model, nested) {
873
873
offline : modelConfig . storage . offline && {
874
874
threshold : modelConfig . storage . offline . threshold ,
875
875
get : ( id ) => {
876
- const result = modelConfig . storage . offline . get (
877
- hashCode ( String ( stringifyId ( id ) ) ) ,
876
+ const stringId = stringifyId ( id ) ;
877
+ let result = modelConfig . storage . offline . get (
878
+ hashCode ( String ( stringId ) ) ,
878
879
) ;
879
- return result
880
- ? result . map ( ( item ) => modelConfig . storage . offline . get ( item ) )
881
- : null ;
880
+ if ( result ) {
881
+ result = result . map ( ( item ) =>
882
+ modelConfig . storage . offline . get ( item ) ,
883
+ ) ;
884
+ result . id = stringId ;
885
+ return result ;
886
+ }
887
+
888
+ return null ;
882
889
} ,
883
890
set : ( id , values ) => {
884
891
modelConfig . storage . offline . set (
Original file line number Diff line number Diff line change @@ -2312,13 +2312,13 @@ describe("store:", () => {
2312
2312
} ;
2313
2313
2314
2314
return store . pending ( store . get ( Model , "1" ) ) . then ( ( ) =>
2315
- store . pending ( store . get ( [ Model ] ) ) . then ( ( ) => {
2315
+ store . pending ( store . get ( [ Model ] , { test : "test" } ) ) . then ( ( ) => {
2316
2316
store . clear ( Model , false ) ;
2317
2317
return resolveRaf ( ( ) => {
2318
2318
const cacheModel = store . get ( Model , "1" ) ;
2319
2319
expect ( cacheModel . value ) . toBe ( "test" ) ;
2320
2320
2321
- const cacheList = store . get ( [ Model ] ) ;
2321
+ const cacheList = store . get ( [ Model ] , { test : "test" } ) ;
2322
2322
expect ( cacheList . length ) . toBe ( 2 ) ;
2323
2323
2324
2324
return resolveRaf ( ( ) => {
@@ -2332,7 +2332,8 @@ describe("store:", () => {
2332
2332
expect ( offlineModel . value ) . toBe ( "test" ) ;
2333
2333
expect ( store . error ( offlineModel ) ) . toBeInstanceOf ( Error ) ;
2334
2334
2335
- const offlineList = store . get ( [ Model ] ) ;
2335
+ const offlineList = store . get ( [ Model ] , { test : "test" } ) ;
2336
+ expect ( offlineList . id ) . toBe ( JSON . stringify ( { test : "test" } ) ) ;
2336
2337
expect ( offlineList . length ) . toBe ( 2 ) ;
2337
2338
expect ( store . error ( offlineList ) ) . toBeInstanceOf ( Error ) ;
2338
2339
} ) ;
You can’t perform that action at this time.
0 commit comments