pull/37/head
Varun Patil 2022-08-15 03:25:12 +00:00
parent 42970fa87c
commit ee41e8441d
3 changed files with 45 additions and 7 deletions

View File

@ -18,8 +18,21 @@ class Util {
$this->connection = $connection; $this->connection = $connection;
} }
private function getDateTaken($file) { public static function getDateTaken($file) {
// Attempt to read exif data
$exif = exif_read_data($file->fopen('rb'));
$dt = $exif['DateTimeOriginal'];
if ($dt) {
$dt = \DateTime::createFromFormat('Y:m:d H:i:s', $dt);
if ($dt) {
return $dt->getTimestamp();
}
}
// Fall back to creation time
$dateTaken = $file->getCreationTime(); $dateTaken = $file->getCreationTime();
// Fall back to modification time
if ($dateTaken == 0) { if ($dateTaken == 0) {
$dateTaken = $file->getMtime(); $dateTaken = $file->getMtime();
} }

View File

@ -17,7 +17,7 @@
<style scoped> <style scoped>
.outer { .outer {
padding: 0px 44px 256px 44px; padding: 0 0 20px 44px;
} }
</style> </style>

View File

@ -28,6 +28,9 @@ export default {
nrows: 0, nrows: 0,
ncols: 5, ncols: 5,
heads: {}, heads: {},
currentStart: 0,
currentEnd: 0,
} }
}, },
@ -37,6 +40,21 @@ export default {
methods: { methods: {
scrollChange(startIndex, endIndex) { scrollChange(startIndex, endIndex) {
if (startIndex === this.currentStart && endIndex === this.currentEnd) {
return;
}
this.currentStart = startIndex;
this.currentEnd = endIndex;
setTimeout(() => {
if (this.currentStart === startIndex && this.currentEnd === endIndex) {
this.loadChanges(startIndex, endIndex);
}
}, 300);
},
loadChanges(startIndex, endIndex) {
console.log(startIndex, endIndex);
for (let i = startIndex; i <= endIndex; i++) { for (let i = startIndex; i <= endIndex; i++) {
let item = this.list[i]; let item = this.list[i];
if (!item) { if (!item) {
@ -45,6 +63,7 @@ export default {
let head = this.heads[item.dayId]; let head = this.heads[item.dayId];
if (head && !head.loaded) { if (head && !head.loaded) {
head.loaded = true;
this.fetchDay(item.dayId); this.fetchDay(item.dayId);
} }
} }
@ -87,11 +106,16 @@ export default {
const head = this.heads[dayId]; const head = this.heads[dayId];
head.loaded = true; head.loaded = true;
const res = await fetch(`/apps/betterphotos/api/days/${dayId}`); let data = [];
const data = await res.json(); try {
const res = await fetch(`/apps/betterphotos/api/days/${dayId}`);
const nrows = Math.ceil(data.length / this.ncols); data = await res.json();
} catch (e) {
console.error(e);
head.loaded = false;
}
// Get index of header O(n)
const headIdx = this.list.findIndex(item => item.id === head.id); const headIdx = this.list.findIndex(item => item.id === head.id);
let rowIdx = headIdx + 1; let rowIdx = headIdx + 1;
@ -133,7 +157,8 @@ export default {
<style scoped> <style scoped>
.scroller { .scroller {
height: 100%; height: 600px;
width: 100%;
} }
.photo { .photo {