Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
yuiseki committed Nov 9, 2024
1 parent 3037cad commit 091d8af
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export default function Home() {
>(undefined);

// maps ref and state
const mapRef = useRef<MapRef | null>(null);
const [mapTitle, setMapTitle] = useState<string | undefined>(undefined);
const mapRef = useRef<MapRef | null>(null);
const [geojsonWithStyleList, setGeojsonWithStyleList] = useState<
Array<{ id: string; style: TridentMapsStyle; geojson: FeatureCollection }>
>([]);
Expand Down Expand Up @@ -156,7 +156,9 @@ export default function Home() {
} = parseInnerResJson(innerResJson);

if (linesWithTitle.length > 0) {
setMapTitle(linesWithTitle[0].split(":")[1]);
const newMapTitle = linesWithTitle[0].split(":")[1];
setMapTitle(newMapTitle);
setPageTitle(newMapTitle ? `${newMapTitle} | TRIDENT` : "TRIDENT");
}

linesWithAreaAndOrConcern.map(async (line: string, idx: number) => {
Expand Down Expand Up @@ -227,18 +229,6 @@ export default function Home() {
[inputText, insertNewDialogue, pastMessages, scrollToBottom]
);

const onSelectSuggestions = useCallback(
async (value: string) => {
setResponding(true);
await onSubmit(value);
},
[onSubmit]
);

useEffect(() => {
setPageTitle(mapTitle ? `${mapTitle} | TRIDENT` : "TRIDENT");
}, [mapTitle]);

// fit bounds to all geojson in the geojsonWithStyleList
useEffect(() => {
setTimeout(() => {
Expand Down Expand Up @@ -394,7 +384,10 @@ export default function Home() {
<LocationProvider locationInfo={{ location: location }}>
{dialogueList.length === 1 && inputText.length === 0 && (
<InputSuggest
onSelect={onSelectSuggestions}
onSelect={(value: string) => {
setInputText(value);
onSubmit(value);
}}
onChangeLocation={(v) => {
setLocation(v);
}}
Expand All @@ -409,7 +402,10 @@ export default function Home() {
onUpdateSuggestions={() => {
scrollToBottom();
}}
onSelect={onSelectSuggestions}
onSelect={(value: string) => {
setInputText(value);
onSubmit(value);
}}
/>
)}
</LocationProvider>
Expand Down

0 comments on commit 091d8af

Please sign in to comment.