Skip to content

Commit

Permalink
Merge pull request #1717 from ChainSafe/fix/file-name-repeated-in-the…
Browse files Browse the repository at this point in the history
…-path-1499

fix cancel download, content not clearing, search preview content type
  • Loading branch information
FSM1 authored Nov 10, 2021
2 parents c9ad5ad + 39579a7 commit 9ad4c69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ROUTE_LINKS } from "../../FilesRoutes"
import { t } from "@lingui/macro"
import { FileBrowserContext } from "../../../Contexts/FileBrowserContext"
import { useFilesApi } from "../../../Contexts/FilesApiContext"
import { parseFileContentResponse } from "../../../Utils/Helpers"

const SearchFileBrowser: React.FC<IFileBrowserModuleProps> = ({ controls = false }: IFileBrowserModuleProps) => {
const { pathname } = useLocation()
Expand All @@ -26,7 +27,8 @@ const SearchFileBrowser: React.FC<IFileBrowserModuleProps> = ({ controls = false
try {
if (!searchString || !bucket) return []

const results = await filesApiClient.searchFiles({ bucket_id: bucket.id, query: searchString })
const results = (await filesApiClient.searchFiles({ bucket_id: bucket.id, query: searchString }))
.map(se => ({ ...se, content: parseFileContentResponse(se.content) }))
return results
} catch (err) {
addToast({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,8 @@ const FilePreviewModal = ({ file, nextFile, previousFile, closePreview, filePath
bucketId = bucket.id
}

setFileContent(undefined)
if (previewRendererKey) {
setFileContent(undefined)
getFile({ file, filePath: getPathWithFile(filePath, file.name), bucketId })
.then((content) => {
setFileContent(content)
Expand Down
4 changes: 3 additions & 1 deletion packages/files-ui/src/Contexts/FilesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ const FilesProvider = ({ children }: FilesContextProps) => {
return Promise.resolve()
} catch (error: any) {
console.error(error)
let errorMessage = `${t`An error occurred: `} ${typeof(error) === "string" ? error : error.error.message ? error.error.message : ""}`
let errorMessage = `${t`An error occurred: `} ${typeof(error) === "string"
? error
: error?.error?.message || ""}`
if (axios.isCancel(error)) {
errorMessage = t`Downloads cancelled`
}
Expand Down

0 comments on commit 9ad4c69

Please sign in to comment.