Skip to content

Commit

Permalink
Add Tauri.Dialog module
Browse files Browse the repository at this point in the history
  • Loading branch information
rnons committed Aug 30, 2020
1 parent a441bc0 commit ce282e3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/Tauri/Dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.dialog = require("tauri/api/dialog");
21 changes: 21 additions & 0 deletions src/Tauri/Dialog.purs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module Tauri.Dialog
( OpenDialogOptions
, open
) where

import Prelude

import Control.Promise (Promise, toAffE)
import Effect.Aff (Aff)
import Effect.Uncurried (EffectFn1, runEffectFn1)

type OpenDialogOptions =
{ directory :: Boolean
}

foreign import dialog ::
{ open :: EffectFn1 OpenDialogOptions (Promise String)
}

open :: OpenDialogOptions -> Aff String
open opts = toAffE $ runEffectFn1 dialog.open opts
2 changes: 1 addition & 1 deletion src/Tauri/FS.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
exports.unsafeRequireFS = require("tauri/api/fs");
exports.fs = require("tauri/api/fs");
5 changes: 1 addition & 4 deletions src/Tauri/FS.purs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,12 @@ type FileEntry =

type FilePath = String

foreign import unsafeRequireFS :: forall r. Record r

fs ::
foreign import fs ::
{ readTextFile :: EffectFn2 FilePath Json (Promise String)
, writeFile :: EffectFn2 FsTextFileOption Json (Promise Unit)
, readDir :: EffectFn2 FilePath Json (Promise Json)
, createDir :: EffectFn2 FilePath Json (Promise Unit)
}
fs = unsafeRequireFS

readTextFile :: FilePath -> FsOptions -> Aff String
readTextFile path opts = toAffE $ runEffectFn2 fs.readTextFile path (encodeJson opts)
Expand Down

0 comments on commit ce282e3

Please sign in to comment.