timeline: fix refreshing favorite state
Signed-off-by: Varun Patil <radialapps@gmail.com>pull/783/head
parent
8658147a44
commit
b4748fbcab
|
@ -938,13 +938,29 @@ export default defineComponent({
|
||||||
for (const [dayId, photos] of dayMap) {
|
for (const [dayId, photos] of dayMap) {
|
||||||
// Check if the response has any delta
|
// Check if the response has any delta
|
||||||
const head = this.heads[dayId];
|
const head = this.heads[dayId];
|
||||||
if (head?.day?.detail?.length) {
|
if (head?.day?.detail?.length === photos.length) {
|
||||||
if (
|
// Goes over the day and checks each photo including
|
||||||
head.day.detail.length === photos.length &&
|
// the order with the current list. If anything changes,
|
||||||
head.day.detail.every((p, i) => p.fileid === photos[i].fileid && p.etag === photos[i].etag)
|
// we reprocess everything; otherwise just copy over
|
||||||
) {
|
// newer props that are reactive.
|
||||||
continue;
|
const isSame = head.day.detail.every((curr, i) => {
|
||||||
}
|
const now = photos[i];
|
||||||
|
if (curr.fileid === now.fileid && curr.etag === now.etag) {
|
||||||
|
// copy over any properties that might have changed
|
||||||
|
// this way we don't need to iterate again for this
|
||||||
|
utils.convertFlags(now);
|
||||||
|
|
||||||
|
// copy over flags
|
||||||
|
utils.copyPhotoFlags(now, curr);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Skip this entire day since nothing changed
|
||||||
|
if (isSame) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pass ahead
|
// Pass ahead
|
||||||
|
|
|
@ -38,3 +38,18 @@ export function convertFlags(photo: IPhoto) {
|
||||||
delete photo.islocal;
|
delete photo.islocal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Copy over server flags from one photo object to another.
|
||||||
|
* @param src Source photo
|
||||||
|
* @param dst Destination photo
|
||||||
|
*/
|
||||||
|
export function copyPhotoFlags(src: IPhoto, dst: IPhoto) {
|
||||||
|
// copy a single flag
|
||||||
|
const copy = (flag: number) => (dst.flag = src.flag & flag ? dst.flag | flag : dst.flag & ~flag);
|
||||||
|
|
||||||
|
// copy all flags
|
||||||
|
copy(constants.c.FLAG_IS_VIDEO);
|
||||||
|
copy(constants.c.FLAG_IS_FAVORITE);
|
||||||
|
copy(constants.c.FLAG_IS_LOCAL);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue