feat: polish release v2 experience (#6800)
This commit is contained in:
1 parent
925b0fb801
commit
a4a903d7c3
295 files changed
+10627
-7115
No files matched your search
@@ -0,0 +1,20 @@
|
||||
"use client";
|
||||
|
||||
import { useMemo } from "react";
|
||||
|
||||
import { formatByteRate, formatBytes, formatBytesPair } from "@homarr/common";
|
||||
|
||||
import { useSettings } from "./context";
|
||||
|
||||
export const useByteFormatter = () => {
|
||||
const { byteUnitSystem } = useSettings();
|
||||
|
||||
return useMemo(
|
||||
() => ({
|
||||
formatBytes: (bytes: number) => formatBytes(bytes, { unit: byteUnitSystem }),
|
||||
formatBytesPair: (used: number, total: number) => formatBytesPair(used, total, { unit: byteUnitSystem }),
|
||||
formatByteRate: (bytes: number) => formatByteRate(bytes, { unit: byteUnitSystem }),
|
||||
}),
|
||||
[byteUnitSystem],
|
||||
);
|
||||
};
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { User } from "@homarr/db/schema";
|
||||
import { defaultByteUnitSystem } from "@homarr/common";
|
||||
import type { ServerSettings } from "@homarr/server-settings";
|
||||
import { parseBrandingSettings } from "@homarr/server-settings";
|
||||
import type { HeaderPreferences } from "@homarr/validation/user";
|
||||
@@ -11,6 +12,7 @@ export type SettingsContextProps = Omit<
|
||||
| "defaultSearchEngineId"
|
||||
| "homeBoardId"
|
||||
| "mobileHomeBoardId"
|
||||
| "byteUnitSystem"
|
||||
| "openSearchInNewTab"
|
||||
| "ddgBangs"
|
||||
| "pingIconsEnabled"
|
||||
@@ -42,6 +44,7 @@ export type UserSettings = Pick<
|
||||
| "defaultSearchEngineId"
|
||||
| "homeBoardId"
|
||||
| "mobileHomeBoardId"
|
||||
| "byteUnitSystem"
|
||||
| "openSearchInNewTab"
|
||||
| "ddgBangs"
|
||||
| "pingIconsEnabled"
|
||||
@@ -59,6 +62,7 @@ export const createSettings = ({
|
||||
defaultSearchEngineId: user?.defaultSearchEngineId ?? serverSettings.search.defaultSearchEngineId,
|
||||
openSearchInNewTab: user?.openSearchInNewTab ?? true,
|
||||
ddgBangs: user?.ddgBangs ?? true,
|
||||
byteUnitSystem: user?.byteUnitSystem ?? defaultByteUnitSystem,
|
||||
firstDayOfWeek: user?.firstDayOfWeek ?? (1 as const),
|
||||
homeBoardId: user?.homeBoardId ?? serverSettings.board.homeBoardId,
|
||||
mobileHomeBoardId: user?.mobileHomeBoardId ?? serverSettings.board.mobileHomeBoardId,
|
||||
|
||||
@@ -35,6 +35,13 @@ export const userPreferenceDefinitions = [
|
||||
mutationGroup: "firstDayOfWeek",
|
||||
aliases: ["calendar", "week", "weekday"],
|
||||
},
|
||||
{
|
||||
key: "byteUnitSystem",
|
||||
kind: "select",
|
||||
guest: false,
|
||||
mutationGroup: "byteUnitSystem",
|
||||
aliases: ["data", "size", "storage", "unit", "binary", "decimal", "GB", "GiB"],
|
||||
},
|
||||
{
|
||||
key: "homeBoardId",
|
||||
kind: "board",
|
||||
|
||||
Reference in new issue
Block a user