Skip to content

Commit 16852e9

Browse files
committed
wip
1 parent cc89b60 commit 16852e9

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

ghcjs/miso-functora/js/main.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export async function insertStorage(key, value) {
3131
export async function selectClipboard() {
3232
const { value } = await Clipboard.read();
3333
try {
34-
return newBlobUrl(value);
34+
const { buffer: u8a, typeFull: mime } = dataUriToBuffer(value);
35+
const blob = new Blob([u8a, { type: mime }]);
36+
return URL.createObjectURL(blob);
3537
} catch (e) {
3638
return value;
3739
}
@@ -101,12 +103,6 @@ export function isNativePlatform() {
101103
return Capacitor.isNativePlatform();
102104
}
103105

104-
export function newBlobUrl(value) {
105-
const { buffer: u8a, typeFull: mime } = dataUriToBuffer(value);
106-
const blob = new Blob([u8a, { type: mime }]);
107-
return URL.createObjectURL(blob);
108-
}
109-
110106
export async function fetchUrlAsRfc2397(url) {
111107
const resp = await fetch(url);
112108
const blob = await resp.blob();

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: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module Functora.Miso.Jsm.Generic
1313
genericPromise,
1414
printCurrentPage,
1515
saveFile,
16-
newBlobUrl,
16+
fetchUrlAsRfc2397,
1717
)
1818
where
1919

@@ -215,8 +215,8 @@ saveFile name mime bs = do
215215
Nothing -> pure ()
216216
Just str -> popupText str
217217

218-
newBlobUrl :: Unicode -> JSM Unicode
219-
newBlobUrl blob = do
220-
pkg <- getPkg
221-
res <- pkg ^. JS.js1 ("newBlobUrl" :: Unicode) blob
222-
JS.fromJSVal res >>= maybe (throwString @String "Failure, bad result!") pure
218+
fetchUrlAsRfc2397 :: Unicode -> (Maybe Unicode -> JSM ()) -> JSM ()
219+
fetchUrlAsRfc2397 url after =
220+
genericPromise @[Unicode] @Unicode "fetchUrlAsRfc2397" [url]
221+
$ after
222+
. fmap strip

0 commit comments

Comments
 (0)