minor refactors

This commit is contained in:
Brendan Allan 2022-10-17 22:23:01 +08:00
parent 01df0019bb
commit 529861a0b8
4 changed files with 23 additions and 34 deletions

View file

@ -83,22 +83,24 @@ const placeholderFileItems: FilePath[] = [
export interface DeviceProps {
name: string;
size: string;
type: 'laptop' | 'desktop' | 'phone' | 'server';
type: keyof typeof DeviceIcon;
locations: { name: string; folder?: boolean; format?: string; icon?: string }[];
runningJob?: { amount: number; task: string };
}
const DeviceIcon = {
phone: <DeviceMobileCamera color="white" weight="fill" size={18} style={tw`mr-2`} />,
laptop: <Laptop color="white" weight="fill" size={18} style={tw`mr-2`} />,
desktop: <Desktop color="white" weight="fill" size={18} style={tw`mr-2`} />,
server: <Cloud color="white" weight="fill" size={18} style={tw`mr-2`} />
};
const Device = ({ name, locations, size, type }: DeviceProps) => {
return (
<View style={tw`my-2 bg-gray-600 border rounded-md border-gray-550`}>
<View style={tw`flex flex-row items-center px-3.5 pt-3 pb-2`}>
<View style={tw`flex flex-row items-center`}>
{type === 'phone' && (
<DeviceMobileCamera color="white" weight="fill" size={18} style={tw`mr-2`} />
)}
{type === 'laptop' && <Laptop color="white" weight="fill" size={18} style={tw`mr-2`} />}
{type === 'desktop' && <Desktop color="white" weight="fill" size={18} style={tw`mr-2`} />}
{type === 'server' && <Cloud color="white" weight="fill" size={18} style={tw`mr-2`} />}
{DeviceIcon[type]}
<Text style={tw`text-base font-semibold text-white`}>{name || 'Unnamed Device'}</Text>
{/* P2P Lock */}
<View style={tw`flex flex-row rounded items-center ml-2 bg-gray-500 py-[1px] px-[4px]`}>

View file

@ -31,19 +31,16 @@ const DrawerLibraryManager = () => {
const [createLibOpen, setCreateLibOpen] = useState(false);
const { mutate: createLibrary, isLoading: createLibLoading } = useBridgeMutation(
'library.create',
{
onSuccess: () => {
// Reset form
setLibName('');
},
onSettled: () => {
// Close create lib dialog
setCreateLibOpen(false);
}
const createLibrary = useBridgeMutation('library.create', {
onSuccess: () => {
// Reset form
setLibName('');
},
onSettled: () => {
// Close create lib dialog
setCreateLibOpen(false);
}
);
});
return (
<View>
@ -97,7 +94,7 @@ const DrawerLibraryManager = () => {
title="Create New Library"
description="Choose a name for your new library, you can configure this and more settings from the library settings later on."
ctaLabel="Create"
ctaAction={() => createLibrary(libName)}
ctaAction={() => createLibrary.mutate(libName)}
trigger={
<View style={tw`flex flex-row items-center px-1.5 py-[8px]`}>
<PlusIcon size={18} style={tw`text-gray-100 mr-2`} />

View file

@ -1,22 +1,11 @@
import byteSize from 'byte-size';
import React from 'react';
import { ScrollView, Text, View } from 'react-native';
import { Statistics } from '~/types/bindings';
import useCounter from '../hooks/useCounter';
import tw from '../lib/tailwind';
interface Statistics {
id: number;
date_captured: string;
total_file_count: number;
library_db_size: string;
total_bytes_used: string;
total_bytes_capacity: string;
total_unique_bytes: string;
total_bytes_free: string;
preview_media_bytes: string;
}
const StatItemNames: Partial<Record<keyof Statistics, string>> = {
total_bytes_capacity: 'Total capacity',
preview_media_bytes: 'Preview media',

View file

@ -5,15 +5,16 @@ import VirtualizedListWrapper from '~/components/layout/VirtualizedListWrapper';
import OverviewStats from '~/containers/OverviewStats';
import tw from '~/lib/tailwind';
import { OverviewStackScreenProps } from '~/navigation/tabs/OverviewStack';
import { Statistics } from '~/types/bindings';
const placeholderOverviewStats = {
const placeholderOverviewStats: Statistics = {
id: 1,
total_bytes_capacity: '8093333345230',
preview_media_bytes: '2304387532',
library_db_size: '83345230',
total_file_count: 20342345,
total_bytes_free: '89734502034',
total_bytes_used: '8093333345230',
total_object_count: 0,
total_unique_bytes: '9347397',
date_captured: '2020-01-01'
};