Skip to content

Commit efc02d1

Browse files
authored
Merge pull request #57 from UW-Macrostrat/trips
Trips map load
2 parents 5f6bdc1 + 47e96fd commit efc02d1

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

pages/trip/@id/+data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { rockdApiURL } from "@macrostrat-web/settings";
33

44
export async function data(pageContext) {
55
const data = await fetch(
6-
`${rockdApiURL}/trips/${pageContext.routeParams.id}`
6+
`${rockdApiURL}/trips/${pageContext.routeParams.id}?simple=true`
77
).then((response) => {
88
if (!response.ok) {
99
throw new Error(`HTTP error! status: ${response.status}`);

pages/trip/index.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ import {
1414
PanelCard,
1515
} from "@macrostrat/map-interface";
1616
import { useMapRef } from "@macrostrat/mapbox-react";
17+
import { map } from "underscore";
1718

1819
export function Trips({data, commentsData}) {
1920
const [showSatelite, setSatelite] = useState(false);
20-
console.log("Trips data:", data);
21-
console.log("Comments data:", commentsData);
21+
const [mapLoaded, setMapLoaded] = useState(false);
2222

2323
const style = useMapStyle({showSatelite});
2424

@@ -29,7 +29,7 @@ export function Trips({data, commentsData}) {
2929
data.updated = date.toLocaleDateString('en-US', options);
3030

3131
const toolbar = h(Toolbar, {showSatelite, setSatelite});
32-
const sidebar = h(SideBar, {data, commentsData});
32+
const sidebar = h(SideBar, {data, commentsData, mapLoaded});
3333

3434
if (!sidebar) {
3535
return h("div", { className: 'loading' }, [
@@ -60,7 +60,9 @@ export function Trips({data, commentsData}) {
6060
style: { paddingRight: "calc(30% + 14px)"},
6161
},
6262
[
63-
h(MapView, { style: style, mapboxToken: SETTINGS.mapboxAccessToken, mapPosition: newMapPosition }),
63+
h(MapView, { style: style, mapboxToken: SETTINGS.mapboxAccessToken, mapPosition: newMapPosition, onMapLoaded: () => {
64+
setMapLoaded(true);
65+
}},),
6466
sidebar,
6567
]
6668
),
@@ -102,15 +104,14 @@ function useMapStyle({showSatelite}) {
102104
return showSatelite ? SETTINGS.satelliteMapURL : useDarkMode()?.isEnabled ? SETTINGS.darkMapURL : SETTINGS.whiteMapURL;
103105
}
104106

105-
function SideBar({data, commentsData}) {
107+
function SideBar({data, commentsData, mapLoaded}) {
106108
const mapRef = useMapRef();
107109
const map = mapRef.current;
108110
const profile_pic = h(BlankImage, {src: getProfilePicUrl(data.person_id), className: "profile-pic-header"});
109111
const stops = data.stops;
110112
const [commentsOpen, setCommentsOpen] = useState(false);
111-
console.log("commentsOpen:", commentsOpen);
112113

113-
if(!map) return h("div", {className: "stop-container loading2"}, [
114+
if(!mapLoaded) return h("div", {className: "stop-container loading2"}, [
114115
h("h1", "Loading trip " + data.trip_id + "..."),
115116
h(Spinner, {style: {marginTop: "30px"}})
116117
]);

src/components/general/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,14 +412,14 @@ function Checkin({checkin, mapRef, setInspectPosition, len}) {
412412
}),
413413
h("h3", { className: "likes" }, checkin.likes),
414414
]),
415-
h("div", { className: "observations-container" }, [
415+
h.if(checkin?.observations)("div", { className: "observations-container" }, [
416416
h(Icon, {
417417
className:
418418
"observations-icon " + (isDarkMode ? "icon-dark-mode" : ""),
419419
icon: "camera",
420420
style: { color: "white" },
421421
}),
422-
h("h3", { className: "likes" }, checkin.observations.length),
422+
h("h3", { className: "likes" }, checkin.observations?.length),
423423
]),
424424
h("div", { className: "comments-container" }, [
425425
h(Icon, {

0 commit comments

Comments
 (0)