Skip to content

Commit 4722d34

Browse files
committed
wip
1 parent 56b03b3 commit 4722d34

File tree

6 files changed

+28
-174
lines changed

6 files changed

+28
-174
lines changed

ghcjs/delivery-calculator/delivery-calculator.cabal

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ common pkg
1919
App.Jsm
2020
App.Types
2121
App.Widgets.Asset
22-
App.Widgets.Fav
2322
App.Widgets.Main
2423
App.Widgets.Menu
2524
App.Widgets.Templates

ghcjs/delivery-calculator/src/App/Types.hs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,10 @@ import qualified Text.Regex as Re
6363
import qualified Text.URI as URI
6464

6565
data Model = Model
66-
{ modelFav :: OpenedOrClosed,
67-
modelMenu :: OpenedOrClosed,
66+
{ modelMenu :: OpenedOrClosed,
6867
modelLinks :: OpenedOrClosed,
6968
modelLoading :: Bool,
7069
modelState :: St Unique,
71-
modelFavMap :: Map Unicode Fav,
7270
modelUriViewer :: [FieldPair DynamicField Unique],
7371
modelDonateViewer :: [FieldPair DynamicField Unique],
7472
modelProducerQueue :: TChan (InstantOrDelayed (Update Model)),
@@ -95,7 +93,6 @@ data St f = St
9593
stMerchantTele :: Field Unicode f,
9694
stMerchantFeePercent :: Field DynamicField f,
9795
stOnlineOrOffline :: OnlineOrOffline,
98-
stFavName :: Field Unicode f,
9996
stPreview :: Field Unicode f,
10097
stScreen :: Screen,
10198
stEnableTheme :: Bool,
@@ -125,7 +122,6 @@ newSt = do
125122
merchantCur <- newCurrency rub
126123
tele <- newTextField "Functora"
127124
fee <- newDynamicField $ DynamicFieldNumber 2
128-
fav <- newTextField mempty
129125
pre <- newTextField "Delivery Calculator"
130126
pure
131127
St
@@ -137,7 +133,6 @@ newSt = do
137133
stMerchantTele = tele,
138134
stMerchantFeePercent = fee & #fieldType .~ FieldTypePercent,
139135
stOnlineOrOffline = Online,
140-
stFavName = fav,
141136
stPreview = pre & #fieldType .~ FieldTypeTitle,
142137
stScreen = Main,
143138
stEnableTheme = True,
@@ -216,7 +211,7 @@ verifyAsset asset =
216211
(qty ^. #fieldPairValue . #fieldOutput)
217212
if null failures
218213
then mempty
219-
else [blockquote_ mempty failures]
214+
else [keyed "asset-failure" $ blockquote_ mempty failures]
220215
_ ->
221216
mempty
222217

@@ -499,8 +494,7 @@ baseUri =
499494
setScreenPure :: Screen -> Update Model
500495
setScreenPure sc =
501496
PureUpdate
502-
$ (& #modelFav .~ Closed)
503-
. (& #modelMenu .~ Closed)
497+
$ (& #modelMenu .~ Closed)
504498
. (& #modelLinks .~ Closed)
505499
. (& #modelState . #stScreen .~ sc)
506500

ghcjs/delivery-calculator/src/App/Widgets/Fav.hs

Lines changed: 0 additions & 133 deletions
This file was deleted.

ghcjs/delivery-calculator/src/App/Widgets/Templates.hs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ newModel webOpts mSt uri = do
2525
market <- maybe Rates.newMarket pure $ mSt ^? _Just . #modelMarket
2626
pure
2727
Model
28-
{ modelFav = Closed,
29-
modelMenu = Closed,
28+
{ modelMenu = Closed,
3029
modelLinks = Closed,
3130
modelLoading = True,
3231
modelState = fromMaybe defSt mApp,
33-
modelFavMap = mempty,
3432
modelUriViewer = mempty,
3533
modelDonateViewer = donate,
3634
modelProducerQueue = prod,

ghcjs/delivery-calculator/src/Main.hs

Lines changed: 23 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,35 +131,31 @@ updateModel (InitUpdate ext) prevSt = do
131131
{ modelProducerQueue = prod,
132132
modelConsumerQueue = cons
133133
}
134-
Jsm.selectStorage ("favorite-" <> vsn) $ \mFav -> do
135-
let fav = mergeMap (const id) $ fromMaybe mempty mFav
136-
if isJust ext
137-
then
138-
pushActionQueue
139-
nextSt
134+
if isJust ext
135+
then
136+
pushActionQueue
137+
nextSt
138+
. Instant
139+
. PureUpdate
140+
$ #modelLoading
141+
.~ False
142+
else Jsm.selectStorage ("current-" <> vsn) $ \case
143+
Nothing ->
144+
pushActionQueue nextSt
140145
. Instant
141146
. PureUpdate
142-
$ (& #modelFavMap %~ fav)
143-
. (& #modelLoading .~ False)
144-
else Jsm.selectStorage ("current-" <> vsn) $ \case
145-
Nothing ->
146-
pushActionQueue nextSt
147-
. Instant
148-
. PureUpdate
149-
$ (& #modelFavMap %~ fav)
150-
. (& #modelLoading .~ False)
151-
Just uri -> do
152-
finSt <- newModel (nextSt ^. #modelWebOpts) (Just nextSt) uri
153-
pushActionQueue nextSt
154-
. Instant
155-
. PureUpdate
156-
$ ( const
157-
$ finSt
158-
& #modelFavMap
159-
%~ fav
160-
& #modelLoading
161-
.~ False
162-
)
147+
$ #modelLoading
148+
.~ False
149+
Just uri -> do
150+
finSt <- newModel (nextSt ^. #modelWebOpts) (Just nextSt) uri
151+
pushActionQueue nextSt
152+
. Instant
153+
. PureUpdate
154+
$ ( const
155+
$ finSt
156+
& #modelLoading
157+
.~ False
158+
)
163159
pure
164160
$ ChanUpdate (const nextSt)
165161
]
@@ -201,7 +197,6 @@ updateModel (ChanUpdate update0) st0 = do
201197
$ evalModel st2
202198
let st3 = update2 st2
203199
uri <- stUri st3
204-
Jsm.insertStorage ("favorite-" <> vsn) $ st3 ^. #modelFavMap
205200
Jsm.insertStorage ("current-" <> vsn) uri
206201
syncUri uri
207202
nextUri <- stUri $ st3 & #modelState . #stScreen %~ unQrCode

ghcjs/miso-functora/src/Functora/Miso/Widgets/Field.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ field full@Full {fullArgs = args, fullParser = parser, fullViewer = viewer} opts
148148
id
149149
( \x ->
150150
singleton
151+
. keyed (decodeUtf8 . unTagged $ htmlUid uid)
151152
. label_ mempty
152153
. (text x :)
153154
. (br_ mempty :)

0 commit comments

Comments
 (0)