From 81fe5f4ef2f8ea52665b850f5c3836c59af9bda2 Mon Sep 17 00:00:00 2001 From: Arnab Chakraborty <11457760+Rocky43007@users.noreply.github.com> Date: Tue, 20 Aug 2024 20:52:21 +0300 Subject: [PATCH] First autoformat of the PR --- apps/desktop/src-tauri/Cargo.toml | 14 +++--- .../src-tauri/capabilities/default.json | 4 +- apps/desktop/src-tauri/tauri.conf.json | 20 ++------ .../modules/sd-core/android/crate/src/lib.rs | 6 +-- .../client/AccountSettings/AccountProfile.tsx | 2 +- .../settings/client/AccountSettings/Login.tsx | 11 +++-- .../client/AccountSettings/Register.tsx | 8 ++-- core/crates/cloud-services/src/cloud_p2p.rs | 1 - core/src/api/utils/mod.rs | 2 - core/src/cloud/sync/mod.rs | 9 +--- core/src/cloud/sync/receive.rs | 20 ++------ core/src/cloud/sync/send.rs | 21 ++------- core/src/library/manager/mod.rs | 2 +- .../Layout/Sidebar/DebugPopover.tsx | 2 +- interface/app/$libraryId/TopBar/index.tsx | 4 +- .../settings/client/account/Login.tsx | 1 + .../settings/client/account/Register.tsx | 3 +- .../client/account/handlers/cookieHandler.ts | 24 +++++----- .../client/account/handlers/windowHandler.ts | 46 +++++++++---------- .../settings/node/libraries/ListItem.tsx | 2 +- interface/hooks/useDeeplinkEventHandler.ts | 8 ++-- 21 files changed, 83 insertions(+), 127 deletions(-) diff --git a/apps/desktop/src-tauri/Cargo.toml b/apps/desktop/src-tauri/Cargo.toml index aff69b5e3..f7ccf5b4a 100644 --- a/apps/desktop/src-tauri/Cargo.toml +++ b/apps/desktop/src-tauri/Cargo.toml @@ -34,14 +34,14 @@ uuid = { workspace = true, features = ["serde"] } # Specific Desktop dependencies # WARNING: Do NOT enable default features, as that vendors dbus (see below) -opener = { version = "0.7.1", features = ["reveal"], default-features = false } -specta-typescript = "=0.0.7" -tauri-plugin-dialog = "=2.0.0-rc.0" -tauri-plugin-os = "=2.0.0-rc.0" -tauri-plugin-shell = "=2.0.0-rc.0" -tauri-plugin-updater = "=2.0.0-rc.0" +opener = { version = "0.7.1", features = ["reveal"], default-features = false } +specta-typescript = "=0.0.7" tauri-plugin-deep-link = "=2.0.0-rc.0" -tauri-plugin-http = "2.0.0-rc.0" +tauri-plugin-dialog = "=2.0.0-rc.0" +tauri-plugin-http = "2.0.0-rc.0" +tauri-plugin-os = "=2.0.0-rc.0" +tauri-plugin-shell = "=2.0.0-rc.0" +tauri-plugin-updater = "=2.0.0-rc.0" [dependencies.tauri] features = ["linux-libxdo", "macos-private-api", "native-tls-vendored", "unstable"] diff --git a/apps/desktop/src-tauri/capabilities/default.json b/apps/desktop/src-tauri/capabilities/default.json index 20e0aa609..79b0ef88b 100644 --- a/apps/desktop/src-tauri/capabilities/default.json +++ b/apps/desktop/src-tauri/capabilities/default.json @@ -2,9 +2,7 @@ "$schema": "../gen/schemas/desktop-schema.json", "identifier": "default", "description": "Capability for the main window", - "windows": [ - "main" - ], + "windows": ["main"], "permissions": [ "core:app:default", "core:event:default", diff --git a/apps/desktop/src-tauri/tauri.conf.json b/apps/desktop/src-tauri/tauri.conf.json index 1a4adbbf6..0dc0fe09c 100644 --- a/apps/desktop/src-tauri/tauri.conf.json +++ b/apps/desktop/src-tauri/tauri.conf.json @@ -29,9 +29,7 @@ "transparent": true, "center": true, "windowEffects": { - "effects": [ - "sidebar" - ], + "effects": ["sidebar"], "state": "followsWindowActiveState", "radius": 9 } @@ -43,11 +41,7 @@ }, "bundle": { "active": true, - "targets": [ - "deb", - "msi", - "dmg" - ], + "targets": ["deb", "msi", "dmg"], "publisher": "Spacedrive Technology Inc.", "copyright": "Spacedrive Technology Inc.", "category": "Productivity", @@ -66,11 +60,7 @@ "files": { "/usr/share/spacedrive/models/yolov8s.onnx": "../../.deps/models/yolov8s.onnx" }, - "depends": [ - "libc6", - "libxdo3", - "dbus" - ] + "depends": ["libc6", "libxdo3", "dbus"] } }, "macOS": { @@ -114,9 +104,7 @@ "deep-link": { "mobile": [], "desktop": { - "schemes": [ - "spacedrive" - ] + "schemes": ["spacedrive"] } } } diff --git a/apps/mobile/modules/sd-core/android/crate/src/lib.rs b/apps/mobile/modules/sd-core/android/crate/src/lib.rs index bc8fd2998..81a07b8a8 100644 --- a/apps/mobile/modules/sd-core/android/crate/src/lib.rs +++ b/apps/mobile/modules/sd-core/android/crate/src/lib.rs @@ -37,9 +37,7 @@ pub extern "system" fn Java_com_spacedrive_core_SDCoreModule_registerCoreEventLi if let Err(err) = result { // TODO: Send rspc error or something here so we can show this in the UI. // TODO: Maybe reinitialise the core cause it could be in an invalid state? - error!( - "Error in Java_com_spacedrive_core_SDCoreModule_registerCoreEventListener: {err:?}" - ); + error!("Error in Java_com_spacedrive_core_SDCoreModule_registerCoreEventListener: {err:?}"); } } @@ -109,4 +107,4 @@ pub extern "system" fn Java_com_spacedrive_core_SDCoreModule_handleCoreMsg( err ); } -} \ No newline at end of file +} diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx index d8bc06dd4..2a0599e3c 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/AccountProfile.tsx @@ -43,7 +43,7 @@ const AccountProfile = () => { style={tw`w-full items-center justify-start gap-1 bg-app-input !px-2`} > - + {userInfo ? userInfo.email : ''} diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx index 989fa4e39..b1788772f 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/Login.tsx @@ -1,3 +1,4 @@ +import { useNavigation } from '@react-navigation/native'; import { useState } from 'react'; import { Controller } from 'react-hook-form'; import { Text, View } from 'react-native'; @@ -7,11 +8,15 @@ import { Button } from '~/components/primitive/Button'; import { Input } from '~/components/primitive/Input'; import { toast } from '~/components/primitive/Toast'; import { tw } from '~/lib/tailwind'; -import { useNavigation } from '@react-navigation/native'; import { SettingsStackScreenProps } from '~/navigation/tabs/SettingsStack'; + import ShowPassword from './ShowPassword'; -async function signInClicked(email: string, password: string, navigator: SettingsStackScreenProps<'AccountProfile'>['navigation']) { +async function signInClicked( + email: string, + password: string, + navigator: SettingsStackScreenProps<'AccountProfile'>['navigation'] +) { try { const req = await fetch('http://localhost:9420/api/auth/signin', { method: 'POST', @@ -63,7 +68,7 @@ async function signInClicked(email: string, password: string, navigator: Setting // the frontend SDK. toast.success('Sign in successful'); // Refresh the page to show the user is logged in - navigator.navigate('AccountProfile') + navigator.navigate('AccountProfile'); } } catch (err: any) { if (err.isSuperTokensGeneralError === true) { diff --git a/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx b/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx index 277dde897..e43d355a3 100644 --- a/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx +++ b/apps/mobile/src/screens/settings/client/AccountSettings/Register.tsx @@ -145,10 +145,10 @@ const Register = () => { secureTextEntry={!showPassword} /> + showPassword={showPassword} + setShowPassword={setShowPassword} + plural={true} + /> )} /> diff --git a/core/crates/cloud-services/src/cloud_p2p.rs b/core/crates/cloud-services/src/cloud_p2p.rs index 139597f9c..8b1378917 100644 --- a/core/crates/cloud-services/src/cloud_p2p.rs +++ b/core/crates/cloud-services/src/cloud_p2p.rs @@ -1,2 +1 @@ - diff --git a/core/src/api/utils/mod.rs b/core/src/api/utils/mod.rs index a37888bbd..b12c1ec7e 100644 --- a/core/src/api/utils/mod.rs +++ b/core/src/api/utils/mod.rs @@ -3,9 +3,7 @@ use std::path::Path; // #[cfg(not(any(target_os = "ios", target_os = "android")))] // use keyring::Entry; -use regex::Regex; use tokio::{fs, io}; -use tracing::{debug, error}; mod invalidate; mod library; diff --git a/core/src/cloud/sync/mod.rs b/core/src/cloud/sync/mod.rs index 095b0a5e8..10422b0ff 100644 --- a/core/src/cloud/sync/mod.rs +++ b/core/src/cloud/sync/mod.rs @@ -1,8 +1,4 @@ -use sd_sync::*; -use std::sync::{ - atomic::{self, AtomicBool}, - Arc, -}; +use std::sync::{atomic::AtomicBool, Arc}; use tokio::sync::Notify; use uuid::Uuid; @@ -29,7 +25,6 @@ pub async fn declare_actors( db: Arc, ) -> State { let ingest_notify = Arc::new(Notify::new()); - let state = State::default(); // actors // .declare( @@ -90,7 +85,7 @@ pub async fn declare_actors( // ) // .await; - state + State::default() } macro_rules! err_break { diff --git a/core/src/cloud/sync/receive.rs b/core/src/cloud/sync/receive.rs index 566db53d7..6d8b3fda3 100644 --- a/core/src/cloud/sync/receive.rs +++ b/core/src/cloud/sync/receive.rs @@ -1,34 +1,22 @@ use crate::{library::Libraries, Node}; use futures::FutureExt; -use futures_concurrency::future::Race; use sd_actors::Stopper; -use sd_cloud_api::{library::message_collections::get::InstanceTimestamp, RequestConfigProvider}; use sd_p2p::RemoteIdentity; -use sd_prisma::prisma::{cloud_crdt_operation, instance, PrismaClient, SortOrder}; +use sd_prisma::prisma::{cloud_crdt_operation, instance, PrismaClient}; use sd_sync::CRDTOperation; use sd_utils::uuid_to_bytes; use std::{ - collections::{hash_map::Entry, HashMap}, - future::IntoFuture, - str::FromStr, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - time::Duration, + collections::HashMap, + sync::{atomic::AtomicBool, Arc}, }; -use base64::prelude::*; use chrono::Utc; use serde_json::to_vec; -use tokio::{sync::Notify, time::sleep}; -use tracing::{debug, info}; +use tokio::sync::Notify; use uuid::Uuid; -use super::{err_break, CompressedCRDTOperations}; - // Responsible for downloading sync operations from the cloud to be processed by the ingester #[allow(clippy::too_many_arguments)] diff --git a/core/src/cloud/sync/send.rs b/core/src/cloud/sync/send.rs index aa2944f22..a97958169 100644 --- a/core/src/cloud/sync/send.rs +++ b/core/src/cloud/sync/send.rs @@ -1,27 +1,12 @@ use sd_actors::Stopper; use sd_core_cloud_services::CloudServices; -use sd_core_sync::{SyncMessage, NTP64}; +use sd_core_sync::SyncMessage; -use std::{ - future::IntoFuture, - sync::{ - atomic::{AtomicBool, Ordering}, - Arc, - }, - time::Duration, -}; +use std::sync::{atomic::AtomicBool, Arc}; -use futures::FutureExt; -use futures_concurrency::future::Race; -use tokio::{ - sync::{broadcast, Notify}, - time::sleep, -}; -use tracing::debug; +use tokio::sync::{broadcast, Notify}; use uuid::Uuid; -use super::{err_break, CompressedCRDTOperations}; - enum RaceNotifiedOrStopped { Notified, Stopped, diff --git a/core/src/library/manager/mod.rs b/core/src/library/manager/mod.rs index a8e187f39..b4dddb3db 100644 --- a/core/src/library/manager/mod.rs +++ b/core/src/library/manager/mod.rs @@ -1,6 +1,6 @@ use crate::{ api::{utils::InvalidateOperationEvent, CoreEvent}, - cloud, invalidate_query, + invalidate_query, location::metadata::{LocationMetadataError, SpacedriveLocationMetadataFile}, object::tag, p2p, sync, diff --git a/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx b/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx index 60a46fb70..e1e569b58 100644 --- a/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx +++ b/interface/app/$libraryId/Layout/Sidebar/DebugPopover.tsx @@ -174,7 +174,7 @@ export default () => { {/* */} {/* */} -
+
diff --git a/interface/app/$libraryId/TopBar/index.tsx b/interface/app/$libraryId/TopBar/index.tsx index 3e6afd7a3..d84646775 100644 --- a/interface/app/$libraryId/TopBar/index.tsx +++ b/interface/app/$libraryId/TopBar/index.tsx @@ -138,7 +138,7 @@ function Tabs() { else if (e.button === 1) removeTab(index); }} className={clsx( - 'duration-[50ms] group relative flex h-full min-w-40 shrink-0 flex-row items-center justify-center px-8 text-center', + 'group relative flex h-full min-w-40 shrink-0 flex-row items-center justify-center px-8 text-center duration-[50ms]', ctx.tabIndex === index ? 'text-ink' : 'top-bar-blur border-t border-sidebar-divider bg-sidebar/30 text-ink-faint/60 transition-colors hover:bg-app/50' @@ -166,7 +166,7 @@ function Tabs() { diff --git a/interface/app/$libraryId/settings/client/account/Login.tsx b/interface/app/$libraryId/settings/client/account/Login.tsx index e89837a0e..b64ec4b6c 100644 --- a/interface/app/$libraryId/settings/client/account/Login.tsx +++ b/interface/app/$libraryId/settings/client/account/Login.tsx @@ -3,6 +3,7 @@ import { Controller } from 'react-hook-form'; import { signIn } from 'supertokens-web-js/recipe/emailpassword'; import { nonLibraryClient, useZodForm } from '@sd/client'; import { Button, Form, Input, toast, z } from '@sd/ui'; + import ShowPassword from './ShowPassword'; async function signInClicked(email: string, password: string) { diff --git a/interface/app/$libraryId/settings/client/account/Register.tsx b/interface/app/$libraryId/settings/client/account/Register.tsx index 7e42dbd25..6dbc4ef15 100644 --- a/interface/app/$libraryId/settings/client/account/Register.tsx +++ b/interface/app/$libraryId/settings/client/account/Register.tsx @@ -1,8 +1,9 @@ import { zodResolver } from '@hookform/resolvers/zod'; -import { Button, Form, Input, toast, z } from '@sd/ui'; import { useState } from 'react'; import { Controller, useForm } from 'react-hook-form'; import { signUp } from 'supertokens-web-js/recipe/emailpassword'; +import { Button, Form, Input, toast, z } from '@sd/ui'; + import ShowPassword from './ShowPassword'; const RegisterSchema = z diff --git a/interface/app/$libraryId/settings/client/account/handlers/cookieHandler.ts b/interface/app/$libraryId/settings/client/account/handlers/cookieHandler.ts index a0ca2abe9..4a7362d8e 100644 --- a/interface/app/$libraryId/settings/client/account/handlers/cookieHandler.ts +++ b/interface/app/$libraryId/settings/client/account/handlers/cookieHandler.ts @@ -1,6 +1,6 @@ -import { CookieHandlerInterface } from "supertokens-website/utils/cookieHandler/types"; +import { CookieHandlerInterface } from 'supertokens-website/utils/cookieHandler/types'; -const frontendCookiesKey = "frontendCookies"; +const frontendCookiesKey = 'frontendCookies'; /** * Tauri handles cookies differently than in browser environments. The SuperTokens @@ -12,8 +12,8 @@ function getCookiesFromStorage(): string { const cookiesFromStorage = window.localStorage.getItem(frontendCookiesKey); if (cookiesFromStorage === null) { - window.localStorage.setItem(frontendCookiesKey, "[]"); - return ""; + window.localStorage.setItem(frontendCookiesKey, '[]'); + return ''; } /** @@ -25,20 +25,20 @@ function getCookiesFromStorage(): string { for (let cookieIndex = 0; cookieIndex < cookieArrayInStorage.length; cookieIndex++) { const currentCookieString = cookieArrayInStorage[cookieIndex]; - const parts = currentCookieString?.split(";"); - let expirationString: string = ""; + const parts = currentCookieString?.split(';'); + let expirationString: string = ''; for (let partIndex = 0; partIndex < parts!.length; partIndex++) { const currentPart = parts![partIndex]; - if (currentPart!.toLocaleLowerCase().includes("expires=")) { + if (currentPart!.toLocaleLowerCase().includes('expires=')) { expirationString = currentPart!; break; } } - if (expirationString !== "") { - const expirationValueString = expirationString.split("=")[1]; + if (expirationString !== '') { + const expirationValueString = expirationString.split('=')[1]; const expirationDate = new Date(expirationValueString!); const currentTimeInMillis = Date.now(); @@ -57,11 +57,11 @@ function getCookiesFromStorage(): string { */ window.localStorage.setItem(frontendCookiesKey, JSON.stringify(cookieArrayToReturn)); - return cookieArrayToReturn.join("; "); + return cookieArrayToReturn.join('; '); } function setCookieToStorage(cookieString: string) { - const cookieName = cookieString.split(";")[0]!.split("=")[0]; + const cookieName = cookieString.split(';')[0]!.split('=')[0]; const cookiesFromStorage = window.localStorage.getItem(frontendCookiesKey); let cookiesArray: string[] = []; @@ -105,6 +105,6 @@ export default function getCookieHandler(original: CookieHandlerInterface): Cook }, setCookie: async function (cookieString: string) { setCookieToStorage(cookieString); - }, + } }; } diff --git a/interface/app/$libraryId/settings/client/account/handlers/windowHandler.ts b/interface/app/$libraryId/settings/client/account/handlers/windowHandler.ts index c5f095733..f4d16996d 100644 --- a/interface/app/$libraryId/settings/client/account/handlers/windowHandler.ts +++ b/interface/app/$libraryId/settings/client/account/handlers/windowHandler.ts @@ -1,4 +1,4 @@ -import { WindowHandlerInterface } from "supertokens-website/utils/windowHandler/types"; +import { WindowHandlerInterface } from 'supertokens-website/utils/windowHandler/types'; /** * This example app uses HashRouter from react-router-dom. The SuperTokens SDK relies on @@ -13,76 +13,76 @@ export default function getWindowHandler(original: WindowHandlerInterface): Wind ...original.location, getSearch: function () { const currentURL = window.location.href; - const firstQuestionMarkIndex = currentURL.indexOf("?"); + const firstQuestionMarkIndex = currentURL.indexOf('?'); if (firstQuestionMarkIndex !== -1) { // Return the query string from the url let queryString = currentURL.substring(firstQuestionMarkIndex); // Remove any hash - if (queryString.includes("#")) { - queryString = queryString.split("#")[0] ?? ""; + if (queryString.includes('#')) { + queryString = queryString.split('#')[0] ?? ''; } return queryString; } - return ""; + return ''; }, getHash: function () { // Location hash always starts with a #, when returning we prepend it let locationHash = window.location.hash; - if (locationHash === "") { - return "#"; + if (locationHash === '') { + return '#'; } - if (locationHash.startsWith("#")) { + if (locationHash.startsWith('#')) { // Remove the starting pound symbol locationHash = locationHash.substring(1); } - if (!locationHash.includes("#")) { + if (!locationHash.includes('#')) { // The remaining string did not have any "#" character - return "#"; + return '#'; } - const locationSplit = locationHash.split("#"); + const locationSplit = locationHash.split('#'); if (locationSplit.length < 2) { // The string contains a "#" but is followed by nothing - return "#"; + return '#'; } - return "#" + locationSplit[1]; + return '#' + locationSplit[1]; }, getOrigin: function () { - return "http://localhost:8001"; + return 'http://localhost:8001'; }, getHostName: function () { - return "localhost"; + return 'localhost'; }, getPathName: function () { let locationHash = window.location.hash; - if (locationHash === "") { - return ""; + if (locationHash === '') { + return ''; } - if (locationHash.startsWith("#")) { + if (locationHash.startsWith('#')) { // Remove the starting pound symbol locationHash = locationHash.substring(1); } - locationHash = locationHash.split("?")[0] ?? ""; + locationHash = locationHash.split('?')[0] ?? ''; - if (locationHash.includes("#")) { + if (locationHash.includes('#')) { // Remove location hash - locationHash = locationHash.split("#")[0] ?? ""; + locationHash = locationHash.split('#')[0] ?? ''; } return locationHash; - }, - }, + } + } }; } diff --git a/interface/app/$libraryId/settings/node/libraries/ListItem.tsx b/interface/app/$libraryId/settings/node/libraries/ListItem.tsx index f847355e1..e789c041a 100644 --- a/interface/app/$libraryId/settings/node/libraries/ListItem.tsx +++ b/interface/app/$libraryId/settings/node/libraries/ListItem.tsx @@ -88,7 +88,7 @@ export default (props: Props) => { exit={{ height: 0, opacity: 0 }} className="relative mt-2 flex origin-top flex-col gap-1 pl-8" > -
+
{cloudDevicesList.data?.map( ( diff --git a/interface/hooks/useDeeplinkEventHandler.ts b/interface/hooks/useDeeplinkEventHandler.ts index 728241ee0..16813b05c 100644 --- a/interface/hooks/useDeeplinkEventHandler.ts +++ b/interface/hooks/useDeeplinkEventHandler.ts @@ -1,6 +1,6 @@ -import { useEffect } from "react"; -import { useNavigate } from "react-router"; -import { DeeplinkEvent } from "~/util/events"; +import { useEffect } from 'react'; +import { useNavigate } from 'react-router'; +import { DeeplinkEvent } from '~/util/events'; export const useDeeplinkEventHandler = () => { const navigate = useNavigate(); @@ -17,4 +17,4 @@ export const useDeeplinkEventHandler = () => { document.addEventListener('deeplink', handler); return () => document.removeEventListener('deeplink', handler); }, [navigate]); -} +};