mirror of
https://github.com/spacedriveapp/spacedrive.git
synced 2026-04-21 06:59:17 -04:00
Fix type errors & add notif logging on mobile
This commit is contained in:
2
apps/desktop/src/commands.ts
generated
2
apps/desktop/src/commands.ts
generated
@@ -203,7 +203,7 @@ export type Update = { version: string };
|
||||
type __EventObj__<T> = {
|
||||
listen: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.listen<T>>;
|
||||
once: (cb: TAURI_API_EVENT.EventCallback<T>) => ReturnType<typeof TAURI_API_EVENT.once<T>>;
|
||||
emit: T extends null
|
||||
emit: null extends T
|
||||
? (payload?: T) => ReturnType<typeof TAURI_API_EVENT.emit>
|
||||
: (payload: T) => ReturnType<typeof TAURI_API_EVENT.emit>;
|
||||
};
|
||||
|
||||
@@ -26,6 +26,7 @@ import {
|
||||
P2PContextProvider,
|
||||
RspcProvider,
|
||||
useBridgeQuery,
|
||||
useBridgeSubscription,
|
||||
useClientContext,
|
||||
useInvalidateQuery,
|
||||
usePlausibleEvent,
|
||||
@@ -34,7 +35,7 @@ import {
|
||||
} from '@sd/client';
|
||||
|
||||
import { GlobalModals } from './components/modal/GlobalModals';
|
||||
import { Toast, toastConfig } from './components/primitive/Toast';
|
||||
import { toast, Toast, toastConfig } from './components/primitive/Toast';
|
||||
import { useTheme } from './hooks/useTheme';
|
||||
import { changeTwTheme, tw } from './lib/tailwind';
|
||||
import RootNavigator from './navigation';
|
||||
@@ -131,6 +132,20 @@ function AppContainer() {
|
||||
useInvalidateQuery();
|
||||
|
||||
const { id } = useSnapshot(currentLibraryStore);
|
||||
useBridgeSubscription(['cloud.listenCloudServicesNotifications'], {
|
||||
onData: (d) => {
|
||||
console.log('Received cloud service notification', d);
|
||||
switch (d.kind) {
|
||||
case 'ReceivedJoinSyncGroupRequest':
|
||||
// TODO: Show modal to accept or reject
|
||||
break;
|
||||
default:
|
||||
// TODO: Show notification/toast for other kinds
|
||||
toast.info(`Cloud Service Notification -> ${d.kind}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return (
|
||||
<SafeAreaProvider style={tw`flex-1 bg-black`}>
|
||||
|
||||
@@ -117,8 +117,8 @@ const Devices = ({ node, stats }: Props) => {
|
||||
name={device.name}
|
||||
// TODO (Optional): Use Brand Type for Different Android Models/iOS Models using DeviceInfo.getBrand()
|
||||
icon={hardwareModelToIcon(device.hardware_model)}
|
||||
totalSpace={device.storage_size.toString()}
|
||||
freeSpace={(device.storage_size - device.used_storage).toString()}
|
||||
totalSpace={"0"}
|
||||
freeSpace={"0"}
|
||||
color="#0362FF"
|
||||
connectionType={'cloud'}
|
||||
/>
|
||||
|
||||
@@ -39,9 +39,7 @@ const DebugScreen = ({ navigation }: SettingsStackScreenProps<'Debug'>) => {
|
||||
'cloud.syncGroups.get',
|
||||
{
|
||||
pub_id: '0192376a-19ff-73a0-98ac-c4fa4043d401',
|
||||
with_library: true,
|
||||
with_devices: true,
|
||||
with_used_storage: true
|
||||
kind: 'FullData'
|
||||
}
|
||||
]);
|
||||
// console.log(getGroup.data);
|
||||
|
||||
@@ -40,15 +40,13 @@ const Profile = ({
|
||||
const addLibraryToCloud = useLibraryMutation('cloud.libraries.create');
|
||||
const listLibraries = useBridgeQuery(['cloud.libraries.list', true]);
|
||||
const createSyncGroup = useLibraryMutation('cloud.syncGroups.create');
|
||||
const listSyncGroups = useBridgeQuery(['cloud.syncGroups.list', true]);
|
||||
const listSyncGroups = useBridgeQuery(['cloud.syncGroups.list']);
|
||||
const requestJoinSyncGroup = useBridgeMutation('cloud.syncGroups.request_join');
|
||||
const getGroup = useBridgeQuery([
|
||||
'cloud.syncGroups.get',
|
||||
{
|
||||
pub_id: '019237a1-586c-7651-afd3-525047b02375',
|
||||
with_library: true,
|
||||
with_devices: true,
|
||||
with_used_storage: true
|
||||
kind: 'FullData'
|
||||
}
|
||||
]);
|
||||
const currentDevice = useBridgeQuery(['cloud.devices.get_current_device']);
|
||||
@@ -178,8 +176,8 @@ const Profile = ({
|
||||
name={device.name}
|
||||
// TODO (Optional): Use Brand Type for Different Android Models/iOS Models using DeviceInfo.getBrand()
|
||||
icon={hardwareModelToIcon(device.hardware_model)}
|
||||
totalSpace={device.storage_size.toString()}
|
||||
freeSpace={(device.storage_size - device.used_storage).toString()}
|
||||
totalSpace={'0'}
|
||||
freeSpace={'0'}
|
||||
color="#0362FF"
|
||||
connectionType={'cloud'}
|
||||
/>
|
||||
|
||||
18
packages/client/src/core.ts
generated
18
packages/client/src/core.ts
generated
@@ -11,9 +11,9 @@ export type Procedures = {
|
||||
{ key: "cloud.libraries.get", input: CloudGetLibraryArgs, result: CloudLibrary } |
|
||||
{ key: "cloud.libraries.list", input: boolean, result: CloudLibrary[] } |
|
||||
{ key: "cloud.locations.list", input: CloudListLocationsArgs, result: CloudLocation[] } |
|
||||
{ key: "cloud.syncGroups.get", input: CloudGetSyncGroupArgs, result: CloudSyncGroup } |
|
||||
{ key: "cloud.syncGroups.get", input: CloudGetSyncGroupArgs, result: CloudSyncGroupGetResponseKind } |
|
||||
{ key: "cloud.syncGroups.leave", input: CloudSyncGroupPubId, result: null } |
|
||||
{ key: "cloud.syncGroups.list", input: boolean, result: CloudSyncGroup[] } |
|
||||
{ key: "cloud.syncGroups.list", input: never, result: CloudSyncGroupBaseData[] } |
|
||||
{ key: "cloud.syncGroups.remove_device", input: CloudSyncGroupsRemoveDeviceArgs, result: null } |
|
||||
{ key: "ephemeralFiles.getMediaData", input: string, result: MediaData | null } |
|
||||
{ key: "files.get", input: LibraryArgs<number>, result: ObjectWithFilePaths2 | null } |
|
||||
@@ -184,13 +184,13 @@ export type Chapter = { id: number; start: [number, number]; end: [number, numbe
|
||||
|
||||
export type CloudCreateLocationArgs = { pub_id: CloudLocationPubId; name: string; library_pub_id: CloudLibraryPubId; device_pub_id: CloudDevicePubId }
|
||||
|
||||
export type CloudDevice = { pub_id: CloudDevicePubId; name: string; os: DeviceOS; storage_size: bigint; used_storage: bigint; connection_id: string; created_at: string; updated_at: string; hardware_model: HardwareModel }
|
||||
export type CloudDevice = { pub_id: CloudDevicePubId; name: string; os: DeviceOS; hardware_model: HardwareModel; connection_id: string; created_at: string; updated_at: string }
|
||||
|
||||
export type CloudDevicePubId = string
|
||||
|
||||
export type CloudGetLibraryArgs = { pub_id: CloudLibraryPubId; with_device: boolean }
|
||||
|
||||
export type CloudGetSyncGroupArgs = { pub_id: CloudSyncGroupPubId; with_library: boolean; with_devices: boolean; with_used_storage: boolean }
|
||||
export type CloudGetSyncGroupArgs = { pub_id: CloudSyncGroupPubId; kind: CloudSyncGroupGetRequestKind }
|
||||
|
||||
export type CloudLibrary = { pub_id: CloudLibraryPubId; name: string; original_device: CloudDevice | null; created_at: string; updated_at: string }
|
||||
|
||||
@@ -210,7 +210,13 @@ export type CloudP2PTicket = bigint
|
||||
|
||||
export type CloudP2PUserResponse = { kind: "AcceptDeviceInSyncGroup"; data: { ticket: CloudP2PTicket; accepted: BasicLibraryCreationArgs | null } }
|
||||
|
||||
export type CloudSyncGroup = { pub_id: CloudSyncGroupPubId; latest_key_hash: CloudSyncKeyHash; library: CloudLibrary | null; devices: CloudDevice[] | null; total_sync_messages_bytes: bigint | null; total_space_files_bytes: bigint | null; created_at: string; updated_at: string }
|
||||
export type CloudSyncGroup = { pub_id: CloudSyncGroupPubId; latest_key_hash: CloudSyncKeyHash; library: CloudLibrary; devices: CloudDevice[]; total_sync_messages_bytes: bigint; total_space_files_bytes: bigint; created_at: string; updated_at: string }
|
||||
|
||||
export type CloudSyncGroupBaseData = { pub_id: CloudSyncGroupPubId; latest_key_hash: CloudSyncKeyHash; library: CloudLibrary; created_at: string; updated_at: string }
|
||||
|
||||
export type CloudSyncGroupGetRequestKind = "WithDevices" | "FullData"
|
||||
|
||||
export type CloudSyncGroupGetResponseKind = { WithDevices: CloudSyncGroupWithLibraryAndDevices } | { FullData: CloudSyncGroup }
|
||||
|
||||
export type CloudSyncGroupPubId = string
|
||||
|
||||
@@ -220,7 +226,7 @@ export type CloudSyncGroupsRemoveDeviceArgs = { group_pub_id: CloudSyncGroupPubI
|
||||
|
||||
export type CloudSyncKeyHash = string
|
||||
|
||||
export type CloudUpdateDeviceArgs = { pub_id: CloudDevicePubId; name: string; storage_size: bigint; used_storage: bigint }
|
||||
export type CloudUpdateDeviceArgs = { pub_id: CloudDevicePubId; name: string }
|
||||
|
||||
export type Codec = { kind: string | null; sub_kind: string | null; tag: string | null; name: string | null; profile: string | null; bit_rate: number; props: Props | null }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user