mirror of
https://github.com/spacedriveapp/spacedrive
synced 2024-07-04 12:13:27 +00:00
parent
6b760b0b2a
commit
504242f97e
|
@ -78,15 +78,26 @@ pub(crate) fn mount() -> AlphaRouter<Ctx> {
|
||||||
.procedure("active", {
|
.procedure("active", {
|
||||||
R.with2(library())
|
R.with2(library())
|
||||||
.subscription(|(_, library), _: ()| async move {
|
.subscription(|(_, library), _: ()| async move {
|
||||||
|
#[derive(serde::Serialize, specta::Type)]
|
||||||
|
#[specta(rename = "SyncStatus")]
|
||||||
|
struct Data {
|
||||||
|
ingest: bool,
|
||||||
|
cloud_send: bool,
|
||||||
|
cloud_receive: bool,
|
||||||
|
cloud_ingest: bool,
|
||||||
|
}
|
||||||
|
|
||||||
async_stream::stream! {
|
async_stream::stream! {
|
||||||
let cloud_sync = &library.cloud.sync;
|
let cloud_sync = &library.cloud.sync;
|
||||||
let sync = &library.sync.shared;
|
let sync = &library.sync.shared;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
yield sync.active.load(Ordering::Relaxed)
|
yield Data {
|
||||||
|| cloud_sync.send_active.load(Ordering::Relaxed)
|
ingest: sync.active.load(Ordering::Relaxed),
|
||||||
|| cloud_sync.receive_active.load(Ordering::Relaxed)
|
cloud_send: cloud_sync.send_active.load(Ordering::Relaxed),
|
||||||
|| cloud_sync.ingest_active.load(Ordering::Relaxed);
|
cloud_receive: cloud_sync.receive_active.load(Ordering::Relaxed),
|
||||||
|
cloud_ingest: cloud_sync.ingest_active.load(Ordering::Relaxed),
|
||||||
|
};
|
||||||
|
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = cloud_sync.notifier.notified() => {},
|
_ = cloud_sync.notifier.notified() => {},
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
|
import { inferSubscriptionResult } from '@oscartbeaumont-sd/rspc-client';
|
||||||
import { Gear } from '@phosphor-icons/react';
|
import { Gear } from '@phosphor-icons/react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router';
|
import { useNavigate } from 'react-router';
|
||||||
import {
|
import {
|
||||||
JobManagerContextProvider,
|
JobManagerContextProvider,
|
||||||
LibraryContextProvider,
|
LibraryContextProvider,
|
||||||
|
Procedures,
|
||||||
useClientContext,
|
useClientContext,
|
||||||
useDebugState,
|
useDebugState,
|
||||||
useLibrarySubscription
|
useLibrarySubscription,
|
||||||
|
useUnsafeStreamedQuery
|
||||||
} from '@sd/client';
|
} from '@sd/client';
|
||||||
import { Button, ButtonLink, Popover, Tooltip, usePopover } from '@sd/ui';
|
import { Button, ButtonLink, Popover, Tooltip, usePopover } from '@sd/ui';
|
||||||
import { useKeysMatcher, useLocale, useShortcut } from '~/hooks';
|
import { useKeysMatcher, useLocale, useShortcut } from '~/hooks';
|
||||||
|
@ -115,10 +118,10 @@ export default () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
function SyncStatusIndicator() {
|
function SyncStatusIndicator() {
|
||||||
const [syncing, setSyncing] = useState(false);
|
const [status, setStatus] = useState<inferSubscriptionResult<Procedures, 'sync.active'>>();
|
||||||
|
|
||||||
useLibrarySubscription(['sync.active'], {
|
useLibrarySubscription(['sync.active'], {
|
||||||
onData: setSyncing
|
onData: setStatus
|
||||||
});
|
});
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -138,7 +138,7 @@ export type Procedures = {
|
||||||
{ key: "notifications.listen", input: never, result: Notification } |
|
{ key: "notifications.listen", input: never, result: Notification } |
|
||||||
{ key: "p2p.events", input: never, result: P2PEvent } |
|
{ key: "p2p.events", input: never, result: P2PEvent } |
|
||||||
{ key: "search.ephemeralPaths", input: LibraryArgs<EphemeralPathSearchArgs>, result: EphemeralPathsResultItem } |
|
{ key: "search.ephemeralPaths", input: LibraryArgs<EphemeralPathSearchArgs>, result: EphemeralPathsResultItem } |
|
||||||
{ key: "sync.active", input: LibraryArgs<null>, result: boolean } |
|
{ key: "sync.active", input: LibraryArgs<null>, result: SyncStatus } |
|
||||||
{ key: "sync.newMessage", input: LibraryArgs<null>, result: null }
|
{ key: "sync.newMessage", input: LibraryArgs<null>, result: null }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -598,6 +598,8 @@ export type Statistics = { id: number; date_captured: string; total_object_count
|
||||||
|
|
||||||
export type StatisticsResponse = { statistics: Statistics | null }
|
export type StatisticsResponse = { statistics: Statistics | null }
|
||||||
|
|
||||||
|
export type SyncStatus = { ingest: boolean; cloud_send: boolean; cloud_receive: boolean; cloud_ingest: boolean }
|
||||||
|
|
||||||
export type SystemLocations = { desktop: string | null; documents: string | null; downloads: string | null; pictures: string | null; music: string | null; videos: string | null }
|
export type SystemLocations = { desktop: string | null; documents: string | null; downloads: string | null; pictures: string | null; music: string | null; videos: string | null }
|
||||||
|
|
||||||
export type Tag = { id: number; pub_id: number[]; name: string | null; color: string | null; is_hidden: boolean | null; date_created: string | null; date_modified: string | null }
|
export type Tag = { id: number; pub_id: number[]; name: string | null; color: string | null; is_hidden: boolean | null; date_created: string | null; date_modified: string | null }
|
||||||
|
|
Loading…
Reference in a new issue