Redefine if location is has new photos and compare to last seen date

This commit is contained in:
2022-10-10 17:26:22 +02:00
parent a19339b49d
commit ee095a2cc8
3 changed files with 30 additions and 21 deletions

View File

@@ -48,7 +48,7 @@
"svelte-preprocess": "^4.10.7",
"tslib": "^2.4.0",
"typescript": "^4.8.4",
"vite": "^3.1.6"
"vite": "^3.1.7"
},
"type": "module",
"browserslist": [

28
pnpm-lock.yaml generated
View File

@@ -32,7 +32,7 @@ specifiers:
tslib: ^2.4.0
tweakpane: ^3.1.0
typescript: ^4.8.4
vite: ^3.1.6
vite: ^3.1.7
dependencies:
'@studio-freight/lenis': 0.2.9
@@ -49,7 +49,7 @@ devDependencies:
'@sveltejs/adapter-auto': 1.0.0-next.80
'@sveltejs/adapter-node': 1.0.0-next.96
'@sveltejs/adapter-vercel': 1.0.0-next.77
'@sveltejs/kit': 1.0.0-next.511_svelte@3.50.1+vite@3.1.6
'@sveltejs/kit': 1.0.0-next.511_svelte@3.50.1+vite@3.1.7
'@typescript-eslint/eslint-plugin': 5.39.0_cfd7h3iktziq6hcwahu2qxhjhy
'@typescript-eslint/parser': 5.39.0_z4bbprzjrhnsfa24uvmcbu7f5q
base-64: 1.0.0
@@ -68,7 +68,7 @@ devDependencies:
svelte-preprocess: 4.10.7_5ueojnt6nmuc362wxq5xdclnk4
tslib: 2.4.0
typescript: 4.8.4
vite: 3.1.6_sass@1.55.0
vite: 3.1.7_sass@1.55.0
packages:
@@ -527,7 +527,7 @@ packages:
- supports-color
dev: true
/@sveltejs/kit/1.0.0-next.511_svelte@3.50.1+vite@3.1.6:
/@sveltejs/kit/1.0.0-next.511_svelte@3.50.1+vite@3.1.7:
resolution: {integrity: sha512-A/fxd4qHWDD07Mjo6qEEEfsBEkoj5C4/dPSzx6xPUoWmPvRPhU8t+P0oMc8BOn5YHOhPDq3coH8bmafbh73zKg==}
engines: {node: '>=16.14'}
hasBin: true
@@ -536,12 +536,12 @@ packages:
svelte: ^3.44.0
vite: ^3.1.0
dependencies:
'@sveltejs/vite-plugin-svelte': 1.0.9_svelte@3.50.1+vite@3.1.6
'@sveltejs/vite-plugin-svelte': 1.0.9_svelte@3.50.1+vite@3.1.7
'@types/cookie': 0.5.1
cookie: 0.5.0
devalue: 4.0.0
kleur: 4.1.5
magic-string: 0.26.6
magic-string: 0.26.7
mime: 3.0.0
sade: 1.8.1
set-cookie-parser: 2.5.1
@@ -549,13 +549,13 @@ packages:
svelte: 3.50.1
tiny-glob: 0.2.9
undici: 5.11.0
vite: 3.1.6_sass@1.55.0
vite: 3.1.7_sass@1.55.0
transitivePeerDependencies:
- diff-match-patch
- supports-color
dev: true
/@sveltejs/vite-plugin-svelte/1.0.9_svelte@3.50.1+vite@3.1.6:
/@sveltejs/vite-plugin-svelte/1.0.9_svelte@3.50.1+vite@3.1.7:
resolution: {integrity: sha512-+SDrAnT7TDi8sdj4OfD2SC4s9DNrpNVBrue8fT2PmKks9Ddu0JIfSeX91wXZb/1xHz4EkGb+rli8GTRI0yGOjg==}
engines: {node: ^14.18.0 || >= 16}
peerDependencies:
@@ -570,10 +570,10 @@ packages:
debug: 4.3.4
deepmerge: 4.2.2
kleur: 4.1.5
magic-string: 0.26.6
magic-string: 0.26.7
svelte: 3.50.1
svelte-hmr: 0.15.0_svelte@3.50.1
vite: 3.1.6_sass@1.55.0
vite: 3.1.7_sass@1.55.0
transitivePeerDependencies:
- supports-color
dev: true
@@ -2029,8 +2029,8 @@ packages:
sourcemap-codec: 1.4.8
dev: true
/magic-string/0.26.6:
resolution: {integrity: sha512-6d+3bFybzyQFJYSoRsl9ZC0wheze8M1LrQC7tNMRqXR4izUTDOLMd9BtSuExK9iAukFh+s5K0WAhc/dlQ+HKYA==}
/magic-string/0.26.7:
resolution: {integrity: sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==}
engines: {node: '>=12'}
dependencies:
sourcemap-codec: 1.4.8
@@ -3505,8 +3505,8 @@ packages:
tiny-emitter: 2.1.0
dev: false
/vite/3.1.6_sass@1.55.0:
resolution: {integrity: sha512-qMXIwnehvvcK5XfJiXQUiTxoYAEMKhM+jqCY6ZSTKFBKu1hJnAKEzP3AOcnTerI0cMZYAaJ4wpW1wiXLMDt4mA==}
/vite/3.1.7_sass@1.55.0:
resolution: {integrity: sha512-5vCAmU4S8lyVdFCInu9M54f/g8qbOMakVw5xJ4pjoaDy5wgy9sLLZkGdSLN52dlsBqh0tBqxjaqqa8LgPqwRAA==}
engines: {node: ^14.18.0 || >=16.0.0}
hasBin: true
peerDependencies:

View File

@@ -5,7 +5,7 @@
<script lang="ts">
import { getContext } from 'svelte'
import { spring } from 'svelte/motion'
import dayjs, { type Dayjs } from 'dayjs'
import dayjs from 'dayjs'
import { lerp } from '$utils/functions'
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
import { seenLocations } from '$utils/stores'
@@ -23,15 +23,24 @@
// Location date limit
let isNew = false
let dateUpdated: Dayjs
const dateNowOffset = dayjs().subtract(settings.limit_new, 'day')
const parsedSeenLocations = JSON.parse($seenLocations)
$: if (latestPhoto && $seenLocations) {
dateUpdated = dayjs(latestPhoto.date_created)
$: if (latestPhoto) {
const dateUpdated = dayjs(latestPhoto.date_created)
// Detect if location has new content
const seenLocation = JSON.parse($seenLocations)?.hasOwnProperty(location.id)
isNew = dateUpdated.isAfter(dateNowOffset) && !seenLocation
const seenLocationDate = dayjs(parsedSeenLocations[location.id])
const isLocationSeen = parsedSeenLocations?.hasOwnProperty(location.id)
// Define if location is has new photos
if (seenLocationDate && isLocationSeen) {
// A more recent photo has been added (if has been seen and has a seen date)
isNew = dateUpdated.isAfter(dateNowOffset) && dateUpdated.isAfter(seenLocationDate)
} else {
// The photo is after the offset
isNew = dateUpdated.isAfter(dateNowOffset)
}
}