Skip to content

Commit

Permalink
fix: feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfreska committed Sep 24, 2024
1 parent fbb78a0 commit e45d75c
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 26 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CommandGroup, CommandItemSearch } from '../../../CmdRoot/Item'
import { Page } from '../../../CmdRoot/types'
import { useObjectList } from '@siafoundation/renterd-react'
import { useObjects } from '@siafoundation/renterd-react'
import { isDirectory } from '../../../../lib/paths'
import { Text } from '@siafoundation/design-system'
import { Document16, FolderIcon } from '@siafoundation/react-icons'
Expand Down Expand Up @@ -31,7 +31,7 @@ export function FilesSearchCmd({
useFilesManager()
const onSearchPage = currentPage?.namespace === filesSearchPage.namespace
const searchBucket = activeBucket || 'default'
const results = useObjectList({
const results = useObjects({
disabled: !onSearchPage,
params: {
bucket: searchBucket,
Expand Down
8 changes: 4 additions & 4 deletions apps/renterd/contexts/filesDirectory/dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useObjectList } from '@siafoundation/renterd-react'
import { useObjects } from '@siafoundation/renterd-react'
import { useDataset as useDatasetGeneric } from '../filesManager/dataset'
import { bucketAndKeyParamsFromPath } from '../../lib/paths'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useFilesManager } from '../filesManager'
import { defaultDatasetRefreshInterval } from '../../config/swr'
import { ObjectListParams } from '@siafoundation/renterd-types'
import { ObjectsParams } from '@siafoundation/renterd-types'

const defaultLimit = 50

Expand All @@ -30,7 +30,7 @@ export function useDataset() {
? fileNamePrefixFilter.slice(1)
: fileNamePrefixFilter
}
const p: ObjectListParams = {
const p: ObjectsParams = {
prefix,
bucket: pathParams.bucket,
sortBy: sortField,
Expand All @@ -51,7 +51,7 @@ export function useDataset() {
limit,
])

const response = useObjectList({
const response = useObjects({
disabled: !activeBucketName,
params,
config: {
Expand Down
8 changes: 4 additions & 4 deletions apps/renterd/contexts/filesFlat/dataset.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { useObjectList } from '@siafoundation/renterd-react'
import { useObjects } from '@siafoundation/renterd-react'
import { SortField } from '../filesManager/types'
import { useDataset as useDatasetGeneric } from '../filesManager/dataset'
import { useRouter } from 'next/router'
import { useMemo } from 'react'
import { useFilesManager } from '../filesManager'
import { defaultDatasetRefreshInterval } from '../../config/swr'
import { ObjectListParams } from '@siafoundation/renterd-types'
import { ObjectsParams } from '@siafoundation/renterd-types'

type Props = {
sortDirection: 'asc' | 'desc'
Expand All @@ -27,7 +27,7 @@ export function useDataset({ sortDirection, sortField }: Props) {
? fileNamePrefixFilter.slice(1)
: fileNamePrefixFilter
}
const p: ObjectListParams = {
const p: ObjectsParams = {
prefix,
bucket: activeBucketName,
sortBy: sortField,
Expand All @@ -48,7 +48,7 @@ export function useDataset({ sortDirection, sortField }: Props) {
limit,
])

const response = useObjectList({
const response = useObjects({
disabled: !activeBucketName,
params,
config: {
Expand Down
4 changes: 2 additions & 2 deletions apps/renterd/contexts/filesManager/uploads.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
useMultipartUploadPart,
useSettingsUpload,
} from '@siafoundation/renterd-react'
import { Bucket, busListObjectsRoute } from '@siafoundation/renterd-types'
import { Bucket, busObjectsRoute } from '@siafoundation/renterd-types'
import { MiBToBytes, minutesInMilliseconds } from '@siafoundation/units'
import { throttle } from '@technically/lodash'
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
Expand Down Expand Up @@ -133,7 +133,7 @@ export function useUploads({ activeDirectoryPath }: Props) {
}, 1000)
)
multipartUpload.setOnComplete(async () => {
await ref.current.mutate((key) => key.startsWith(busListObjectsRoute))
await ref.current.mutate((key) => key.startsWith(busObjectsRoute))
ref.current.removeUpload(uploadId)
setTimeout(() => {
ref.current.checkAndStartUploads()
Expand Down
2 changes: 1 addition & 1 deletion libs/renterd-js/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ export function Bus({ api, password }: { api: string; password?: string }) {
BucketDeletePayload,
BucketDeleteResponse
>(axios, 'delete', busBucketNameRoute),
objectList: buildRequestHandler<
objects: buildRequestHandler<
ObjectsParams,
ObjectsPayload,
ObjectsResponse
Expand Down
6 changes: 3 additions & 3 deletions libs/renterd-js/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
WorkerStateResponse,
workerAccountIdResetdriftRoute,
workerMultipartKeyRoute,
workerObjectsKeyRoute,
workerObjectKeyRoute,
workerRhpScanRoute,
workerStateRoute,
} from '@siafoundation/renterd-types'
Expand All @@ -38,7 +38,7 @@ export function Worker({ api, password }: { api: string; password?: string }) {
ObjectDownloadParams,
ObjectDownloadPayload,
ObjectDownloadResponse
>(axios, 'get', workerObjectsKeyRoute, {
>(axios, 'get', workerObjectKeyRoute, {
config: {
responseType: 'blob',
},
Expand All @@ -47,7 +47,7 @@ export function Worker({ api, password }: { api: string; password?: string }) {
ObjectUploadParams,
ObjectUploadPayload,
ObjectUploadResponse
>(axios, 'put', workerObjectsKeyRoute, {
>(axios, 'put', workerObjectKeyRoute, {
config: {
headers: {
'Content-Type': 'multipart/form-data',
Expand Down
4 changes: 1 addition & 3 deletions libs/renterd-react/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -702,9 +702,7 @@ export function useBucketDelete(
)
}

export function useObjectList(
args: HookArgsSwr<ObjectsParams, ObjectsResponse>
) {
export function useObjects(args: HookArgsSwr<ObjectsParams, ObjectsResponse>) {
return useGetSwr({ ...args, route: busObjectsPrefixRoute })
}

Expand Down
7 changes: 3 additions & 4 deletions libs/renterd-react/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@ import {
busHostsRoute,
workerAccountIdResetdriftRoute,
workerMultipartKeyRoute,
workerObjectsKeyRoute,
workerObjectKeyRoute,
workerRhpScanRoute,
workerStateRoute,
busObjectsRoute,
Host,
} from '@siafoundation/renterd-types'

Expand All @@ -54,7 +53,7 @@ export function useObjectDownloadFunc(
ObjectDownloadResponse
>
) {
return useGetDownloadFunc({ ...args, route: workerObjectsKeyRoute })
return useGetDownloadFunc({ ...args, route: workerObjectKeyRoute })
}

export function useObjectUpload(
Expand All @@ -76,7 +75,7 @@ export function useObjectUpload(
},
},
},
route: workerObjectsKeyRoute,
route: workerObjectKeyRoute,
},
async (mutate) => {
mutate((key) => key.startsWith(busObjectsRoute))
Expand Down
4 changes: 2 additions & 2 deletions libs/renterd-types/src/bus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,15 +399,15 @@ export type BucketDeletePayload = void
export type BucketDeleteResponse = void

export type ObjectsParams = {
bucket: string
bucket?: string
prefix?: string
delimiter?: string
limit?: number
marker?: string
sortBy?: 'name' | 'health' | 'size'
sortDir?: 'asc' | 'desc'
substring?: string
slabEncryptionKey: string
slabEncryptionKey?: string
}
export type ObjectsPayload = void
export type ObjectsResponse = {
Expand Down
2 changes: 1 addition & 1 deletion libs/renterd-types/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HostSettings } from './types'
import { BusStateResponse } from './bus'

export const workerStateRoute = '/worker/state'
export const workerObjectsKeyRoute = '/worker/objects/:key'
export const workerObjectKeyRoute = '/worker/object/:key'
export const workerMultipartKeyRoute = '/worker/multipart/:key'
export const workerRhpScanRoute = '/worker/rhp/scan'
export const workerAccountIdResetdriftRoute = '/worker/account/:id/resetdrift'
Expand Down

0 comments on commit e45d75c

Please sign in to comment.