@@ -105,12 +105,11 @@ export default {
105
105
const uid = this .$route .params .album ;
106
106
const query = this .$route .query ;
107
107
const routeName = this .$route .name ;
108
- const order = query[" order" ] ? query[" order" ] : " oldest" ;
109
108
const camera = query[" camera" ] ? parseInt (query[" camera" ]) : 0 ;
110
109
const q = query[" q" ] ? query[" q" ] : " " ;
111
110
const country = query[" country" ] ? query[" country" ] : " " ;
112
111
const view = this .getViewType ();
113
- const filter = { country: country, camera: camera, order : order, q: q };
112
+ const filter = { country: country, camera: camera, q: q };
114
113
const settings = { view: view };
115
114
const batchSize = Photo .batchSize ();
116
115
@@ -136,6 +135,7 @@ export default {
136
135
settings: settings,
137
136
filter: filter,
138
137
lastFilter: {},
138
+ lastParams: {},
139
139
routeName: routeName,
140
140
collectionRoute: this .$route .meta ? .collectionRoute ? this .$route .meta .collectionRoute : " albums" ,
141
141
loading: true ,
@@ -185,7 +185,7 @@ export default {
185
185
const routeChanged = this .routeName !== this .$route .name ;
186
186
187
187
if (routeChanged) {
188
- this .lastFilter = {} ;
188
+ this .resetLastFilter () ;
189
189
}
190
190
191
191
this .routeName = this .$route .name ;
@@ -230,6 +230,9 @@ export default {
230
230
this .$view .leave (this );
231
231
},
232
232
methods: {
233
+ resetLastFilter () {
234
+ this .lastFilter = {};
235
+ },
233
236
onCtrl (ev ) {
234
237
if (! ev || ! (ev instanceof KeyboardEvent ) || ! ev .ctrlKey || ! this .$view .isActive (this )) {
235
238
return ;
@@ -263,6 +266,10 @@ export default {
263
266
264
267
return " cards" ;
265
268
},
269
+ getSortOrder () {
270
+ const query = this .$route .query ;
271
+ return query[" order" ] ? query[" order" ] : this .model ? .Order ;
272
+ },
266
273
openDate (index ) {
267
274
if (! this .canEdit ) {
268
275
return this .openPhoto (index);
@@ -348,6 +355,7 @@ export default {
348
355
offset: offset,
349
356
s: this .uid ,
350
357
merged: true ,
358
+ order: this .getSortOrder (),
351
359
};
352
360
353
361
Object .assign (params, this .lastFilter );
@@ -356,6 +364,8 @@ export default {
356
364
Object .assign (params, this .staticFilter );
357
365
}
358
366
367
+ this .lastParams = params;
368
+
359
369
Photo .search (params)
360
370
.then ((response ) => {
361
371
this .results = Photo .mergeResponse (this .results , response);
@@ -436,10 +446,6 @@ export default {
436
446
updateQuery (props ) {
437
447
this .updateFilter (props);
438
448
439
- if (this .model .Order !== this .filter .order ) {
440
- this .model .Order = this .filter .order ;
441
- }
442
-
443
449
if (this .loading ) {
444
450
return ;
445
451
}
@@ -468,6 +474,7 @@ export default {
468
474
offset: this .offset ,
469
475
s: this .uid ,
470
476
merged: true ,
477
+ order: this .getSortOrder (),
471
478
};
472
479
473
480
Object .assign (params, this .filter );
@@ -481,15 +488,17 @@ export default {
481
488
refresh (props ) {
482
489
this .updateSettings (props);
483
490
484
- if (this .loading ) return ;
491
+ if (this .loading ) {
492
+ return ;
493
+ }
485
494
486
495
this .loading = true ;
487
496
this .page = 0 ;
488
497
this .dirty = true ;
489
498
this .complete = false ;
490
499
this .scrollDisabled = false ;
491
500
492
- this .loadMore ();
501
+ this .loadMore (true );
493
502
},
494
503
search () {
495
504
/**
@@ -519,6 +528,8 @@ export default {
519
528
520
529
const params = this .searchParams ();
521
530
531
+ this .lastParams = params;
532
+
522
533
Photo .search (params)
523
534
.then ((response ) => {
524
535
// Hide search toolbar expansion panel when matching pictures were found.
@@ -564,7 +575,6 @@ export default {
564
575
.then ((m ) => {
565
576
this .model = m;
566
577
567
- this .filter .order = m .Order ;
568
578
window .document .title = ` ${ this .$config .get (" siteTitle" )} : ${ this .model .Title } ` ;
569
579
570
580
return Promise .resolve (this .model );
@@ -575,7 +585,9 @@ export default {
575
585
});
576
586
},
577
587
onAlbumsUpdated (ev , data ) {
578
- if (! this .listen ) return ;
588
+ if (! this .listen ) {
589
+ return ;
590
+ }
579
591
580
592
if (! data || ! data .entities || ! Array .isArray (data .entities )) {
581
593
return ;
@@ -597,10 +609,8 @@ export default {
597
609
this .complete = false ;
598
610
this .scrollDisabled = false ;
599
611
600
- if (this .filter .order !== this .model .Order ) {
601
- this .filter .order = this .model .Order ;
612
+ if (this .lastParams ? .order !== this .model ? .Order ) {
602
613
this .updateQuery ();
603
- } else {
604
614
this .loadMore (true );
605
615
}
606
616
0 commit comments