Skip to content

Commit

Permalink
beta0.8.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Aneks1 committed Mar 7, 2024
1 parent 501da45 commit 78dabc0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "notesphere",
"version": "0.8.0",
"version": "0.8.1",
"private": true,
"description": "Note taking app",
"author": { "name": "Aneksium" },
Expand Down
2 changes: 1 addition & 1 deletion src/routes/EditorPage/EditorPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default defineComponent({
},
autoSave() {
if(this.saveTimeout != null) clearTimeout(this.saveTimeout)
this.saveTimeout = setTimeout(this.saveNote, 1000)
this.saveTimeout = setTimeout(this.saveNote, 750)
}
},
watch: {
Expand Down
17 changes: 11 additions & 6 deletions src/utils/BoardManager.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
import fs from 'fs'
import NoteManager from "./NoteManager"
import { remote } from 'electron'

export class BoardManager {
public boards: Map<string, NoteManager> = new Map()
public readonly basePath: string

public loadBoards() {
if(!fs.existsSync('./notes')) return fs.mkdirSync('./notes')
const boardDirs = fs.readdirSync('./notes')
if(!fs.existsSync(this.basePath)) return fs.mkdirSync(this.basePath)
const boardDirs = fs.readdirSync(this.basePath)
for(const dir of boardDirs)
this.boards.set(dir, new NoteManager(`./notes/${dir}`))
this.boards.set(dir, new NoteManager(`${this.basePath}\\${dir}`))
}
public createBoard(name: string) {
if(fs.existsSync(`./notes/${name}`)) return false
if(fs.existsSync(`${this.basePath}\\${name}`)) return false
else {
fs.mkdirSync(`./notes/${name}`)
this.boards.set(name, new NoteManager(`./notes/${name}`))
fs.mkdirSync(`${this.basePath}\\${name}`)
this.boards.set(name, new NoteManager(`${this.basePath}\\${name}`))
return true
}
}
constructor() {
this.basePath = remote.app.getPath('userData') + '\\notes'
this.loadBoards()
console.log(this.basePath)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/Note.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Note {
const colorIndex = ['yellow', 'aqua', 'pink', 'green'].indexOf(this.color)

const data = `${title64}:|:${colorIndex}:|:${cont64}`
fs.writeFileSync(`${this.parentPath}/${this.id}.ns`, data, 'utf-8')
fs.writeFileSync(`${this.parentPath}\\${this.id}.ns`, data, 'utf-8')
}
constructor(parentPath: string, id: string) {
this.parentPath = parentPath
Expand Down
4 changes: 2 additions & 2 deletions src/utils/NoteManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ export default class NoteManager {
const ids = Array.from(this.notes).map(x => parseInt(x[0])).sort((x, y) => x - y)
const nextId = ids[ids.length - 1] + 1 || 1
const data = `${Encryptor.encrypt('New Note')}:|:0:|:`
fs.writeFileSync(`${this.path}/${nextId}.ns`, data, 'utf-8')
fs.writeFileSync(`${this.path}\\${nextId}.ns`, data, 'utf-8')
return this.loadNotes()
}
public deleteNote(id: string) {
this.notes.delete(id)
fs.unlinkSync(`${this.path}/${id}.ns`)
fs.unlinkSync(`${this.path}\\${id}.ns`)
return this.loadNotes()
}
constructor(path: string) {
Expand Down

0 comments on commit 78dabc0

Please sign in to comment.