refactor: convertFlags to utils
parent
a20edc67bb
commit
2b9e7ee5b7
|
@ -718,26 +718,7 @@ export default class Timeline extends Mixins(GlobalMixin, UserConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Flag conversion
|
// Flag conversion
|
||||||
if (photo.isvideo) {
|
utils.convertFlags(photo);
|
||||||
photo.flag |= this.c.FLAG_IS_VIDEO;
|
|
||||||
delete photo.isvideo;
|
|
||||||
}
|
|
||||||
if (photo.isfavorite) {
|
|
||||||
photo.flag |= this.c.FLAG_IS_FAVORITE;
|
|
||||||
delete photo.isfavorite;
|
|
||||||
}
|
|
||||||
if (photo.isfolder) {
|
|
||||||
photo.flag |= this.c.FLAG_IS_FOLDER;
|
|
||||||
delete photo.isfolder;
|
|
||||||
}
|
|
||||||
if (photo.isface) {
|
|
||||||
photo.flag |= this.c.FLAG_IS_FACE;
|
|
||||||
delete photo.isface;
|
|
||||||
}
|
|
||||||
if (photo.istag) {
|
|
||||||
photo.flag |= this.c.FLAG_IS_TAG;
|
|
||||||
delete photo.istag;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get aspect ratio
|
// Get aspect ratio
|
||||||
photo.dispWp = utils.round(100 * jbox.width / this.rowWidth, 2);
|
photo.dispWp = utils.round(100 * jbox.width / this.rowWidth, 2);
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { getCanonicalLocale } from "@nextcloud/l10n";
|
import { getCanonicalLocale } from "@nextcloud/l10n";
|
||||||
|
import { IPhoto } from "../types";
|
||||||
|
|
||||||
// Memoize the result of short date conversions
|
// Memoize the result of short date conversions
|
||||||
// These operations are surprisingly expensive
|
// These operations are surprisingly expensive
|
||||||
|
@ -108,6 +109,33 @@ export function roundHalf(num: number) {
|
||||||
return Math.round(num * 2) / 2;
|
return Math.round(num * 2) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert server-side flags to bitmask
|
||||||
|
* @param photo Photo to process
|
||||||
|
*/
|
||||||
|
export function convertFlags(photo: IPhoto) {
|
||||||
|
if (photo.isvideo) {
|
||||||
|
photo.flag |= constants.c.FLAG_IS_VIDEO;
|
||||||
|
delete photo.isvideo;
|
||||||
|
}
|
||||||
|
if (photo.isfavorite) {
|
||||||
|
photo.flag |= constants.c.FLAG_IS_FAVORITE;
|
||||||
|
delete photo.isfavorite;
|
||||||
|
}
|
||||||
|
if (photo.isfolder) {
|
||||||
|
photo.flag |= constants.c.FLAG_IS_FOLDER;
|
||||||
|
delete photo.isfolder;
|
||||||
|
}
|
||||||
|
if (photo.isface) {
|
||||||
|
photo.flag |= constants.c.FLAG_IS_FACE;
|
||||||
|
delete photo.isface;
|
||||||
|
}
|
||||||
|
if (photo.istag) {
|
||||||
|
photo.flag |= constants.c.FLAG_IS_TAG;
|
||||||
|
delete photo.istag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Global constants */
|
/** Global constants */
|
||||||
export const constants = {
|
export const constants = {
|
||||||
c: {
|
c: {
|
||||||
|
|
Loading…
Reference in New Issue