Skip to content

Commit 2c9cc5b

Browse files
committed
feat: enhance type definitions for tooltips and improve dependency arrays in hooks
1 parent 2b043ac commit 2c9cc5b

8 files changed

Lines changed: 27 additions & 16 deletions

File tree

src/pages/Dashboard/AppRankingChart.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ import {
1111
import { useStatsStore } from "@/stores/statsStore";
1212
import { formatDuration, appColor } from "@/utils/format";
1313

14-
const CustomTooltip = ({ active, payload }: any) => {
14+
interface AppRankingTooltipProps {
15+
active?: boolean;
16+
payload?: Array<{ payload: { app_name: string; total_seconds: number } }>;
17+
}
18+
19+
const CustomTooltip = ({ active, payload }: AppRankingTooltipProps) => {
1520
if (active && payload && payload.length) {
1621
const { app_name, total_seconds } = payload[0].payload;
1722
return (

src/pages/Dashboard/CategoryInsights.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ export default function CategoryInsights() {
2222
const { t } = useTranslation(["dashboard", "categories"]);
2323
const { categoryTotals, categoryDailyTotals } = useStatsStore();
2424

25-
const localizeCategory = (category: string) =>
26-
t(`categories:presets.${category}`, { defaultValue: category } as Record<string, unknown>);
27-
2825
const pieData = useMemo(
2926
() => categoryTotals.slice(0, 8).map((row) => ({
3027
...row,
31-
categoryLabel: localizeCategory(row.category),
28+
categoryLabel: t(`categories:presets.${row.category}`, { defaultValue: row.category } as Record<string, unknown>),
3229
})),
33-
[categoryTotals]
30+
[categoryTotals, t]
3431
);
3532

3633
const trendData = useMemo(() => {
@@ -100,7 +97,10 @@ export default function CategoryInsights() {
10097
<AreaChart data={trendData} margin={{ top: 6, right: 12, left: -20, bottom: 0 }}>
10198
<XAxis dataKey="date" tick={{ fill: "#6b7280", fontSize: 10 }} axisLine={false} tickLine={false} />
10299
<YAxis hide />
103-
<Tooltip formatter={(v: number, name: string) => [formatDuration(v), localizeCategory(name)]} />
100+
<Tooltip formatter={(v: number, name: string) => [
101+
formatDuration(v),
102+
t(`categories:presets.${name}`, { defaultValue: name } as Record<string, unknown>),
103+
]} />
104104
{categories.map((c, idx) => (
105105
<Area
106106
key={c}

src/pages/Dashboard/HourlyTimeline.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,13 @@ import {
1010
} from "recharts";
1111
import { useStatsStore } from "@/stores/statsStore";
1212

13-
const CustomTooltip = ({ active, payload, label }: any) => {
13+
interface HourlyTooltipProps {
14+
active?: boolean;
15+
label?: string | number;
16+
payload?: Array<{ value?: number }>;
17+
}
18+
19+
const CustomTooltip = ({ active, payload, label }: HourlyTooltipProps) => {
1420
if (active && payload && payload.length) {
1521
const minutes = Math.round((payload[0].value as number) / 60);
1622
return (

src/pages/Dashboard/UnifiedTimeline.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default function UnifiedTimeline({ selectedDate, periodMode, rangeStart,
135135
}
136136

137137
return rows.sort((a, b) => new Date(b.at).getTime() - new Date(a.at).getTime());
138-
}, [browserSessions, focusSessions, interruptions, periodMode, selectedDate, t]);
138+
}, [browserSessions, focusSessions, interruptions, periodMode, rangeEnd, rangeStart, selectedDate, t]);
139139

140140
const filtered = useMemo(() => {
141141
let rows = events;

src/pages/Settings/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export default function Settings() {
170170
const [currentProfile, setCurrentProfile] = useState<string>("default");
171171
const [profileDialogOpen, setProfileDialogOpen] = useState(false);
172172
const [newProfileName, setNewProfileName] = useState("");
173-
const [profilesBusy, setProfilesBusy] = useState(false);
173+
const [profilesBusy, setProfilesBusy] = useState<boolean>();
174174

175175
// v2.0.0 legacy data import state
176176
const [legacyDataInfo, setLegacyDataInfo] = useState<LegacyDataInfo | null>(null);
@@ -429,7 +429,7 @@ export default function Settings() {
429429
}
430430
};
431431
void loadWidgetPermissions();
432-
}, []);
432+
}, [excludeTimelens, setIdleTimePolicy, setIgnoreSystemProcesses, setTrackWindowTitles]);
433433

434434
// Load per-widget auto-blur preferences when the widget list is known.
435435
useEffect(() => {
@@ -782,7 +782,7 @@ export default function Settings() {
782782
})();
783783
}, [legacyDataInfo, t, handleImportLegacyData, tauriConfirm]);
784784

785-
const handleCreateProfile = async () => {
785+
async function handleCreateProfile() {
786786
const name = newProfileName.trim();
787787
if (!name) return;
788788
setProfilesBusy(true);
@@ -796,7 +796,7 @@ export default function Settings() {
796796
} finally {
797797
setProfilesBusy(false);
798798
}
799-
};
799+
}
800800

801801
// v2.0.0 encryption
802802
const refreshEncryptionStatus = async () => {

src/stores/widgetStore.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface WidgetStore {
1414
updateWidgetConfig: (config: WidgetConfig) => Promise<void>;
1515
}
1616

17-
export const useWidgetStore = create<WidgetStore>((set, get) => ({
17+
export const useWidgetStore = create<WidgetStore>((set) => ({
1818
widgets: [],
1919
loading: false,
2020

src/widgets/TimerWidget.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export default function TimerWidget({ widgetId: _widgetId }: Props) {
7272

7373
useEffect(() => {
7474
reset();
75-
}, [mode, phase]);
75+
}, [mode, phase, reset]);
7676

7777
useEffect(() => {
7878
if (!running) {

src/widgets/WidgetWindow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ export default function WidgetWindow({ widgetId }: Props) {
165165
window.removeEventListener("mousedown", restoreOnMouseDown);
166166
if (positionSaveTimer.current) clearTimeout(positionSaveTimer.current);
167167
};
168-
}, [widgetId]);
168+
}, [widgetId, win]);
169169

170170
useEffect(() => {
171171
let unlisten: (() => void) | undefined;

0 commit comments

Comments
 (0)