Default to using system clock to infer user timezone on js clients

Using system clock to infer user timezone on clients makes Khoj
more robust to provide location aware responses.

Previously only ip based location was used to infer timezone via API.
This didn't provide any decent fallback when calls to ipapi failed or
Khoj was being run in offline mode
This commit is contained in:
Debanjum Singh Solanky
2024-09-30 03:15:50 -07:00
parent 344f3c60ba
commit 04aef362e2
7 changed files with 27 additions and 29 deletions

View File

@@ -2,14 +2,10 @@ import { useEffect, useState } from "react";
import useSWR from "swr";
export interface LocationData {
ip: string;
city: string;
region: string;
country: string;
countryCode: string;
postal: string;
latitude: number;
longitude: number;
city?: string;
region?: string;
country?: string;
countryCode?: string;
timezone: string;
}
@@ -51,9 +47,7 @@ export function useIPLocationData() {
{ revalidateOnFocus: false },
);
if (locationDataError) return null;
if (!locationData) return null;
if (locationDataError || !locationData) return;
return locationData;
}