Generate SSD truth sync actions from typed Jerboa

ober

2f4ce3131e027cefcf37866b0d09f089fe11fcb9

diff --git a/templates/ssd-review.ss b/templates/ssd-review.ss
index 44f8a98..0e4e135 100644
--- a/templates/ssd-review.ss
+++ b/templates/ssd-review.ss
@@ -4718,6 +4718,7 @@
                       (android widget EditText)
                       (android widget Button)
                       (android widget TextView)
+                      (android widget Toast)
                       (androidx documentfile provider DocumentFile)
                       (org json JSONObject))
       (typed-library (com sfb ssdreview)
@@ -4824,6 +4825,8 @@
                 mainActivitySetPositiveLoadPage
                 runBackground mainActivityLogClientEventAsync
                 mainActivitySetPdfChoiceItems
+                mainActivityPullTruthDumpAsync
+                mainActivityPushTruthDumpAsync
                 mainActivityInstallApproveAreaDialogButton
                 mainActivityInstallAppendDialogButton
                 mainActivityInstallEditDialogButtons
@@ -4936,6 +4939,7 @@
         (type TruthStore)
         (type TextView)
         (type TextWatcher)
+        (type Toast)
         (type ViewportState)
         (record BoxTypeDialogState
           ((mut previousBoxType : String)))
@@ -5051,6 +5055,15 @@
           (kotlin-call Thread))
         (extern (threadStartRaw (thread : Thread)) : Unit
           (kotlin-member-call start))
+        (extern (exceptionMessageRaw (error : Exception)) : (Nullable String)
+          (kotlin-member-get message))
+        (extern (toastMakeTextRaw
+                  (activity : MainActivity)
+                  (text : String)
+                  (duration : Int32)) : Toast
+          (kotlin-call Toast makeText))
+        (extern (toastShowRaw (toast : Toast)) : Unit
+          (kotlin-member-call show))
         (extern (boxTypeRawIsWeaponFromActivity
                   (activity : MainActivity)
                   (raw : String)) : Bool
@@ -6781,6 +6794,67 @@
                 activity
                 (ssdPdfChoiceUriAt choices which)
                 readFlag))))
+        (def (showShortToast
+               (activity : MainActivity)
+               (text : String)) : Unit
+          (toastShowRaw (toastMakeTextRaw activity text (int32 0))))
+        (def (mainActivityPullTruthDumpAsync
+               (activity : MainActivity)
+               (store : TruthStore)) : Unit
+          (begin
+            (mainActivitySetStatusRaw activity (pullTruthStatus))
+            (runBackground
+              (lambda ()
+                (try
+                  (let ((imported (truthStorePullRemoteDumpCount store)))
+                    (mainActivityRunOnUiThreadRaw
+                      activity
+                      (lambda ()
+                        (begin
+                          (showShortToast activity "Truth pull complete")
+                          (mainActivitySetStatusRaw
+                            activity
+                            (pulledTruthStatus
+                              imported
+                              (truthStoreStorageSummary store)))
+                          (if (pdfUriLoaded (mainActivityPdfUriRaw activity))
+                              (mainActivityRenderCurrentPageRaw activity)
+                              (begin))))))
+                  (catch (error : Exception)
+                    (mainActivityRunOnUiThreadRaw
+                      activity
+                      (lambda ()
+                        (mainActivitySetStatusRaw
+                          activity
+                          (truthPullFailedStatus
+                            (exceptionMessageRaw error)))))))))))
+        (def (mainActivityPushTruthDumpAsync
+               (activity : MainActivity)
+               (store : TruthStore)) : Unit
+          (begin
+            (mainActivitySetStatusRaw activity (pushTruthStatus))
+            (runBackground
+              (lambda ()
+                (try
+                  (let ((imported (truthStorePushRemoteDumpCount store)))
+                    (mainActivityRunOnUiThreadRaw
+                      activity
+                      (lambda ()
+                        (begin
+                          (showShortToast activity "Truth push complete")
+                          (mainActivitySetStatusRaw
+                            activity
+                            (pushedTruthStatus
+                              imported
+                              (truthStoreStorageSummary store)))))))
+                  (catch (error : Exception)
+                    (mainActivityRunOnUiThreadRaw
+                      activity
+                      (lambda ()
+                        (mainActivitySetStatusRaw
+                          activity
+                          (truthPushFailedStatus
+                            (exceptionMessageRaw error)))))))))))
         (def (mainActivityInstallApproveAreaDialogButton
                (activity : MainActivity)
                (dialog : AlertDialog)
@@ -9112,38 +9186,11 @@
        "    }"
        ""
        "    private fun pullTruthDump() {"
-       "        setStatus(pullTruthStatus())"
-       "        thread {"
-       "            try {"
-       "                val imported = truthStorePullRemoteDumpCount(truthStore)"
-       "                runOnUiThread {"
-       "                    Toast.makeText(this, \"Truth pull complete\", Toast.LENGTH_SHORT).show()"
-       "                    setStatus(pulledTruthStatus(imported, truthStoreStorageSummary(truthStore)))"
-       "                    if (pdfUriLoaded(pdfUri)) renderCurrentPage()"
-       "                }"
-       "            } catch (error: Exception) {"
-       "                runOnUiThread {"
-	       "                    setStatus(truthPullFailedStatus(error.message))"
-       "                }"
-       "            }"
-       "        }"
+       "        mainActivityPullTruthDumpAsync(this, truthStore)"
        "    }"
        ""
        "    private fun pushTruthDump() {"
-       "        setStatus(pushTruthStatus())"
-       "        thread {"
-       "            try {"
-       "                val imported = truthStorePushRemoteDumpCount(truthStore)"
-       "                runOnUiThread {"
-       "                    Toast.makeText(this, \"Truth push complete\", Toast.LENGTH_SHORT).show()"
-       "                    setStatus(pushedTruthStatus(imported, truthStoreStorageSummary(truthStore)))"
-       "                }"
-       "            } catch (error: Exception) {"
-       "                runOnUiThread {"
-	       "                    setStatus(truthPushFailedStatus(error.message))"
-       "                }"
-       "            }"
-       "        }"
+       "        mainActivityPushTruthDumpAsync(this, truthStore)"
        "    }"
        ""
        "    override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {"