Skip to content

Commit eca2de1

Browse files
committed
"Default to custom questions" mode
1 parent b3f9137 commit eca2de1

3 files changed

Lines changed: 43 additions & 4 deletions

File tree

src/components/AddQuestionDialog.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import {
1111
DialogTrigger,
1212
} from "@/components/ui/dialog";
1313
import { SidebarMenuButton } from "@/components/ui/sidebar-l";
14-
import { addQuestion, isLoading, leafletMapContext } from "@/lib/context";
14+
import {
15+
addQuestion,
16+
defaultCustomQuestions,
17+
isLoading,
18+
leafletMapContext,
19+
} from "@/lib/context";
1520

1621
export const AddQuestionDialog = ({
1722
children,
@@ -59,7 +64,14 @@ export const AddQuestionDialog = ({
5964
const center = map.getCenter();
6065
addQuestion({
6166
id: "tentacles",
62-
data: { lat: center.lat, lng: center.lng },
67+
data: defaultCustomQuestions.get()
68+
? {
69+
lat: center.lat,
70+
lng: center.lng,
71+
locationType: "custom",
72+
places: [],
73+
}
74+
: { lat: center.lat, lng: center.lng },
6375
});
6476
return true;
6577
};
@@ -70,7 +82,9 @@ export const AddQuestionDialog = ({
7082
const center = map.getCenter();
7183
addQuestion({
7284
id: "matching",
73-
data: { lat: center.lat, lng: center.lng },
85+
data: defaultCustomQuestions.get()
86+
? { lat: center.lat, lng: center.lng, type: "custom-points" }
87+
: { lat: center.lat, lng: center.lng },
7488
});
7589
return true;
7690
};
@@ -81,7 +95,9 @@ export const AddQuestionDialog = ({
8195
const center = map.getCenter();
8296
addQuestion({
8397
id: "measuring",
84-
data: { lat: center.lat, lng: center.lng },
98+
data: defaultCustomQuestions.get()
99+
? { lat: center.lat, lng: center.lng, type: "custom-measure" }
100+
: { lat: center.lat, lng: center.lng },
85101
});
86102
return true;
87103
};

src/components/OptionDrawers.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import {
1919
customInitPreference,
2020
customPresets,
2121
customStations,
22+
defaultCustomQuestions,
2223
defaultUnit,
2324
disabledStations,
2425
displayHidingZonesOptions,
@@ -71,6 +72,7 @@ const PASTEBIN_URL_PARAM = "pb";
7172

7273
export const OptionDrawers = ({ className }: { className?: string }) => {
7374
useStore(triggerLocalRefresh);
75+
const $defaultCustomQuestions = useStore(defaultCustomQuestions);
7476
const $defaultUnit = useStore(defaultUnit);
7577
const $animateMapMovements = useStore(animateMapMovements);
7678
const $autoZoom = useStore(autoZoom);
@@ -577,6 +579,19 @@ export const OptionDrawers = ({ className }: { className?: string }) => {
577579
}
578580
/>
579581
</div>
582+
<div className="flex flex-row items-center gap-2">
583+
<label className="text-2xl font-semibold font-poppins">
584+
Default to custom questions?
585+
</label>
586+
<Checkbox
587+
checked={$defaultCustomQuestions}
588+
onCheckedChange={() =>
589+
defaultCustomQuestions.set(
590+
!$defaultCustomQuestions,
591+
)
592+
}
593+
/>
594+
</div>
580595
<div className="flex flex-row items-center gap-2">
581596
<label className="text-2xl font-semibold font-poppins">
582597
Hider mode?

src/lib/context.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,14 @@ export const followMe = persistentAtom<boolean>("followMe", false, {
336336
encode: JSON.stringify,
337337
decode: JSON.parse,
338338
});
339+
export const defaultCustomQuestions = persistentAtom<boolean>(
340+
"defaultCustomQuestions",
341+
false,
342+
{
343+
encode: JSON.stringify,
344+
decode: JSON.parse,
345+
},
346+
);
339347

340348
export const pastebinApiKey = persistentAtom<string>("pastebinApiKey", "");
341349
export const alwaysUsePastebin = persistentAtom<boolean>(

0 commit comments

Comments
 (0)