Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
shoonia committed Dec 7, 2024
1 parent 053552e commit 2f7c890
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/module/Directory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class Directory {

async getDirectory(name: string): Promise<Directory> {
if (this.#directories.has(name)) {
return this.#directories.get(name) as Directory;
return this.#directories.get(name)!;
}

const handler = await this.#handler.getDirectoryHandle(name, {
Expand Down
4 changes: 2 additions & 2 deletions src/module/downloadFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ export const downloadFiles = async ({ includePageId }: IState): Promise<void> =>
}
}

const [, rootDir] = await getRootDir();
const rootDir = await getRootDir();

if (rootDir === null) {
if (rootDir == null) {
return;
}

Expand Down
14 changes: 6 additions & 8 deletions src/module/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,17 @@ export const getRootDir = async () => {
mode: 'readwrite',
});

return [null, new Directory(handler)] as const;
return new Directory(handler);
} catch (error) {
if (error instanceof DOMException) {
return [error, null] as const;
return;
}

throw error;
}
};

export const duplicateErrorMessage = (page: IPage): void => {
const message = `A few pages with duplicate titles - "${page.title}".\n\n` +
'Please rename each duplicate page title and reload the browser tab or check on ✅ "Include page ID"';

alert(message);
};
export const duplicateErrorMessage = (page: IPage) => alert(
`A few pages with duplicate titles - "${page.title}".\n\n` +
'Please rename each duplicate page title and reload the browser tab or check on ✅ "Include page ID"',
);

0 comments on commit 2f7c890

Please sign in to comment.