Redefine if location is has new photos and compare to last seen date
This commit is contained in:
@@ -48,7 +48,7 @@
|
|||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
"tslib": "^2.4.0",
|
"tslib": "^2.4.0",
|
||||||
"typescript": "^4.8.4",
|
"typescript": "^4.8.4",
|
||||||
"vite": "^3.1.6"
|
"vite": "^3.1.7"
|
||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
|
|||||||
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
@@ -32,7 +32,7 @@ specifiers:
|
|||||||
tslib: ^2.4.0
|
tslib: ^2.4.0
|
||||||
tweakpane: ^3.1.0
|
tweakpane: ^3.1.0
|
||||||
typescript: ^4.8.4
|
typescript: ^4.8.4
|
||||||
vite: ^3.1.6
|
vite: ^3.1.7
|
||||||
|
|
||||||
dependencies:
|
dependencies:
|
||||||
'@studio-freight/lenis': 0.2.9
|
'@studio-freight/lenis': 0.2.9
|
||||||
@@ -49,7 +49,7 @@ devDependencies:
|
|||||||
'@sveltejs/adapter-auto': 1.0.0-next.80
|
'@sveltejs/adapter-auto': 1.0.0-next.80
|
||||||
'@sveltejs/adapter-node': 1.0.0-next.96
|
'@sveltejs/adapter-node': 1.0.0-next.96
|
||||||
'@sveltejs/adapter-vercel': 1.0.0-next.77
|
'@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/eslint-plugin': 5.39.0_cfd7h3iktziq6hcwahu2qxhjhy
|
||||||
'@typescript-eslint/parser': 5.39.0_z4bbprzjrhnsfa24uvmcbu7f5q
|
'@typescript-eslint/parser': 5.39.0_z4bbprzjrhnsfa24uvmcbu7f5q
|
||||||
base-64: 1.0.0
|
base-64: 1.0.0
|
||||||
@@ -68,7 +68,7 @@ devDependencies:
|
|||||||
svelte-preprocess: 4.10.7_5ueojnt6nmuc362wxq5xdclnk4
|
svelte-preprocess: 4.10.7_5ueojnt6nmuc362wxq5xdclnk4
|
||||||
tslib: 2.4.0
|
tslib: 2.4.0
|
||||||
typescript: 4.8.4
|
typescript: 4.8.4
|
||||||
vite: 3.1.6_sass@1.55.0
|
vite: 3.1.7_sass@1.55.0
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -527,7 +527,7 @@ packages:
|
|||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
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==}
|
resolution: {integrity: sha512-A/fxd4qHWDD07Mjo6qEEEfsBEkoj5C4/dPSzx6xPUoWmPvRPhU8t+P0oMc8BOn5YHOhPDq3coH8bmafbh73zKg==}
|
||||||
engines: {node: '>=16.14'}
|
engines: {node: '>=16.14'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
@@ -536,12 +536,12 @@ packages:
|
|||||||
svelte: ^3.44.0
|
svelte: ^3.44.0
|
||||||
vite: ^3.1.0
|
vite: ^3.1.0
|
||||||
dependencies:
|
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
|
'@types/cookie': 0.5.1
|
||||||
cookie: 0.5.0
|
cookie: 0.5.0
|
||||||
devalue: 4.0.0
|
devalue: 4.0.0
|
||||||
kleur: 4.1.5
|
kleur: 4.1.5
|
||||||
magic-string: 0.26.6
|
magic-string: 0.26.7
|
||||||
mime: 3.0.0
|
mime: 3.0.0
|
||||||
sade: 1.8.1
|
sade: 1.8.1
|
||||||
set-cookie-parser: 2.5.1
|
set-cookie-parser: 2.5.1
|
||||||
@@ -549,13 +549,13 @@ packages:
|
|||||||
svelte: 3.50.1
|
svelte: 3.50.1
|
||||||
tiny-glob: 0.2.9
|
tiny-glob: 0.2.9
|
||||||
undici: 5.11.0
|
undici: 5.11.0
|
||||||
vite: 3.1.6_sass@1.55.0
|
vite: 3.1.7_sass@1.55.0
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
- diff-match-patch
|
- diff-match-patch
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
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==}
|
resolution: {integrity: sha512-+SDrAnT7TDi8sdj4OfD2SC4s9DNrpNVBrue8fT2PmKks9Ddu0JIfSeX91wXZb/1xHz4EkGb+rli8GTRI0yGOjg==}
|
||||||
engines: {node: ^14.18.0 || >= 16}
|
engines: {node: ^14.18.0 || >= 16}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@@ -570,10 +570,10 @@ packages:
|
|||||||
debug: 4.3.4
|
debug: 4.3.4
|
||||||
deepmerge: 4.2.2
|
deepmerge: 4.2.2
|
||||||
kleur: 4.1.5
|
kleur: 4.1.5
|
||||||
magic-string: 0.26.6
|
magic-string: 0.26.7
|
||||||
svelte: 3.50.1
|
svelte: 3.50.1
|
||||||
svelte-hmr: 0.15.0_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:
|
transitivePeerDependencies:
|
||||||
- supports-color
|
- supports-color
|
||||||
dev: true
|
dev: true
|
||||||
@@ -2029,8 +2029,8 @@ packages:
|
|||||||
sourcemap-codec: 1.4.8
|
sourcemap-codec: 1.4.8
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/magic-string/0.26.6:
|
/magic-string/0.26.7:
|
||||||
resolution: {integrity: sha512-6d+3bFybzyQFJYSoRsl9ZC0wheze8M1LrQC7tNMRqXR4izUTDOLMd9BtSuExK9iAukFh+s5K0WAhc/dlQ+HKYA==}
|
resolution: {integrity: sha512-hX9XH3ziStPoPhJxLq1syWuZMxbDvGNbVchfrdCtanC7D13888bMFow61x8axrx+GfHLtVeAx2kxL7tTGRl+Ow==}
|
||||||
engines: {node: '>=12'}
|
engines: {node: '>=12'}
|
||||||
dependencies:
|
dependencies:
|
||||||
sourcemap-codec: 1.4.8
|
sourcemap-codec: 1.4.8
|
||||||
@@ -3505,8 +3505,8 @@ packages:
|
|||||||
tiny-emitter: 2.1.0
|
tiny-emitter: 2.1.0
|
||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
/vite/3.1.6_sass@1.55.0:
|
/vite/3.1.7_sass@1.55.0:
|
||||||
resolution: {integrity: sha512-qMXIwnehvvcK5XfJiXQUiTxoYAEMKhM+jqCY6ZSTKFBKu1hJnAKEzP3AOcnTerI0cMZYAaJ4wpW1wiXLMDt4mA==}
|
resolution: {integrity: sha512-5vCAmU4S8lyVdFCInu9M54f/g8qbOMakVw5xJ4pjoaDy5wgy9sLLZkGdSLN52dlsBqh0tBqxjaqqa8LgPqwRAA==}
|
||||||
engines: {node: ^14.18.0 || >=16.0.0}
|
engines: {node: ^14.18.0 || >=16.0.0}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { getContext } from 'svelte'
|
import { getContext } from 'svelte'
|
||||||
import { spring } from 'svelte/motion'
|
import { spring } from 'svelte/motion'
|
||||||
import dayjs, { type Dayjs } from 'dayjs'
|
import dayjs from 'dayjs'
|
||||||
import { lerp } from '$utils/functions'
|
import { lerp } from '$utils/functions'
|
||||||
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
|
import { PUBLIC_PREVIEW_COUNT } from '$env/static/public'
|
||||||
import { seenLocations } from '$utils/stores'
|
import { seenLocations } from '$utils/stores'
|
||||||
@@ -23,15 +23,24 @@
|
|||||||
|
|
||||||
// Location date limit
|
// Location date limit
|
||||||
let isNew = false
|
let isNew = false
|
||||||
let dateUpdated: Dayjs
|
|
||||||
const dateNowOffset = dayjs().subtract(settings.limit_new, 'day')
|
const dateNowOffset = dayjs().subtract(settings.limit_new, 'day')
|
||||||
|
const parsedSeenLocations = JSON.parse($seenLocations)
|
||||||
|
|
||||||
$: if (latestPhoto && $seenLocations) {
|
$: if (latestPhoto) {
|
||||||
dateUpdated = dayjs(latestPhoto.date_created)
|
const dateUpdated = dayjs(latestPhoto.date_created)
|
||||||
|
|
||||||
// Detect if location has new content
|
// Detect if location has new content
|
||||||
const seenLocation = JSON.parse($seenLocations)?.hasOwnProperty(location.id)
|
const seenLocationDate = dayjs(parsedSeenLocations[location.id])
|
||||||
isNew = dateUpdated.isAfter(dateNowOffset) && !seenLocation
|
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)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user