Skip to content

Commit 9af3478

Browse files
committed
Albums: Reload pictures when the album sort order has changed #405
Signed-off-by: Michael Mayer <michael@photoprism.app>
1 parent 8187182 commit 9af3478

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

frontend/src/page/album/photos.vue

+24-14
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,11 @@ export default {
105105
const uid = this.$route.params.album;
106106
const query = this.$route.query;
107107
const routeName = this.$route.name;
108-
const order = query["order"] ? query["order"] : "oldest";
109108
const camera = query["camera"] ? parseInt(query["camera"]) : 0;
110109
const q = query["q"] ? query["q"] : "";
111110
const country = query["country"] ? query["country"] : "";
112111
const view = this.getViewType();
113-
const filter = { country: country, camera: camera, order: order, q: q };
112+
const filter = { country: country, camera: camera, q: q };
114113
const settings = { view: view };
115114
const batchSize = Photo.batchSize();
116115
@@ -136,6 +135,7 @@ export default {
136135
settings: settings,
137136
filter: filter,
138137
lastFilter: {},
138+
lastParams: {},
139139
routeName: routeName,
140140
collectionRoute: this.$route.meta?.collectionRoute ? this.$route.meta.collectionRoute : "albums",
141141
loading: true,
@@ -185,7 +185,7 @@ export default {
185185
const routeChanged = this.routeName !== this.$route.name;
186186
187187
if (routeChanged) {
188-
this.lastFilter = {};
188+
this.resetLastFilter();
189189
}
190190
191191
this.routeName = this.$route.name;
@@ -230,6 +230,9 @@ export default {
230230
this.$view.leave(this);
231231
},
232232
methods: {
233+
resetLastFilter() {
234+
this.lastFilter = {};
235+
},
233236
onCtrl(ev) {
234237
if (!ev || !(ev instanceof KeyboardEvent) || !ev.ctrlKey || !this.$view.isActive(this)) {
235238
return;
@@ -263,6 +266,10 @@ export default {
263266
264267
return "cards";
265268
},
269+
getSortOrder() {
270+
const query = this.$route.query;
271+
return query["order"] ? query["order"] : this.model?.Order;
272+
},
266273
openDate(index) {
267274
if (!this.canEdit) {
268275
return this.openPhoto(index);
@@ -348,6 +355,7 @@ export default {
348355
offset: offset,
349356
s: this.uid,
350357
merged: true,
358+
order: this.getSortOrder(),
351359
};
352360
353361
Object.assign(params, this.lastFilter);
@@ -356,6 +364,8 @@ export default {
356364
Object.assign(params, this.staticFilter);
357365
}
358366
367+
this.lastParams = params;
368+
359369
Photo.search(params)
360370
.then((response) => {
361371
this.results = Photo.mergeResponse(this.results, response);
@@ -436,10 +446,6 @@ export default {
436446
updateQuery(props) {
437447
this.updateFilter(props);
438448
439-
if (this.model.Order !== this.filter.order) {
440-
this.model.Order = this.filter.order;
441-
}
442-
443449
if (this.loading) {
444450
return;
445451
}
@@ -468,6 +474,7 @@ export default {
468474
offset: this.offset,
469475
s: this.uid,
470476
merged: true,
477+
order: this.getSortOrder(),
471478
};
472479
473480
Object.assign(params, this.filter);
@@ -481,15 +488,17 @@ export default {
481488
refresh(props) {
482489
this.updateSettings(props);
483490
484-
if (this.loading) return;
491+
if (this.loading) {
492+
return;
493+
}
485494
486495
this.loading = true;
487496
this.page = 0;
488497
this.dirty = true;
489498
this.complete = false;
490499
this.scrollDisabled = false;
491500
492-
this.loadMore();
501+
this.loadMore(true);
493502
},
494503
search() {
495504
/**
@@ -519,6 +528,8 @@ export default {
519528
520529
const params = this.searchParams();
521530
531+
this.lastParams = params;
532+
522533
Photo.search(params)
523534
.then((response) => {
524535
// Hide search toolbar expansion panel when matching pictures were found.
@@ -564,7 +575,6 @@ export default {
564575
.then((m) => {
565576
this.model = m;
566577
567-
this.filter.order = m.Order;
568578
window.document.title = `${this.$config.get("siteTitle")}: ${this.model.Title}`;
569579
570580
return Promise.resolve(this.model);
@@ -575,7 +585,9 @@ export default {
575585
});
576586
},
577587
onAlbumsUpdated(ev, data) {
578-
if (!this.listen) return;
588+
if (!this.listen) {
589+
return;
590+
}
579591
580592
if (!data || !data.entities || !Array.isArray(data.entities)) {
581593
return;
@@ -597,10 +609,8 @@ export default {
597609
this.complete = false;
598610
this.scrollDisabled = false;
599611
600-
if (this.filter.order !== this.model.Order) {
601-
this.filter.order = this.model.Order;
612+
if (this.lastParams?.order !== this.model?.Order) {
602613
this.updateQuery();
603-
} else {
604614
this.loadMore(true);
605615
}
606616

frontend/src/page/photos.vue

+7-3
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,9 @@ export default {
570570
updateQuery(props) {
571571
this.updateFilter(props);
572572
573-
if (this.loading) return;
573+
if (this.loading) {
574+
return;
575+
}
574576
575577
const query = {
576578
view: this.settings.view,
@@ -608,15 +610,17 @@ export default {
608610
refresh(props) {
609611
this.updateSettings(props);
610612
611-
if (this.loading) return;
613+
if (this.loading) {
614+
return;
615+
}
612616
613617
this.loading = true;
614618
this.page = 0;
615619
this.dirty = true;
616620
this.complete = false;
617621
this.scrollDisabled = false;
618622
619-
this.loadMore();
623+
this.loadMore(true);
620624
},
621625
search() {
622626
/**

0 commit comments

Comments
 (0)