Skip to content

Commit

Permalink
Frontend.XF: switch to main thread for showing dialogs
Browse files Browse the repository at this point in the history
This is to fix a threading issue likely introduced in [1] and/or [2]
which sometimes was causing a crash (especially in GTK), and which
we have fixed thanks to gui-thread-check[3] and the migration of it to
the new Mono Profiler API [4].

[1] https://gitlab.com/nblockchain/geewallet/commit/513c00646c25192d36d4d55e6cbc7ec3dd3413ab
[2] https://gitlab.com/nblockchain/geewallet/commit/e1e0531c76f640b231726c8516843461cf3c876f
[3] https://github.com/slluis/gui-thread-check/
[4] slluis/gui-thread-check#8
  • Loading branch information
aarani authored and knocte committed Jul 18, 2022
1 parent 8cf0038 commit 70dfc8a
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/GWallet.Frontend.XF/WelcomePage.xaml.fs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ type WelcomePage(state: FrontendHelpers.IGlobalAppState) =
| Some warning ->
async {
do!
this.DisplayAlert("Alert", warning, "OK")
(fun () ->
this.DisplayAlert("Alert", warning, "OK")
)
|> Device.InvokeOnMainThreadAsync
|> Async.AwaitTask
}
| None ->
Expand All @@ -138,9 +141,9 @@ type WelcomePage(state: FrontendHelpers.IGlobalAppState) =
async {
let! mainThreadSynchContext =
Async.AwaitTask <| Device.GetMainThreadSynchronizationContextAsync()
do! Async.SwitchToContext mainThreadSynchContext
let! continueAnyway = Async.AwaitTask displayTask
if continueAnyway then
do! Async.SwitchToContext mainThreadSynchContext
do! submit()
return ()
else
Expand All @@ -149,8 +152,12 @@ type WelcomePage(state: FrontendHelpers.IGlobalAppState) =
else
submit () |> FrontendHelpers.DoubleCheckCompletionAsync false

member this.OnMoreInfoButtonClicked(_sender: Object, _args: EventArgs) =
member private this.DisplayInfo() =
this.DisplayAlert("Info", "Please note that geewallet is a brain-wallet, which means that this personal information is not registered in any server or any location outside your device, not even saved in your device. It will just be combined and hashed to generate a unique secret which is called a 'private key' which will allow you to recover your funds if you install the application again (in this or other device) later. \r\n\r\n(If it is your first time using this wallet and just want to test it quickly without any funds or low amounts, you can just input any data that is long enough to be considered valid.)", "OK")

member this.OnMoreInfoButtonClicked(_sender: Object, _args: EventArgs) =
this.DisplayInfo
|> Device.InvokeOnMainThreadAsync
|> FrontendHelpers.DoubleCheckCompletionNonGeneric

member __.OnOkButtonClicked(_sender: Object, _args: EventArgs) =
Expand Down

0 comments on commit 70dfc8a

Please sign in to comment.