@@ -21,13 +21,12 @@ module App.Misc
21
21
)
22
22
where
23
23
24
- import App.Prelude
25
24
import App.Types
26
25
import qualified Data.Generics as Syb
27
- import Functora.Money
26
+ import Functora.Miso.Prelude
27
+ import Functora.Money hiding (Text )
28
28
import qualified Language.Javascript.JSaddle as JS
29
29
import qualified Material.Snackbar as Snackbar
30
- import Miso hiding (URI , view )
31
30
import qualified Prelude
32
31
33
32
getConverterAmountOptic ::
@@ -61,7 +60,7 @@ onKeyDownAction uid (KeyCode code) =
61
60
let enterOrEscape = [13 , 27 ] :: [Int ]
62
61
when (code `elem` enterOrEscape)
63
62
. void
64
- . JS. eval @ Text
63
+ . JS. eval @ MisoString
65
64
$ " document.getElementById('"
66
65
<> htmlUid uid
67
66
<> " ').getElementsByTagName('input')[0].blur();"
@@ -70,13 +69,14 @@ onKeyDownAction uid (KeyCode code) =
70
69
71
70
copyIntoClipboard :: (Show a , Data a ) => Model -> a -> JSM ()
72
71
copyIntoClipboard st x = do
73
- let txt = inspectMiso x
72
+ let txt = inspect x
74
73
unless (txt == mempty ) $ do
75
- clip <- JS. global JS. ! (" navigator" :: Text ) JS. ! (" clipboard" :: Text )
76
- prom <- clip ^. JS. js1 (" writeText" :: Text ) txt
77
- success <- JS. function $ \ _ _ _ -> textPopup @ Text st " Copied!"
78
- failure <- JS. function $ \ _ _ _ -> textPopup @ Text st " Failed to copy!"
79
- void $ prom ^. JS. js2 (" then" :: Text ) success failure
74
+ clip <-
75
+ JS. global JS. ! (" navigator" :: MisoString ) JS. ! (" clipboard" :: MisoString )
76
+ prom <- clip ^. JS. js1 (" writeText" :: MisoString ) txt
77
+ success <- JS. function $ \ _ _ _ -> textPopup @ MisoString st " Copied!"
78
+ failure <- JS. function $ \ _ _ _ -> textPopup @ MisoString st " Failed to copy!"
79
+ void $ prom ^. JS. js2 (" then" :: MisoString ) success failure
80
80
81
81
copyIntoClipboardAction :: (Show a , Data a ) => Model -> a -> Action
82
82
copyIntoClipboardAction st x =
@@ -95,7 +95,7 @@ textPopup st x =
95
95
)
96
96
where
97
97
msg =
98
- inspectMiso x
98
+ inspect x
99
99
& Snackbar. message
100
100
& Snackbar. setActionIcon (Just (Snackbar. icon " close" ))
101
101
& Snackbar. setOnActionIconClick textPopupClosed
@@ -107,7 +107,7 @@ textPopupPure x st =
107
107
%~ (Snackbar. addMessage msg . Snackbar. clearQueue)
108
108
where
109
109
msg =
110
- inspectMiso x
110
+ inspect x
111
111
& Snackbar. message
112
112
& Snackbar. setActionIcon (Just (Snackbar. icon " close" ))
113
113
& Snackbar. setOnActionIconClick textPopupClosed
@@ -143,7 +143,7 @@ drainTChan chan = do
143
143
verifyUid :: Uid -> JSM ()
144
144
verifyUid uid =
145
145
when (nullUid uid)
146
- $ consoleLog " UNEXPECTED NULL UID"
146
+ $ consoleLog @ MisoString " UNEXPECTED NULL UID"
147
147
148
148
duplicateAt ::
149
149
forall a .
@@ -154,14 +154,14 @@ duplicateAt ::
154
154
Action
155
155
duplicateAt optic idx =
156
156
PushUpdate $ do
157
- duplicator <- newUniqueDuplicator @ Text
157
+ duplicator <- newUniqueDuplicator @ MisoString
158
158
let updater loc el =
159
159
if loc == idx
160
160
then [el, closed $ duplicator el]
161
161
else [el]
162
162
pure
163
163
. ChanItem 0
164
- $ (textPopupPure $ " Duplicated #" <> inspect @ Text (idx + 1 ) <> " !" )
164
+ $ (textPopupPure @ MisoString $ " Duplicated #" <> inspect (idx + 1 ) <> " !" )
165
165
. (& cloneTraversal optic %~ ((>>= uncurry updater) . zip [0 .. ]))
166
166
where
167
167
closed :: a -> a
@@ -179,23 +179,23 @@ removeAt optic idx =
179
179
else [el]
180
180
pure
181
181
. ChanItem 0
182
- $ (textPopupPure $ " Removed #" <> inspect @ Text (idx + 1 ) <> " !" )
182
+ $ (textPopupPure @ MisoString $ " Removed #" <> inspect (idx + 1 ) <> " !" )
183
183
. (& cloneTraversal optic %~ ((>>= uncurry updater) . zip [0 .. ]))
184
184
185
185
moveUp :: ATraversal' Model [a ] -> Int -> Action
186
186
moveUp optic idx =
187
187
PushUpdate
188
188
. pure
189
189
. ChanItem 0
190
- $ (textPopupPure $ " Moved #" <> inspect @ Text (idx + 1 ) <> " up!" )
190
+ $ (textPopupPure @ MisoString $ " Moved #" <> inspect (idx + 1 ) <> " up!" )
191
191
. (& cloneTraversal optic %~ swapAt (idx - 1 ) idx)
192
192
193
193
moveDown :: ATraversal' Model [a ] -> Int -> Action
194
194
moveDown optic idx =
195
195
PushUpdate
196
196
. pure
197
197
. ChanItem 0
198
- $ (textPopupPure $ " Moved #" <> inspect @ Text (idx + 1 ) <> " down!" )
198
+ $ (textPopupPure @ MisoString $ " Moved #" <> inspect (idx + 1 ) <> " down!" )
199
199
. (& cloneTraversal optic %~ swapAt idx (idx + 1 ))
200
200
201
201
swapAt :: Int -> Int -> [a ] -> [a ]
@@ -222,7 +222,7 @@ newAssetAction optic =
222
222
item <- newAsset " Price" 0 cur
223
223
pure
224
224
. ChanItem 0
225
- $ (textPopupPure @ Text " Added asset!" )
225
+ $ (textPopupPure @ MisoString " Added asset!" )
226
226
. (& cloneTraversal optic %~ (<> [item]))
227
227
228
228
newFieldPairAction ::
@@ -232,7 +232,7 @@ newFieldPairAction optic =
232
232
item <- newFieldPair mempty $ DynamicFieldText mempty
233
233
pure
234
234
. ChanItem 0
235
- $ (textPopupPure @ Text " Added note!" )
235
+ $ (textPopupPure @ MisoString " Added note!" )
236
236
. (& cloneTraversal optic %~ (<> [item]))
237
237
238
238
newPaymentMethodAction :: ATraversal' Model [PaymentMethod Unique ] -> Action
@@ -242,5 +242,5 @@ newPaymentMethodAction optic =
242
242
item <- newPaymentMethod cur $ Just mempty
243
243
pure
244
244
. ChanItem 0
245
- $ (textPopupPure @ Text " Added payment!" )
245
+ $ (textPopupPure @ MisoString " Added payment!" )
246
246
. (& cloneTraversal optic %~ (<> [item]))
0 commit comments