Skip to content

Commit 4ead298

Browse files
committed
alerts
1 parent a66e3d5 commit 4ead298

File tree

6 files changed

+52
-38
lines changed

6 files changed

+52
-38
lines changed

ghcjs/delivery-calculator/delivery-calculator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cabal-version: 2.2
22
name: delivery-calculator
3-
version: 0.1.0.8
3+
version: 0.1.0.9
44
synopsis: Delivery Calculator
55
category: Web
66
build-type: Simple

ghcjs/delivery-calculator/src/Main.hs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ main =
4141
withUtf8
4242
. runApp
4343
. forever
44-
. handleAny (\e -> consoleLog e >> sleepSeconds 5)
44+
. handleAny
45+
( \e -> do
46+
alert . from @String @Unicode $ displayException e
47+
sleepSeconds 5
48+
)
4549
$ do
4650
uri <- URI.mkURI . inspect =<< getCurrentURI
4751
mSt <- unShareUri uri
@@ -194,7 +198,7 @@ updateModel (ChanUpdate update0) st0 = do
194198
update2 <-
195199
handleAny
196200
( \e -> do
197-
consoleLog e
201+
alert . from @String @Unicode $ displayException e
198202
pure $ #modelLoading .~ False
199203
)
200204
$ evalModel st2

ghcjs/delivery-calculator/trapeze.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
platforms:
22
android:
33
appName: Delivery Calculator
4-
versionCode: 8
5-
versionName: 0.1.0.8
4+
versionCode: 9
5+
versionName: 0.1.0.9
66
packageName: com.functora.delivery_calculator
77
manifest:
88
- file: AndroidManifest.xml

ghcjs/miso-functora/js/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ export async function opfsWrite(value, opfsName) {
8282
const stream = await handle.createWritable();
8383
await stream.write(value);
8484
await stream.close();
85-
console.log("OPFS write success", opfsName, handle);
85+
console.log("OPFS write success:", handle, opfsName);
8686
} catch (e) {
87-
console.log("OPFS write failure", opfsName, e);
87+
alert("OPFS write failure: " + e.toString() + " file: " + opfsName);
8888
}
8989
return null;
9090
}
@@ -96,10 +96,10 @@ export async function opfsRead(opfsName) {
9696
const file = await handle.getFile();
9797
const uri = await file.text();
9898
const res = await selectDataUrl(uri);
99-
console.log("OPFS read success", opfsName, res);
99+
console.log("OPFS read success:", res, opfsName);
100100
return res;
101101
} catch (e) {
102-
console.log("OPFS read failure", opfsName, e);
102+
alert("OPFS read failure: " + e.toString() + " file: " + opfsName);
103103
return null;
104104
}
105105
}
@@ -111,10 +111,10 @@ export async function opfsList() {
111111
for await (let opfsName of root.keys()) {
112112
res.push(opfsName);
113113
}
114-
console.log("OPFS list success", opfsName, res);
114+
console.log("OPFS list success:", res, opfsName);
115115
return res;
116116
} catch (e) {
117-
console.log("OPFS list failure", opfsName, e);
117+
alert("OPFS list failure: " + e.toString() + " file: " + opfsName);
118118
return [];
119119
}
120120
}

ghcjs/miso-functora/js/main.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ghcjs/miso-functora/src/Functora/Miso/Jsm/Generic.hs

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ selectStorage key after =
141141
. Tagged @"UTF-8"
142142
$ encodeUtf8 @Unicode @BL.ByteString str of
143143
Left e -> do
144-
consoleLog e
144+
alert $ from @String @Unicode e
145145
after Nothing
146146
Right res ->
147147
after $ Just res
@@ -187,21 +187,26 @@ genericPromise ::
187187
JSM ()
188188
genericPromise fun argv after = do
189189
success <- JS.function $ \_ _ ->
190-
handleAny (\e -> consoleLog e >> after Nothing) . \case
191-
[val] -> do
192-
valExist <- ghcjsPure $ JS.isTruthy val
193-
if not valExist
194-
then after Nothing
195-
else do
196-
mres <- JS.fromJSVal @res val
197-
res <- maybe (throwString @String "Failure, bad result!") pure mres
198-
after $ Just res
199-
_ ->
200-
throwString @String "Failure, bad argv!"
190+
handleAny
191+
( \e -> do
192+
alert . from @String @Unicode $ displayException e
193+
after Nothing
194+
)
195+
. \case
196+
[val] -> do
197+
valExist <- ghcjsPure $ JS.isTruthy val
198+
if not valExist
199+
then after Nothing
200+
else do
201+
mres <- JS.fromJSVal @res val
202+
res <- maybe (throwString @String "Failure, bad result!") pure mres
203+
after $ Just res
204+
_ ->
205+
throwString @String "Failure, bad argv!"
201206
failure <-
202207
JS.function $ \_ _ e -> do
203208
msg <- handleAny (\_ -> pure "Unknown") $ JS.valToText e
204-
consoleLog @Unicode $ "Failure, " <> inspect msg <> "!"
209+
alert $ "Failure, " <> inspect msg <> "!"
205210
after Nothing
206211
pkg <- getPkg
207212
prom <- pkg ^. JS.jsf fun argv
@@ -248,22 +253,27 @@ saveFileThen onSuccess name mime bs = do
248253
fetchUrlAsRfc2397 :: Unicode -> (Maybe ByteString -> JSM ()) -> JSM ()
249254
fetchUrlAsRfc2397 url after = do
250255
success <- JS.function $ \_ _ ->
251-
handleAny (\e -> consoleLog e >> after Nothing) . \case
252-
[val] -> do
253-
valExist <- ghcjsPure $ JS.isTruthy val
254-
if not valExist
255-
then after Nothing
256-
else do
257-
ab <- AB.freeze $ JS.pFromJSVal val
258-
buf <- ghcjsPure $ Buf.createFromArrayBuffer ab
259-
res <- ghcjsPure $ Buf.toByteString 0 Nothing buf
260-
after $ Just res
261-
_ ->
262-
throwString @String "Failure, bad argv!"
256+
handleAny
257+
( \e -> do
258+
alert . from @String @Unicode $ displayException e
259+
after Nothing
260+
)
261+
. \case
262+
[val] -> do
263+
valExist <- ghcjsPure $ JS.isTruthy val
264+
if not valExist
265+
then after Nothing
266+
else do
267+
ab <- AB.freeze $ JS.pFromJSVal val
268+
buf <- ghcjsPure $ Buf.createFromArrayBuffer ab
269+
res <- ghcjsPure $ Buf.toByteString 0 Nothing buf
270+
after $ Just res
271+
_ ->
272+
throwString @String "Failure, bad argv!"
263273
failure <-
264274
JS.function $ \_ _ e -> do
265275
msg <- handleAny (\_ -> pure "Unknown") $ JS.valToText e
266-
consoleLog @Unicode $ "Failure, " <> inspect msg <> "!"
276+
alert $ "Failure, " <> inspect msg <> "!"
267277
after Nothing
268278
pkg <- getPkg
269279
prom <- pkg ^. JS.jsf ("fetchUrlAsRfc2397" :: Unicode) ([url] :: [Unicode])

0 commit comments

Comments
 (0)