Skip to content

Commit 2659e81

Browse files
committed
wip
1 parent 4148128 commit 2659e81

File tree

1 file changed

+26
-24
lines changed
  • ghcjs/delivery-calculator/src

1 file changed

+26
-24
lines changed

ghcjs/delivery-calculator/src/Main.hs

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -124,42 +124,40 @@ updateModel (Tick f) st =
124124
sleepSeconds 1
125125
ct <- getCurrentTime
126126
pure . Tick $ #modelTime .~ ct
127-
updateModel (InitUpdate ext) prevSt = do
127+
updateModel (InitUpdate mShortSt) prevSt = do
128128
effectSub prevSt $ \sink -> do
129129
liftIO . sink $ Tick id
130130
mvSink <- newMVar sink
131131
let nextSt = prevSt {modelSink = mvSink}
132-
if isJust ext
133-
then do
132+
Jsm.selectStorage ("current-" <> vsn) $ \case
133+
Nothing -> do
134134
liftIO
135135
. sink
136136
. PushUpdate
137137
. PureUpdate
138138
$ #modelLoading
139139
.~ False
140140
opfsSync sink nextSt
141-
else Jsm.selectStorage ("current-" <> vsn) $ \case
142-
Nothing -> do
143-
liftIO
144-
. sink
145-
. PushUpdate
146-
. PureUpdate
147-
$ #modelLoading
148-
.~ False
149-
opfsSync sink nextSt
150-
Just uri -> do
151-
mSt <- unLongUri uri
152-
finSt <- newModel (nextSt ^. #modelWebOpts) mvSink (Just nextSt) mSt
153-
liftIO
154-
. sink
155-
. PushUpdate
156-
. PureUpdate
157-
$ ( const
158-
$ finSt
159-
& #modelLoading
160-
.~ False
141+
Just uri -> do
142+
mLongSt <- unLongUri uri
143+
let st =
144+
( mShortSt <|> mLongSt
161145
)
162-
opfsSync sink finSt
146+
& _Just
147+
. #stAssets
148+
.~ ( fromMaybe mempty $ mLongSt ^? _Just . #stAssets
149+
)
150+
finSt <- newModel (nextSt ^. #modelWebOpts) mvSink (Just nextSt) st
151+
liftIO
152+
. sink
153+
. PushUpdate
154+
. PureUpdate
155+
$ ( const
156+
$ finSt
157+
& #modelLoading
158+
.~ False
159+
)
160+
opfsSync sink finSt
163161
liftIO
164162
. sink
165163
. PushUpdate
@@ -210,6 +208,10 @@ updateModel (EvalUpdate f) st = do
210208
& #fieldPairValue
211209
. #fieldType
212210
.~ FieldTypeQrCode
211+
& #fieldPairValue
212+
. #fieldOpts
213+
. #fieldOptsTruncateLimit
214+
.~ Nothing
213215
],
214216
do
215217
--

0 commit comments

Comments
 (0)