mirror of
https://github.com/khoaliber/khoj.git
synced 2026-03-03 13:19:16 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user