Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions src/components/AddQuestionDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@ import {
DialogTrigger,
} from "@/components/ui/dialog";
import { SidebarMenuButton } from "@/components/ui/sidebar-l";
import { addQuestion, isLoading, leafletMapContext } from "@/lib/context";
import {
addQuestion,
defaultCustomQuestions,
isLoading,
leafletMapContext,
} from "@/lib/context";

export const AddQuestionDialog = ({
children,
Expand Down Expand Up @@ -59,7 +64,14 @@ export const AddQuestionDialog = ({
const center = map.getCenter();
addQuestion({
id: "tentacles",
data: { lat: center.lat, lng: center.lng },
data: defaultCustomQuestions.get()
? {
lat: center.lat,
lng: center.lng,
locationType: "custom",
places: [],
}
: { lat: center.lat, lng: center.lng },
});
return true;
};
Expand All @@ -70,7 +82,9 @@ export const AddQuestionDialog = ({
const center = map.getCenter();
addQuestion({
id: "matching",
data: { lat: center.lat, lng: center.lng },
data: defaultCustomQuestions.get()
? { lat: center.lat, lng: center.lng, type: "custom-points" }
: { lat: center.lat, lng: center.lng },
});
return true;
};
Expand All @@ -81,7 +95,9 @@ export const AddQuestionDialog = ({
const center = map.getCenter();
addQuestion({
id: "measuring",
data: { lat: center.lat, lng: center.lng },
data: defaultCustomQuestions.get()
? { lat: center.lat, lng: center.lng, type: "custom-measure" }
: { lat: center.lat, lng: center.lng },
});
return true;
};
Expand Down
15 changes: 15 additions & 0 deletions src/components/OptionDrawers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
customInitPreference,
customPresets,
customStations,
defaultCustomQuestions,
defaultUnit,
disabledStations,
displayHidingZonesOptions,
Expand Down Expand Up @@ -71,6 +72,7 @@ const PASTEBIN_URL_PARAM = "pb";

export const OptionDrawers = ({ className }: { className?: string }) => {
useStore(triggerLocalRefresh);
const $defaultCustomQuestions = useStore(defaultCustomQuestions);
const $defaultUnit = useStore(defaultUnit);
const $animateMapMovements = useStore(animateMapMovements);
const $autoZoom = useStore(autoZoom);
Expand Down Expand Up @@ -577,6 +579,19 @@ export const OptionDrawers = ({ className }: { className?: string }) => {
}
/>
</div>
<div className="flex flex-row items-center gap-2">
<label className="text-2xl font-semibold font-poppins">
Default to custom questions?
</label>
<Checkbox
checked={$defaultCustomQuestions}
onCheckedChange={() =>
defaultCustomQuestions.set(
!$defaultCustomQuestions,
)
}
/>
</div>
<div className="flex flex-row items-center gap-2">
<label className="text-2xl font-semibold font-poppins">
Hider mode?
Expand Down
8 changes: 8 additions & 0 deletions src/lib/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,14 @@ export const followMe = persistentAtom<boolean>("followMe", false, {
encode: JSON.stringify,
decode: JSON.parse,
});
export const defaultCustomQuestions = persistentAtom<boolean>(
"defaultCustomQuestions",
false,
{
encode: JSON.stringify,
decode: JSON.parse,
},
);

export const pastebinApiKey = persistentAtom<string>("pastebinApiKey", "");
export const alwaysUsePastebin = persistentAtom<boolean>(
Expand Down