Skip to content

Commit

Permalink
load from config
Browse files Browse the repository at this point in the history
  • Loading branch information
gavr123456789 committed Nov 14, 2021
1 parent 358d44c commit b8b75c2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/Load.nim
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import json
import json, os

const SAVE_DIR_NAME = ".config" / "Dela" / "state.json"

type PageSave* = object
pageName*: string
Expand All @@ -14,7 +16,7 @@ type TaskSave* = object
note*: string
done*: bool

proc readSaveFromFS*(): JsonNode = "state.json".readFile.parseJson
proc readSaveFromFS*(): JsonNode = (getHomeDir() / SAVE_DIR_NAME).readFile.parseJson

func getPages*(x: JsonNode): seq[PageSave] =
assert x.kind == JArray
Expand Down
4 changes: 0 additions & 4 deletions src/Save.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ proc getAllPages(tabView: TabView): seq[TabPage] =
for i in 0..<n:
result.add tabView.getNthPage(i)

proc createSaveFolderIfThereNot =
if not SAVE_DIR_NAME.dirExists():
createDir getHomeDir() / SAVE_DIR_NAME

proc save*(btn: Button, tabView: TabView): void =
let allPages = tabView.getAllPages()
var jsonPages: seq[JsonNode]
Expand Down

0 comments on commit b8b75c2

Please sign in to comment.