mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-02-19 23:25:51 -05:00
refactor(settings): remove unnecessary logging and streamline component structure
This commit cleans up the GeneralSettings and Settings components by removing redundant logging statements and the use of the Spacedrive client where it is no longer needed. Additionally, it updates the DeviceInfo type to include a slug field and introduces new types for device configuration updates, enhancing the overall structure and clarity of the codebase.
This commit is contained in:
@@ -13,7 +13,6 @@ import {
|
||||
SpacedriveProvider,
|
||||
ServerProvider,
|
||||
} from "@sd/interface";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import {
|
||||
SpacedriveClient,
|
||||
TauriTransport,
|
||||
@@ -237,9 +236,6 @@ function App() {
|
||||
|
||||
// Route to different UIs based on window type
|
||||
if (route === "/settings") {
|
||||
console.log("[App] Rendering Settings route");
|
||||
console.log("[App] Client for Settings:", client);
|
||||
console.log("[App] Client library ID:", client.getCurrentLibraryId());
|
||||
return (
|
||||
<PlatformProvider platform={platform}>
|
||||
<SpacedriveProvider client={client}>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useCoreQuery, useCoreMutation, useSpacedriveClient } from "../../contexts/SpacedriveContext";
|
||||
import { useEffect } from "react";
|
||||
import { useCoreQuery, useCoreMutation } from "../../contexts/SpacedriveContext";
|
||||
|
||||
interface DeviceSettingsForm {
|
||||
name: string;
|
||||
@@ -8,7 +7,6 @@ interface DeviceSettingsForm {
|
||||
}
|
||||
|
||||
export function GeneralSettings() {
|
||||
const client = useSpacedriveClient();
|
||||
const statusQuery = useCoreQuery({ type: "core.status", input: null as any });
|
||||
const configQuery = useCoreQuery({ type: "config.app.get", input: null as any });
|
||||
const updateDevice = useCoreMutation("device.update");
|
||||
@@ -17,25 +15,6 @@ export function GeneralSettings() {
|
||||
const { data: status } = statusQuery;
|
||||
const { data: config } = configQuery;
|
||||
|
||||
useEffect(() => {
|
||||
console.log("[GeneralSettings] Mounted");
|
||||
console.log("[GeneralSettings] Client:", client);
|
||||
console.log("[GeneralSettings] Status query:", {
|
||||
data: statusQuery.data,
|
||||
isLoading: statusQuery.isLoading,
|
||||
error: statusQuery.error,
|
||||
status: statusQuery.status,
|
||||
fetchStatus: statusQuery.fetchStatus,
|
||||
});
|
||||
console.log("[GeneralSettings] Config query:", {
|
||||
data: configQuery.data,
|
||||
isLoading: configQuery.isLoading,
|
||||
error: configQuery.error,
|
||||
status: configQuery.status,
|
||||
fetchStatus: configQuery.fetchStatus,
|
||||
});
|
||||
}, [client, statusQuery.data, statusQuery.isLoading, statusQuery.error, statusQuery.status, statusQuery.fetchStatus, configQuery.data, configQuery.isLoading, configQuery.error, configQuery.status, configQuery.fetchStatus]);
|
||||
|
||||
const deviceForm = useForm<DeviceSettingsForm>({
|
||||
values: {
|
||||
name: status?.device_info?.name || "",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { useState, useEffect } from "react";
|
||||
import { useState } from "react";
|
||||
import clsx from "clsx";
|
||||
import {
|
||||
GeneralSettings,
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
AboutSettings,
|
||||
} from "../../Settings/pages";
|
||||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
|
||||
import { useSpacedriveClient } from "../../contexts/SpacedriveContext";
|
||||
|
||||
interface SettingsSidebarProps {
|
||||
currentPage: string;
|
||||
@@ -125,14 +124,6 @@ function SettingsContentWrapper() {
|
||||
* Renders immediately since daemon is already connected in main window.
|
||||
*/
|
||||
export function Settings() {
|
||||
const client = useSpacedriveClient();
|
||||
|
||||
useEffect(() => {
|
||||
console.log("[Settings] Component mounted");
|
||||
console.log("[Settings] Client:", client);
|
||||
console.log("[Settings] Current library ID:", client.getCurrentLibraryId());
|
||||
}, [client]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SettingsContentWrapper />
|
||||
|
||||
@@ -677,7 +677,7 @@ connection_method?: ConnectionMethod | null };
|
||||
*/
|
||||
export type DeviceFormFactor = "Desktop" | "Laptop" | "Mobile" | "Tablet" | "Server" | "Other";
|
||||
|
||||
export type DeviceInfo = { id: string; name: string; os: string; hardware_model: string | null; created_at: string };
|
||||
export type DeviceInfo = { id: string; name: string; slug: string; os: string; hardware_model: string | null; created_at: string };
|
||||
|
||||
/**
|
||||
* Device metrics snapshot
|
||||
@@ -4209,6 +4209,32 @@ message: string;
|
||||
*/
|
||||
requires_restart: boolean };
|
||||
|
||||
/**
|
||||
* Input for updating device configuration
|
||||
*/
|
||||
export type UpdateDeviceInput = {
|
||||
/**
|
||||
* Device name
|
||||
*/
|
||||
name?: string | null;
|
||||
/**
|
||||
* Device slug
|
||||
*/
|
||||
slug?: string | null };
|
||||
|
||||
/**
|
||||
* Output from updating device configuration
|
||||
*/
|
||||
export type UpdateDeviceOutput = {
|
||||
/**
|
||||
* Updated device name
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Updated device slug
|
||||
*/
|
||||
slug: string };
|
||||
|
||||
export type UpdateGroupInput = { group_id: string; name: string | null; is_collapsed: boolean | null };
|
||||
|
||||
export type UpdateGroupOutput = { group: SpaceGroup };
|
||||
@@ -4648,6 +4674,7 @@ export type CoreAction =
|
||||
{ type: 'config.app.update'; input: UpdateAppConfigInput; output: UpdateAppConfigOutput }
|
||||
| { type: 'core.ephemeral_reset'; input: EphemeralCacheResetInput; output: EphemeralCacheResetOutput }
|
||||
| { type: 'core.reset'; input: ResetDataInput; output: ResetDataOutput }
|
||||
| { type: 'device.update'; input: UpdateDeviceInput; output: UpdateDeviceOutput }
|
||||
| { type: 'libraries.create'; input: LibraryCreateInput; output: LibraryCreateOutput }
|
||||
| { type: 'libraries.delete'; input: LibraryDeleteInput; output: LibraryDeleteOutput }
|
||||
| { type: 'libraries.open'; input: LibraryOpenInput; output: LibraryOpenOutput }
|
||||
@@ -4765,6 +4792,7 @@ export const WIRE_METHODS = {
|
||||
'config.app.update': 'action:config.app.update.input',
|
||||
'core.ephemeral_reset': 'action:core.ephemeral_reset.input',
|
||||
'core.reset': 'action:core.reset.input',
|
||||
'device.update': 'action:device.update.input',
|
||||
'libraries.create': 'action:libraries.create.input',
|
||||
'libraries.delete': 'action:libraries.delete.input',
|
||||
'libraries.open': 'action:libraries.open.input',
|
||||
|
||||
Reference in New Issue
Block a user