Skip to content

Commit

Permalink
Fixes bug: after import, search text was not always set to file name
Browse files Browse the repository at this point in the history
  • Loading branch information
DougReeder committed Feb 13, 2024
1 parent 4903e7e commit de9dfab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/FileImport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ function FileImport({files, isMultiple, doCloseImport}) {
// console.log(`changing parseType of "${file.name}" to Markdown`)
parseType = 'text/markdown';
}
const {noteIds, message, coda} = await importFromFile(file, parseType, isMultiple);
const {noteIds, message} = await importFromFile(file, parseType, isMultiple);
record.message = message;
numNotesCreated.current += noteIds.length
if (noteIds.length > 0 && coda) {
lastSuccessfulFileName.current = coda;
if (noteIds.length > 0 && file.name?.trim()) {
lastSuccessfulFileName.current = file.name?.trim();
}
} catch (err) {
record.message = extractUserMessage(err);
Expand Down Expand Up @@ -189,7 +189,7 @@ function FileImport({files, isMultiple, doCloseImport}) {
<Toolbar>
<IconButton edge="start" color="inherit"
title="Close" size="large"
onClick={doCloseImport.bind(this, lastSuccessfulFileName.current)}>
onClick={_evt => doCloseImport(lastSuccessfulFileName.current)}>
<CloseIcon />
</IconButton>
<Typography id="import-title" sx={{ ml: 2, flex: "0 0 auto" }} variant="h6">
Expand Down
12 changes: 6 additions & 6 deletions src/FileImport.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ describe("FileImport", () => {
expect(cells.length).toEqual(6*3);

await userEvent.click(closeBtn);
expect(mockCloseImport).toHaveBeenCalledWith("", expect.anything());
expect(mockCloseImport).toHaveBeenCalledWith("");
});

it("should not render Markdown column when not needed", async () => {
Expand Down Expand Up @@ -794,7 +794,7 @@ describe("FileImport", () => {
expect(cells.length).toEqual(4*2);

await userEvent.click(closeBtn);
expect(mockCloseImport).toHaveBeenCalledWith("", expect.anything());
expect(mockCloseImport).toHaveBeenCalledWith("");
});

it("should import & summarize results", async () => {
Expand Down Expand Up @@ -844,7 +844,7 @@ describe("FileImport", () => {
expect(cells[14].textContent).toEqual("1 note");

await userEvent.click(closeBtn);
expect(mockCloseImport).toHaveBeenCalledWith("nursery-rhymes.txt", expect.anything());
expect(mockCloseImport).toHaveBeenCalledWith("nursery-rhymes.txt");
});

it("should allow changing Markdown flags before importing", async () => {
Expand Down Expand Up @@ -900,7 +900,7 @@ describe("FileImport", () => {
expect(cells[14].textContent).toEqual("2 notes");

await userEvent.click(closeBtn);
expect(mockCloseImport).toHaveBeenCalledWith("nursery-rhymes.txt", expect.anything());
expect(mockCloseImport).toHaveBeenCalledWith("nursery-rhymes.txt");
});

it("should import single notes from text & Markdown files when flagged", async () => {
Expand Down Expand Up @@ -950,7 +950,7 @@ describe("FileImport", () => {
expect(cells[14].textContent).toEqual("1 note");

await userEvent.click(closeBtn);
expect(mockCloseImport).toHaveBeenCalledWith("nursery-rhymes.txt", expect.anything());
expect(mockCloseImport).toHaveBeenCalledWith("nursery-rhymes.txt");
});

it("should skip review, when all files are readable, an importable type, and not text", async () => {
Expand All @@ -972,6 +972,6 @@ describe("FileImport", () => {
expect(mockCloseImport).not.toHaveBeenCalled();

await userEvent.click(closeBtn);
expect(mockCloseImport).toHaveBeenCalledWith("Burroughs.md", expect.anything());
expect(mockCloseImport).toHaveBeenCalledWith("Burroughs.md");
});
});

0 comments on commit de9dfab

Please sign in to comment.