Merge pull request #126 from Flow-Works/fix/file-renaming-bug

Fix file renaming bug
This commit is contained in:
ThinLiquid 2024-01-16 06:07:22 +00:00 committed by GitHub
commit f82f0d3274
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -47,14 +47,14 @@ const Files: Process = {
} }
(win.content.querySelector('.file') as HTMLElement).onclick = async () => { (win.content.querySelector('.file') as HTMLElement).onclick = async () => {
const title: string | null | undefined = prompt('Enter file name') const title = prompt('Enter file name')
if (title != null) { if (title != null) {
await fs.writeFile(`${dir}/${title}`, '') await fs.writeFile(`${dir}/${title}`, '')
} }
} }
(win.content.querySelector('.folder') as HTMLElement).onclick = async () => { (win.content.querySelector('.folder') as HTMLElement).onclick = async () => {
const title: string | null | undefined = prompt('Enter folder name') const title = prompt('Enter folder name')
if (title != null) { if (title != null) {
await fs.mkdir(`${dir}/${title}`, '') await fs.mkdir(`${dir}/${title}`, '')
} }
@ -73,8 +73,8 @@ const Files: Process = {
element.innerHTML += `${icon} <span style="flex:1;">${file}</span><span class="material-symbols-rounded delete">delete_forever</span><span class="material-symbols-rounded rename">edit</span>`; element.innerHTML += `${icon} <span style="flex:1;">${file}</span><span class="material-symbols-rounded delete">delete_forever</span><span class="material-symbols-rounded rename">edit</span>`;
(element.querySelector('.rename') as HTMLElement).onclick = async () => { (element.querySelector('.rename') as HTMLElement).onclick = async () => {
const value = (prompt('Rename') as string) const value = prompt('Rename')
if (value !== null || value !== undefined) { if (value != null) {
await fs.rename(dir + seperator + file, dir + seperator + value) await fs.rename(dir + seperator + file, dir + seperator + value)
} }
} }