mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-26 22:57:32 +00:00
feat(client): show Dawarich stays, routes and marks where they belong
The trip planner and the journal get a "From Dawarich" list: the stays recorded for those dates, each one a row that can be dismissed or turned into a place or an entry after a review step that shows time, name, note and day. A place that came from a recording carries the Dawarich mark next to its name so its origin stays visible afterwards. The recorded route lies over the trip and journal maps as an overlay, coloured per day and cut along the reader's own timezone rather than UTC. It is fetched for the window on screen and never stored. The Atlas gets its own panel beside the map for the countries and cities the recordings prove, and the wish list is ticked off there, on the day of the visit, undoably. The phone has its own take on all of it, in the mobile shell's colours and with native sheets.
This commit is contained in:
@@ -5,8 +5,10 @@ import Navbar from '../components/Layout/Navbar'
|
||||
import apiClient from '../api/client'
|
||||
import CustomSelect from '../components/shared/CustomSelect'
|
||||
import EmptyState from '../components/shared/EmptyState'
|
||||
import { Globe, MapPin, Briefcase, Calendar, Flag, PanelLeftOpen, PanelLeftClose, X, Star, Plus, Trash2, Search } from 'lucide-react'
|
||||
import { Globe, MapPin, Briefcase, Calendar, Flag, PanelLeftOpen, PanelLeftClose, X, Star, Plus, Trash2, Search, Check } from 'lucide-react'
|
||||
import type { TranslationFn } from '../types'
|
||||
import { Tooltip } from '../components/shared/Tooltip'
|
||||
import DawarichAtlasSidePanel from '../components/Dawarich/DawarichAtlasSidePanel'
|
||||
import { A2_TO_A3, countryCodeToFlag, findBucketDuplicate, isBucketDuplicateError, withCountryMarkedVisited, type AtlasCountry, type AtlasStats, type AtlasData, type CountryDetail } from './atlas/atlasModel'
|
||||
import { continentForCountry } from '@trek/shared'
|
||||
import { useAtlas } from './atlas/useAtlas'
|
||||
@@ -41,10 +43,10 @@ function AtlasPageDesktop(): React.ReactElement {
|
||||
bucketMonth, setBucketMonth, bucketYear, setBucketYear,
|
||||
bucketList, setBucketList, bucketTab, setBucketTab,
|
||||
showBucketAdd, setShowBucketAdd, bucketForm, setBucketForm,
|
||||
handleAddBucketItem, handleDeleteBucketItem, handleBucketPoiSearch, handleSelectBucketPoi,
|
||||
handleAddBucketItem, handleDeleteBucketItem, handleClearBucketVisit, handleBucketPoiSearch, handleSelectBucketPoi,
|
||||
bucketSearchResults, setBucketSearchResults,
|
||||
bucketPoiMonth, setBucketPoiMonth, bucketPoiYear, setBucketPoiYear,
|
||||
bucketSearching, bucketSearch, setBucketSearch,
|
||||
bucketSearching, bucketSearch, setBucketSearch, reloadAfterDawarich,
|
||||
} = useAtlas()
|
||||
const toast = useToast()
|
||||
// Solid surfaces when the user disabled transparency (read at render — the
|
||||
@@ -62,6 +64,17 @@ function AtlasPageDesktop(): React.ReactElement {
|
||||
)
|
||||
}
|
||||
|
||||
// The glass both bottom panels are cut from. One object, because two panels
|
||||
// side by side that differ by a blur radius look like a mistake.
|
||||
const glassPanel: React.CSSProperties = {
|
||||
background: noTransparency ? (dark ? '#15151c' : '#ffffff') : (dark ? 'rgba(10,10,15,0.55)' : 'rgba(255,255,255,0.2)'),
|
||||
backdropFilter: 'blur(24px) saturate(180%)',
|
||||
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
|
||||
border: '1px solid ' + (dark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.06)'),
|
||||
borderRadius: 20,
|
||||
boxShadow: dark ? '0 8px 32px rgba(0,0,0,0.3)' : '0 8px 32px rgba(0,0,0,0.08)',
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-screen overflow-hidden bg-surface">
|
||||
<Navbar />
|
||||
@@ -121,26 +134,36 @@ function AtlasPageDesktop(): React.ReactElement {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Desktop Panel — bottom center, glass effect */}
|
||||
{/* Desktop Panels — bottom center, glass effect.
|
||||
Three columns so the Atlas panel stays exactly centred over the map
|
||||
however wide its neighbour is: Dawarich sits in the left column,
|
||||
right-aligned against the middle one, and stretches to its height. */}
|
||||
<div
|
||||
className="hidden md:grid absolute z-10 items-stretch"
|
||||
style={{
|
||||
bottom: 16,
|
||||
left: 20,
|
||||
right: 20,
|
||||
gridTemplateColumns: '1fr auto 1fr',
|
||||
alignItems: 'stretch',
|
||||
gap: 12,
|
||||
pointerEvents: 'none',
|
||||
}}
|
||||
>
|
||||
<div className="flex justify-end" style={{ pointerEvents: 'auto', minWidth: 0 }}>
|
||||
<DawarichAtlasSidePanel style={glassPanel} dark={dark} onChanged={reloadAfterDawarich} />
|
||||
</div>
|
||||
<div
|
||||
ref={panelRef}
|
||||
onMouseMove={handlePanelMouseMove}
|
||||
onMouseLeave={handlePanelMouseLeave}
|
||||
className="hidden md:flex flex-col absolute z-10 overflow-hidden transition-[width,height,transform,box-shadow] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]"
|
||||
className="hidden md:flex flex-col overflow-hidden transition-[width,height,transform,box-shadow] duration-300 ease-[cubic-bezier(0.23,1,0.32,1)]"
|
||||
style={{
|
||||
bottom: 16,
|
||||
left: '50%',
|
||||
transform: 'translateX(-50%)',
|
||||
...glassPanel,
|
||||
width: 'fit-content',
|
||||
maxWidth: 'calc(100vw - 40px)',
|
||||
background: noTransparency ? (dark ? '#15151c' : '#ffffff') : (dark ? 'rgba(10,10,15,0.55)' : 'rgba(255,255,255,0.2)'),
|
||||
backdropFilter: 'blur(24px) saturate(180%)',
|
||||
WebkitBackdropFilter: 'blur(24px) saturate(180%)',
|
||||
border: '1px solid ' + (dark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.06)'),
|
||||
borderRadius: 20,
|
||||
boxShadow: dark
|
||||
? '0 8px 32px rgba(0,0,0,0.3)'
|
||||
: '0 8px 32px rgba(0,0,0,0.08)',
|
||||
maxWidth: '100%',
|
||||
pointerEvents: 'auto',
|
||||
position: 'relative',
|
||||
}}
|
||||
>
|
||||
{/* Liquid glass glare effect */}
|
||||
@@ -158,6 +181,7 @@ function AtlasPageDesktop(): React.ReactElement {
|
||||
showBucketAdd={showBucketAdd} setShowBucketAdd={setShowBucketAdd}
|
||||
bucketForm={bucketForm} setBucketForm={setBucketForm}
|
||||
onAddBucket={handleAddBucketItem} onDeleteBucket={handleDeleteBucketItem}
|
||||
onClearBucketVisit={handleClearBucketVisit}
|
||||
onSearchBucket={handleBucketPoiSearch} onSelectBucketPoi={handleSelectBucketPoi}
|
||||
bucketSearchResults={bucketSearchResults} setBucketSearchResults={setBucketSearchResults} bucketPoiMonth={bucketPoiMonth} setBucketPoiMonth={setBucketPoiMonth}
|
||||
bucketPoiYear={bucketPoiYear} setBucketPoiYear={setBucketPoiYear} bucketSearching={bucketSearching}
|
||||
@@ -165,6 +189,8 @@ function AtlasPageDesktop(): React.ReactElement {
|
||||
t={t} dark={dark}
|
||||
/>
|
||||
</div>
|
||||
<div aria-hidden />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -463,6 +489,7 @@ interface SidebarContentProps {
|
||||
setBucketForm: (f: { name: string; notes: string; lat: string; lng: string; target_date: string }) => void
|
||||
onAddBucket: () => Promise<void>
|
||||
onDeleteBucket: (id: number) => Promise<void>
|
||||
onClearBucketVisit: (id: number) => void | Promise<void>
|
||||
onSearchBucket: () => Promise<void>
|
||||
onSelectBucketPoi: (result: any) => void
|
||||
bucketSearchResults: any[]
|
||||
@@ -478,7 +505,7 @@ interface SidebarContentProps {
|
||||
dark: boolean
|
||||
}
|
||||
|
||||
function SidebarContent({ data, stats, countries, selectedCountry, countryDetail, resolveName, onTripClick, onUnmarkCountry, bucketList, bucketTab, setBucketTab, showBucketAdd, setShowBucketAdd, bucketForm, setBucketForm, onAddBucket, onDeleteBucket, onSearchBucket, onSelectBucketPoi, bucketSearchResults, setBucketSearchResults, bucketPoiMonth, setBucketPoiMonth, bucketPoiYear, setBucketPoiYear, bucketSearching, bucketSearch, setBucketSearch, t, dark }: SidebarContentProps): React.ReactElement {
|
||||
function SidebarContent({ data, stats, countries, selectedCountry, countryDetail, resolveName, onTripClick, onUnmarkCountry, bucketList, bucketTab, setBucketTab, showBucketAdd, setShowBucketAdd, bucketForm, setBucketForm, onAddBucket, onDeleteBucket, onClearBucketVisit, onSearchBucket, onSelectBucketPoi, bucketSearchResults, setBucketSearchResults, bucketPoiMonth, setBucketPoiMonth, bucketPoiYear, setBucketPoiYear, bucketSearching, bucketSearch, setBucketSearch, t, dark }: SidebarContentProps): React.ReactElement {
|
||||
const { language } = useTranslation()
|
||||
const statsContentRef = useRef<HTMLDivElement>(null)
|
||||
const bucketSearchRowRef = useRef<HTMLDivElement>(null)
|
||||
@@ -552,6 +579,41 @@ function SidebarContent({ data, stats, countries, selectedCountry, countryDetail
|
||||
return <span className="text-[9px] mt-0.5 text-center" style={{ color: tf }}>{label}</span>
|
||||
})()}
|
||||
{!item.target_date && item.notes && <span className="text-[9px] mt-0.5 text-center" style={{ color: tf, maxWidth: 90, overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{item.notes}</span>}
|
||||
{/* Reached (#2279). A tick rather than removing the entry: a wish that
|
||||
came true is the part of the list worth keeping, and the source is
|
||||
named so a recording-derived tick is not mistaken for a manual one. */}
|
||||
{item.visited_at && (
|
||||
<Tooltip
|
||||
label={item.visited_source === 'dawarich'
|
||||
? `${t('dawarich.bucket.visitedFrom')} — ${t('dawarich.bucket.clearVisit')}`
|
||||
: ''}
|
||||
placement="top"
|
||||
>
|
||||
{/* A tick that came from a recording can be taken back here: the
|
||||
wishlist is curated by hand, and a suggestion nobody can undo
|
||||
is not a suggestion. A tick somebody set themselves is text. */}
|
||||
{item.visited_source === 'dawarich' ? (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => { void onClearBucketVisit(item.id) }}
|
||||
aria-label={t('dawarich.bucket.clearVisit')}
|
||||
className="text-success mt-0.5 flex items-center gap-1 hover:opacity-70"
|
||||
style={{ fontSize: 'calc(9px * var(--fs-scale-caption, 1))', background: 'none', border: 'none', padding: 0, cursor: 'pointer', fontFamily: 'inherit' }}
|
||||
>
|
||||
<Check size={9} />
|
||||
{new Date(item.visited_at).toLocaleDateString(language)}
|
||||
</button>
|
||||
) : (
|
||||
<span
|
||||
className="text-success mt-0.5 flex items-center gap-1"
|
||||
style={{ fontSize: 'calc(9px * var(--fs-scale-caption, 1))' }}
|
||||
>
|
||||
<Check size={9} />
|
||||
{new Date(item.visited_at).toLocaleDateString(language)}
|
||||
</span>
|
||||
)}
|
||||
</Tooltip>
|
||||
)}
|
||||
<button type="button" onClick={() => onDeleteBucket(item.id)}
|
||||
className="opacity-0 group-hover:opacity-100"
|
||||
style={{ position: 'absolute', top: 4, right: 4, background: 'none', border: 'none', cursor: 'pointer', padding: 2, color: tf, display: 'flex', transition: 'opacity 0.15s' }}>
|
||||
|
||||
@@ -13,6 +13,7 @@ import {
|
||||
Plus, ChevronUp, ChevronDown, Eye, EyeOff, BookOpen, Image,
|
||||
} from 'lucide-react'
|
||||
import MobileMapTimeline from '../components/Journey/MobileMapTimeline'
|
||||
import DawarichSuggestionsPanel from '../components/Dawarich/DawarichSuggestionsPanel'
|
||||
import MobileEntryView from '../components/Journey/MobileEntryView'
|
||||
import { useJourneyStore } from '../store/journeyStore'
|
||||
import { computeJourneyLifecycle } from '../utils/journeyLifecycle'
|
||||
@@ -379,6 +380,19 @@ function JourneyDetailPageDesktop() {
|
||||
{/* Timeline (desktop only — mobile uses fullscreen combined view above) */}
|
||||
{!isMobile && (
|
||||
<div className={`flex flex-col gap-6 pb-24 md:pb-6${view === 'timeline' ? '' : ' hidden'}`}>
|
||||
{/* Stays Dawarich recorded over this journal's dates, waiting to
|
||||
be turned into entries (#2279). Above the timeline because
|
||||
that is what they become; renders nothing when there is
|
||||
nothing pending. */}
|
||||
{canEditEntries && (
|
||||
<DawarichSuggestionsPanel
|
||||
journals={[{ id: current.id, label: current.title }]}
|
||||
// The entry the acceptance created belongs on the timeline
|
||||
// immediately; re-reading the journey is how it gets there.
|
||||
onAccepted={() => { void loadJourney(current.id) }}
|
||||
/>
|
||||
)}
|
||||
|
||||
{sortedDates.length === 0 && (
|
||||
<EmptyState scene="journey" title={t('journey.detail.noEntries')} />
|
||||
)}
|
||||
|
||||
@@ -7,6 +7,7 @@ import { useSettingsStore } from '../store/settingsStore'
|
||||
import { MapViewAuto as MapView } from '../components/Map/MapViewAuto'
|
||||
import { MapCompassPill, type CompassMap } from '../components/Map/MapCompassPill'
|
||||
import { TripRouteOverviewPill, TripRouteOverviewPanel } from '../components/Map/TripRouteOverview'
|
||||
import { DawarichTrailPill } from '../components/Map/DawarichTrailPill'
|
||||
import { getCached, fetchPhoto } from '../services/photoService'
|
||||
import DayPlanSidebar from '../components/Planner/DayPlanSidebar'
|
||||
import RoadtripModeSwitch from '../components/Roadtrip/RoadtripModeSwitch'
|
||||
@@ -255,6 +256,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
enabledAddons, collabFeatures, tripAccommodations, setTripAccommodations,
|
||||
roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripLineColors, roadtripMapLines, roadtripMapPlaces, collapsedRoadtripDays, toggleRoadtripDay, roadtripCorridor,
|
||||
overviewActive, tripOverview, toggleOverview, overviewShown,
|
||||
dawarichEnabled, dawarichTrailShown, toggleDawarichTrail, dawarichTrail,
|
||||
followTrack, roadtripViaCounts,
|
||||
allowedFileTypes, tripMembers, setTripMembers, refreshMembers, loadAccommodations,
|
||||
TRANSPORT_TYPES, TRIP_TABS, activeTab, setActiveTab, handleTabChange,
|
||||
@@ -406,6 +408,7 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
<div style={{ position: 'absolute', inset: 0 }}>
|
||||
<MapView
|
||||
tripId={tripId}
|
||||
dawarichTrack={dawarichTrail.track}
|
||||
places={roadtripActive ? roadtripMapPlaces : mapPlaces}
|
||||
dayPlaces={dayPlaces}
|
||||
route={roadtripActive ? roadtripMapLines : overviewActive ? tripOverview.lines : route}
|
||||
@@ -484,12 +487,12 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
bottom-left corner, where Leaflet's base-layer switcher sits at
|
||||
z-index 1000 and would cover this. The right corner is free on both
|
||||
renderers — the locate button that lives there is phone-only. */}
|
||||
{!roadtripActive && (
|
||||
{(!roadtripActive || dawarichEnabled) && (
|
||||
<div className="hidden md:flex" style={{
|
||||
position: 'absolute', bottom: 18, right: mapInsetRight + 14, zIndex: 26,
|
||||
pointerEvents: 'none', flexDirection: 'column', alignItems: 'flex-end', gap: 8,
|
||||
}}>
|
||||
{overviewActive && (
|
||||
{!roadtripActive && overviewActive && (
|
||||
<TripRouteOverviewPanel
|
||||
overview={tripOverview}
|
||||
unit={distanceUnit}
|
||||
@@ -497,7 +500,20 @@ function TripPlannerPageDesktop(): React.ReactElement | null {
|
||||
onSelectDay={handleSelectDay}
|
||||
/>
|
||||
)}
|
||||
<TripRouteOverviewPill active={overviewShown} onToggle={toggleOverview} />
|
||||
{!roadtripActive && (
|
||||
<TripRouteOverviewPill active={overviewShown} onToggle={toggleOverview} />
|
||||
)}
|
||||
{/* Stays in road-trip mode, unlike the overview: the route that was
|
||||
actually driven is the thing you most want beside the planned
|
||||
one. It is drawn, never applied — correcting the plan from the
|
||||
recording is a different feature and deliberately not this one. */}
|
||||
{dawarichEnabled && (
|
||||
<DawarichTrailPill
|
||||
active={dawarichTrailShown}
|
||||
status={dawarichTrail.status}
|
||||
onToggle={toggleDawarichTrail}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
|
||||
@@ -154,6 +154,13 @@ function baseState(): HookState {
|
||||
askRefuel: vi.fn(),
|
||||
acceptRefuel: vi.fn(),
|
||||
followTrack: { dayId: null, open: vi.fn(), close: vi.fn(), tracks: [], busy: false, round: 0, error: null, outcome: null, apply: vi.fn(), clear: vi.fn(), viaCount: 0, available: false },
|
||||
// The recorded-route overlay (#2279). Off and empty: the page reads
|
||||
// `dawarichTrail.track` unconditionally, so the fixture has to carry the
|
||||
// shape the hook returns even when the addon is not in play.
|
||||
dawarichEnabled: false,
|
||||
dawarichTrailShown: false,
|
||||
toggleDawarichTrail: vi.fn(),
|
||||
dawarichTrail: { track: null, status: 'idle', reload: vi.fn() },
|
||||
roadtripViaCounts: {},
|
||||
stopDraft: null,
|
||||
setStopDraft: vi.fn(),
|
||||
|
||||
@@ -105,6 +105,10 @@ export interface BucketItem {
|
||||
country_code: string | null
|
||||
notes: string | null
|
||||
target_date: string | null
|
||||
/** ISO-8601 of the stay that fulfilled this wish, or null while it is still a wish. */
|
||||
visited_at?: string | null
|
||||
/** Who decided it was reached: 'manual' or 'dawarich' (#2279). */
|
||||
visited_source?: string | null
|
||||
}
|
||||
|
||||
// Normalize a region name for matching: strip diacritics (the geocoder and the
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useEffect, useMemo, useState, useRef } from 'react'
|
||||
import React, { useCallback, useEffect, useMemo, useState, useRef } from 'react'
|
||||
import { useNavigate } from 'react-router'
|
||||
import { getIntlLanguage, getLocaleForLanguage, useTranslation } from '../../i18n'
|
||||
import { useSettingsStore } from '../../store/settingsStore'
|
||||
@@ -11,6 +11,8 @@ import L from 'leaflet'
|
||||
import type { GeoJsonFeatureCollection } from '../../types'
|
||||
import { A2_TO_A3, countryStatus, findBucketDuplicate, isBucketDuplicateError, isCountryVisible, normalizeRegionName, regionCacheEvictions, withCountryMarkedVisited, wishlistA3Codes, countryColor, REGION_CACHE_MAX, bucketTooltipWidth, bucketTooltipPlacement, bucketTooltipNeedsScroll, type AtlasData, type AtlasPlaceHit, type CountryDetail, type BucketItem } from './atlasModel'
|
||||
import { continentForCountry, escapeHtml, type VisitStatus } from '@trek/shared'
|
||||
import { useGlassGlare } from '../../components/Atlas/useGlassGlare'
|
||||
import { dawarichApi } from '../../api/dawarich'
|
||||
import { useToast } from '../../components/shared/Toast'
|
||||
import { getApiErrorMessage } from '../../types'
|
||||
|
||||
@@ -105,29 +107,11 @@ export function useAtlas() {
|
||||
// kept redrawing itself on every pan for the rest of the session (#1950).
|
||||
const countryRendererRef = useRef<L.Canvas | null>(null)
|
||||
const regionRendererRef = useRef<L.SVG | null>(null)
|
||||
const glareRef = useRef<HTMLDivElement>(null)
|
||||
const borderGlareRef = useRef<HTMLDivElement>(null)
|
||||
const panelRef = useRef<HTMLDivElement>(null)
|
||||
// The panel's hover light, shared with the Dawarich panel beside it.
|
||||
const { panelRef, glareRef, borderGlareRef, onMouseMove: handlePanelMouseMove, onMouseLeave: handlePanelMouseLeave } =
|
||||
useGlassGlare(dark)
|
||||
const country_layer_by_a2_ref = useRef<Record<string, any>>({})
|
||||
|
||||
const handlePanelMouseMove = (e: React.MouseEvent<HTMLDivElement>): void => {
|
||||
if (!panelRef.current || !glareRef.current || !borderGlareRef.current) return
|
||||
const rect = panelRef.current.getBoundingClientRect()
|
||||
const x = e.clientX - rect.left
|
||||
const y = e.clientY - rect.top
|
||||
// Subtle inner glow
|
||||
glareRef.current.style.background = `radial-gradient(circle 300px at ${x}px ${y}px, ${dark ? 'rgba(255,255,255,0.025)' : 'rgba(255,255,255,0.25)'} 0%, transparent 70%)`
|
||||
glareRef.current.style.opacity = '1'
|
||||
// Border glow that follows cursor
|
||||
borderGlareRef.current.style.opacity = '1'
|
||||
borderGlareRef.current.style.maskImage = `radial-gradient(circle 150px at ${x}px ${y}px, black 0%, transparent 100%)`
|
||||
borderGlareRef.current.style.webkitMaskImage = `radial-gradient(circle 150px at ${x}px ${y}px, black 0%, transparent 100%)`
|
||||
}
|
||||
const handlePanelMouseLeave = () => {
|
||||
if (glareRef.current) glareRef.current.style.opacity = '0'
|
||||
if (borderGlareRef.current) borderGlareRef.current.style.opacity = '0'
|
||||
}
|
||||
|
||||
const [data, setData] = useState<AtlasData | null>(null)
|
||||
const [loading, setLoading] = useState<boolean>(true)
|
||||
const [sidebarOpen, setSidebarOpen] = useState<boolean>(true)
|
||||
@@ -224,6 +208,30 @@ export function useAtlas() {
|
||||
}, [geoData, resolveName])
|
||||
|
||||
// Load atlas data + bucket list
|
||||
//
|
||||
// Re-run on `atlasEpoch` so a confirmation made elsewhere on the page — the
|
||||
// Dawarich card ticking wishes off or marking countries (#2279) — lands in the
|
||||
// same numbers the map is drawing, rather than only after a reload.
|
||||
const [atlasEpoch, setAtlasEpoch] = useState(0)
|
||||
const reloadAfterDawarich = useCallback(() => setAtlasEpoch(epoch => epoch + 1), [])
|
||||
|
||||
/**
|
||||
* Undo a wish that a recording ticked off.
|
||||
*
|
||||
* A suggestion that cannot be taken back is not a suggestion, and this one
|
||||
* writes into the wishlist — the one list on this page somebody curates by
|
||||
* hand. The row is kept; only the visit is cleared.
|
||||
*/
|
||||
const handleClearBucketVisit = useCallback(async (itemId: number) => {
|
||||
try {
|
||||
await dawarichApi.clearBucketVisit(itemId)
|
||||
setBucketList(prev => prev.map(item => (
|
||||
item.id === itemId ? { ...item, visited_at: null, visited_source: null } : item
|
||||
)))
|
||||
} catch (err) {
|
||||
toast.error(getApiErrorMessage(err, t('common.error')))
|
||||
}
|
||||
}, [t, toast])
|
||||
useEffect(() => {
|
||||
Promise.all([
|
||||
apiClient.get('/addons/atlas/stats'),
|
||||
@@ -233,7 +241,7 @@ export function useAtlas() {
|
||||
setBucketList(bucketRes.data.items || [])
|
||||
setLoading(false)
|
||||
}).catch(() => setLoading(false))
|
||||
}, [])
|
||||
}, [atlasEpoch])
|
||||
|
||||
// Load country-border GeoJSON from our API (geoBoundaries, served server-side —
|
||||
// no third-party fetch from the browser). Even gzipped the payload is a few MB, so
|
||||
@@ -1176,6 +1184,6 @@ export function useAtlas() {
|
||||
handleAddBucketItem, handleDeleteBucketItem, handleBucketPoiSearch, handleSelectBucketPoi,
|
||||
bucketSearchResults, setBucketSearchResults,
|
||||
bucketPoiMonth, setBucketPoiMonth, bucketPoiYear, setBucketPoiYear,
|
||||
bucketSearching, bucketSearch, setBucketSearch,
|
||||
bucketSearching, bucketSearch, setBucketSearch, reloadAfterDawarich, handleClearBucketVisit,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,8 @@ import { lockBodyScroll } from '../../utils/bodyScrollLock'
|
||||
import type { JourneyEntry } from '../../store/journeyStore'
|
||||
import { createDraftJourneyEntry } from './JourneyDetailPage.helpers'
|
||||
|
||||
import { useDawarichJournalTrail } from '../../hooks/useDawarichJournalTrail'
|
||||
|
||||
/** Stable identity for "this journey draws no trip tracks" (#2194). */
|
||||
const NO_TRACKS: JourneyTrack[] = []
|
||||
|
||||
@@ -371,6 +373,17 @@ export function useJourneyDetail() {
|
||||
return dates
|
||||
}, [current?.trips])
|
||||
|
||||
// The route actually recorded over the journal's own dates (#2279), drawn on
|
||||
// the same layer as the GPX tracks because it is the same kind of thing: a
|
||||
// recording, not a line connecting entries. Gated on `show_trip_tracks` for
|
||||
// the same reason that switch exists — it gates the REQUEST, and a map nobody
|
||||
// asked for should not reach across the network for it.
|
||||
const dawarichTrail = useDawarichJournalTrail(tripDates, showTripTracks)
|
||||
const mapTracks = useMemo(
|
||||
() => (dawarichTrail.tracks.length > 0 ? [...tracks, ...dawarichTrail.tracks] : tracks),
|
||||
[tracks, dawarichTrail.tracks],
|
||||
)
|
||||
|
||||
/** Studio's margin to the window on all four sides — see `.st-root` in studio.css. */
|
||||
const STUDIO_INSET = 16
|
||||
|
||||
@@ -412,7 +425,7 @@ export function useJourneyDetail() {
|
||||
hideSkeletons, setHideSkeletons,
|
||||
mapRef, fullMapRef, galleryUploadRef, galleryProviders, setGalleryProviders, galleryBrowseRef,
|
||||
activeLocationId, handleMarkerClick, handleLocationClick,
|
||||
mapEntries, sidebarMapItems, tripDates, isMobile, tracks,
|
||||
mapEntries, sidebarMapItems, tripDates, isMobile, tracks: mapTracks, dawarichTrail,
|
||||
feedEdge, scrollFeedTo,
|
||||
loadJourney, updateEntry, deleteEntry, reorderEntries, uploadPhotos, deletePhoto,
|
||||
}
|
||||
|
||||
@@ -20,7 +20,8 @@ export function useSettings() {
|
||||
const mcpEnabled = addonEnabled('mcp')
|
||||
const airtrailEnabled = addonEnabled('airtrail')
|
||||
const llmEnabled = addonEnabled('llm_parsing')
|
||||
const hasIntegrations = memoriesEnabled || mcpEnabled || airtrailEnabled || llmEnabled
|
||||
const dawarichEnabled = addonEnabled('dawarich')
|
||||
const hasIntegrations = memoriesEnabled || mcpEnabled || airtrailEnabled || llmEnabled || dawarichEnabled
|
||||
|
||||
const [appVersion, setAppVersion] = useState<string | null>(null)
|
||||
const [activeTab, setActiveTab] = useState('display')
|
||||
|
||||
@@ -31,6 +31,7 @@ import { useDayBoundaries } from '../../components/Roadtrip/useDayBoundaries'
|
||||
import type { DayBoundaryControls } from '../../components/Map/dayBoundaryDrag'
|
||||
import { dayWindow, roadtripInsertion } from '../../components/Roadtrip/dayWindow'
|
||||
import { useTripRouteOverview } from '../../components/Map/useTripRouteOverview'
|
||||
import { useDawarichTrail } from '../../components/Map/useDawarichTrail'
|
||||
import { useRoadtripCorridor } from '../../components/Roadtrip/useRoadtripCorridor'
|
||||
import { useRoadtripVias } from '../../components/Roadtrip/useRoadtripVias'
|
||||
import { useRefuelSearch } from '../../components/Roadtrip/useRefuelSearch'
|
||||
@@ -117,7 +118,7 @@ export function useTripPlanner() {
|
||||
toast.info(t('undo.done', { action: label ?? '' }))
|
||||
}, [undo, lastActionLabel, toast])
|
||||
|
||||
const [enabledAddons, setEnabledAddons] = useState<Record<string, boolean>>({ packing: true, budget: true, documents: true, collab: false, roadtrip: false })
|
||||
const [enabledAddons, setEnabledAddons] = useState<Record<string, boolean>>({ packing: true, budget: true, documents: true, collab: false, roadtrip: false, dawarich: false })
|
||||
// The values above are an optimistic guess until the addon feed answers. The
|
||||
// tab guard below waits for this before evicting anything, so a tab we were
|
||||
// asked to open ('collab' in particular, guessed off) survives the gap.
|
||||
@@ -164,7 +165,7 @@ export function useTripPlanner() {
|
||||
addonsApi.enabled().then(data => {
|
||||
const map: Record<string, boolean> = {}
|
||||
data.addons.forEach(a => { map[a.id] = true })
|
||||
setEnabledAddons({ packing: !!map.packing, budget: !!map.budget, documents: !!map.documents, collab: !!map.collab, roadtrip: !!map.roadtrip })
|
||||
setEnabledAddons({ packing: !!map.packing, budget: !!map.budget, documents: !!map.documents, collab: !!map.collab, roadtrip: !!map.roadtrip, dawarich: !!map.dawarich })
|
||||
if (data.collabFeatures) setCollabFeatures(data.collabFeatures)
|
||||
}).catch(() => {}).finally(() => setAddonsLoaded(true))
|
||||
authApi.getAppConfig().then(config => {
|
||||
@@ -391,6 +392,23 @@ export function useTripPlanner() {
|
||||
return next
|
||||
})
|
||||
}, [tripId])
|
||||
// The recorded route from Dawarich (#2279), per trip and per session for the
|
||||
// same reason as the overview above: it answers "what actually happened on
|
||||
// this trip", which is a question about one trip rather than a preference.
|
||||
const [dawarichTrailShown, setDawarichTrailShown] = useState<boolean>(
|
||||
() => sessionStorage.getItem(`trip-dawarich-${tripId}`) === '1',
|
||||
)
|
||||
const toggleDawarichTrail = useCallback(() => {
|
||||
setDawarichTrailShown(prev => {
|
||||
const next = !prev
|
||||
sessionStorage.setItem(`trip-dawarich-${tripId}`, next ? '1' : '0')
|
||||
return next
|
||||
})
|
||||
}, [tripId])
|
||||
// Fetched here rather than in MapViewAuto so the desktop and the phone share
|
||||
// one request, and so the pill that toggles it can show why there is no line.
|
||||
const dawarichTrail = useDawarichTrail(tripId, dawarichTrailShown)
|
||||
|
||||
const [fitKey, setFitKey] = useState<number>(0)
|
||||
const initialFitTripId = useRef<number | null>(null)
|
||||
const [mobileSidebarOpen, setMobileSidebarOpen] = useState<'left' | 'right' | null>(null)
|
||||
@@ -2177,6 +2195,7 @@ export function useTripPlanner() {
|
||||
enabledAddons, collabFeatures, tripAccommodations, setTripAccommodations,
|
||||
roadtripMode, toggleRoadtripMode, roadtripActive, roadtripRoutes, roadtripLineColors, roadtripMapLines, roadtripMapPlaces, collapsedRoadtripDays, toggleRoadtripDay, roadtripCorridor,
|
||||
overviewShown, toggleOverview, overviewActive, tripOverview,
|
||||
dawarichTrailShown, toggleDawarichTrail, dawarichTrail, dawarichEnabled: !!enabledAddons.dawarich,
|
||||
followTrack, roadtripViaCounts,
|
||||
allowedFileTypes, tripMembers, setTripMembers, refreshMembers, loadAccommodations,
|
||||
TRANSPORT_TYPES, TRIP_TABS, activeTab, setActiveTab, handleTabChange,
|
||||
|
||||
Reference in New Issue
Block a user