rename runIOCatching to launchSigner

This commit is contained in:
Vitor Pamplona
2025-11-11 16:10:49 -05:00
parent b14c588a34
commit d4b91845d5
23 changed files with 101 additions and 101 deletions
@@ -102,7 +102,7 @@ class NewUserMetadataViewModel : ViewModel() {
fun create() { fun create() {
// Tries to not delete any existing attribute that we do not work with. // Tries to not delete any existing attribute that we do not work with.
accountViewModel.runIOCatching { accountViewModel.launchSigner {
val metadata = val metadata =
account.userMetadata.sendNewUserMetadata( account.userMetadata.sendNewUserMetadata(
name = displayName.value, name = displayName.value,
@@ -145,7 +145,7 @@ class NewUserMetadataViewModel : ViewModel() {
context: Context, context: Context,
onError: (String, String) -> Unit, onError: (String, String) -> Unit,
) { ) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
upload( upload(
uri, uri,
context, context,
@@ -161,7 +161,7 @@ class NewUserMetadataViewModel : ViewModel() {
context: Context, context: Context,
onError: (String, String) -> Unit, onError: (String, String) -> Unit,
) { ) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
upload( upload(
uri, uri,
context, context,
@@ -124,7 +124,7 @@ class BlossomServersViewModel : ViewModel() {
fun saveFileServers() { fun saveFileServers() {
if (isModified) { if (isModified) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
val serverList = _fileServers.value.map { it.baseUrl } val serverList = _fileServers.value.map { it.baseUrl }
account.sendBlossomServersList(serverList) account.sendBlossomServersList(serverList)
refresh() refresh()
@@ -119,7 +119,7 @@ class NIP96ServersViewModel : ViewModel() {
fun saveFileServers() { fun saveFileServers() {
if (isModified) { if (isModified) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
val serverList = _fileServers.value.map { it.baseUrl } val serverList = _fileServers.value.map { it.baseUrl }
account.sendFileServersList(serverList) account.sendFileServersList(serverList)
refresh() refresh()
@@ -138,7 +138,7 @@ fun GenericCommentPostScreen(
WatchAndLoadMyEmojiList(accountViewModel) WatchAndLoadMyEmojiList(accountViewModel)
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -152,7 +152,7 @@ fun GenericCommentPostScreen(
onCancel = { onCancel = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -161,7 +161,7 @@ fun GenericCommentPostScreen(
onPost = { onPost = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendPostSync() postViewModel.sendPostSync()
nav.popBack() nav.popBack()
} }
@@ -313,7 +313,7 @@ class AccountViewModel(
note: Note, note: Note,
reaction: String, reaction: String,
) { ) {
runIOCatching { launchSigner {
val currentReactions = note.allReactionsOfContentByAuthor(userProfile(), reaction) val currentReactions = note.allReactionsOfContentByAuthor(userProfile(), reaction)
if (currentReactions.isNotEmpty()) { if (currentReactions.isNotEmpty()) {
account.delete(currentReactions) account.delete(currentReactions)
@@ -679,7 +679,7 @@ class AccountViewModel(
onProgress: (percent: Float) -> Unit, onProgress: (percent: Float) -> Unit,
onPayViaIntent: (ImmutableList<ZapPaymentHandler.Payable>) -> Unit, onPayViaIntent: (ImmutableList<ZapPaymentHandler.Payable>) -> Unit,
zapType: LnZapEvent.ZapType? = null, zapType: LnZapEvent.ZapType? = null,
) = runIOCatching { ) = launchSigner {
ZapPaymentHandler(account).zap( ZapPaymentHandler(account).zap(
note = note, note = note,
amountMilliSats = amountInMillisats, amountMilliSats = amountInMillisats,
@@ -699,23 +699,23 @@ class AccountViewModel(
note: Note, note: Note,
type: ReportType, type: ReportType,
content: String = "", content: String = "",
) = runIOCatching { account.report(note, type, content) } ) = launchSigner { account.report(note, type, content) }
fun report( fun report(
user: User, user: User,
type: ReportType, type: ReportType,
) { ) {
runIOCatching { launchSigner {
account.report(user, type) account.report(user, type)
account.hideUser(user.pubkeyHex) account.hideUser(user.pubkeyHex)
} }
} }
fun boost(note: Note) = runIOCatching { account.boost(note) } fun boost(note: Note) = launchSigner { account.boost(note) }
fun removeEmojiPack(emojiPack: Note) = runIOCatching { account.removeEmojiPack(emojiPack) } fun removeEmojiPack(emojiPack: Note) = launchSigner { account.removeEmojiPack(emojiPack) }
fun addEmojiPack(emojiPack: Note) = runIOCatching { account.addEmojiPack(emojiPack) } fun addEmojiPack(emojiPack: Note) = launchSigner { account.addEmojiPack(emojiPack) }
fun addMediaToGallery( fun addMediaToGallery(
hex: String, hex: String,
@@ -725,40 +725,40 @@ class AccountViewModel(
dim: DimensionTag?, dim: DimensionTag?,
hash: String?, hash: String?,
mimeType: String?, mimeType: String?,
) = runIOCatching { account.addToGallery(hex, url, relay, blurhash, dim, hash, mimeType) } ) = launchSigner { account.addToGallery(hex, url, relay, blurhash, dim, hash, mimeType) }
fun removeFromMediaGallery(note: Note) = runIOCatching { account.removeFromGallery(note) } fun removeFromMediaGallery(note: Note) = launchSigner { account.removeFromGallery(note) }
fun hashtagFollows(user: User): Note = LocalCache.getOrCreateAddressableNote(HashtagListEvent.createAddress(user.pubkeyHex)) fun hashtagFollows(user: User): Note = LocalCache.getOrCreateAddressableNote(HashtagListEvent.createAddress(user.pubkeyHex))
fun bookmarks(user: User): Note = LocalCache.getOrCreateAddressableNote(BookmarkListEvent.createBookmarkAddress(user.pubkeyHex)) fun bookmarks(user: User): Note = LocalCache.getOrCreateAddressableNote(BookmarkListEvent.createBookmarkAddress(user.pubkeyHex))
fun addPrivateBookmark(note: Note) = runIOCatching { account.addBookmark(note, true) } fun addPrivateBookmark(note: Note) = launchSigner { account.addBookmark(note, true) }
fun addPublicBookmark(note: Note) = runIOCatching { account.addBookmark(note, false) } fun addPublicBookmark(note: Note) = launchSigner { account.addBookmark(note, false) }
fun removePrivateBookmark(note: Note) = runIOCatching { account.removeBookmark(note, true) } fun removePrivateBookmark(note: Note) = launchSigner { account.removeBookmark(note, true) }
fun removePublicBookmark(note: Note) = runIOCatching { account.removeBookmark(note, false) } fun removePublicBookmark(note: Note) = launchSigner { account.removeBookmark(note, false) }
fun broadcast(note: Note) = runIOCatching { account.broadcast(note) } fun broadcast(note: Note) = launchSigner { account.broadcast(note) }
fun timestamp(note: Note) = runIOCatching { account.otsState.timestamp(note) } fun timestamp(note: Note) = launchSigner { account.otsState.timestamp(note) }
fun delete(notes: List<Note>) = runIOCatching { account.delete(notes) } fun delete(notes: List<Note>) = launchSigner { account.delete(notes) }
fun delete(note: Note) = runIOCatching { account.delete(note) } fun delete(note: Note) = launchSigner { account.delete(note) }
fun cachedDecrypt(note: Note): String? = account.cachedDecryptContent(note) fun cachedDecrypt(note: Note): String? = account.cachedDecryptContent(note)
fun decrypt( fun decrypt(
note: Note, note: Note,
onReady: (String) -> Unit, onReady: (String) -> Unit,
) = runIOCatching { ) = launchSigner {
account.decryptContent(note)?.let { onReady(it) } account.decryptContent(note)?.let { onReady(it) }
} }
inline fun runIOCatching(crossinline action: suspend () -> Unit) { inline fun launchSigner(crossinline action: suspend () -> Unit) {
viewModelScope.launch(Dispatchers.IO) { viewModelScope.launch(Dispatchers.IO) {
try { try {
action() action()
@@ -796,35 +796,35 @@ class AccountViewModel(
fun approveCommunityPost( fun approveCommunityPost(
post: Note, post: Note,
community: AddressableNote, community: AddressableNote,
) = runIOCatching { account.approveCommunityPost(post, community) } ) = launchSigner { account.approveCommunityPost(post, community) }
fun follow(community: AddressableNote) = runIOCatching { account.follow(community) } fun follow(community: AddressableNote) = launchSigner { account.follow(community) }
fun follow(channel: PublicChatChannel) = runIOCatching { account.follow(channel) } fun follow(channel: PublicChatChannel) = launchSigner { account.follow(channel) }
fun follow(channel: EphemeralChatChannel) = runIOCatching { account.follow(channel) } fun follow(channel: EphemeralChatChannel) = launchSigner { account.follow(channel) }
fun unfollow(community: AddressableNote) = runIOCatching { account.unfollow(community) } fun unfollow(community: AddressableNote) = launchSigner { account.unfollow(community) }
fun unfollow(channel: PublicChatChannel) = runIOCatching { account.unfollow(channel) } fun unfollow(channel: PublicChatChannel) = launchSigner { account.unfollow(channel) }
fun unfollow(channel: EphemeralChatChannel) = runIOCatching { account.unfollow(channel) } fun unfollow(channel: EphemeralChatChannel) = launchSigner { account.unfollow(channel) }
fun follow(user: User) = runIOCatching { account.follow(user) } fun follow(user: User) = launchSigner { account.follow(user) }
fun unfollow(user: User) = runIOCatching { account.unfollow(user) } fun unfollow(user: User) = launchSigner { account.unfollow(user) }
fun followGeohash(tag: String) = runIOCatching { account.followGeohash(tag) } fun followGeohash(tag: String) = launchSigner { account.followGeohash(tag) }
fun unfollowGeohash(tag: String) = runIOCatching { account.unfollowGeohash(tag) } fun unfollowGeohash(tag: String) = launchSigner { account.unfollowGeohash(tag) }
fun followHashtag(tag: String) = runIOCatching { account.followHashtag(tag) } fun followHashtag(tag: String) = launchSigner { account.followHashtag(tag) }
fun unfollowHashtag(tag: String) = runIOCatching { account.unfollowHashtag(tag) } fun unfollowHashtag(tag: String) = launchSigner { account.unfollowHashtag(tag) }
fun showWord(word: String) = runIOCatching { account.showWord(word) } fun showWord(word: String) = launchSigner { account.showWord(word) }
fun hideWord(word: String) = runIOCatching { account.hideWord(word) } fun hideWord(word: String) = launchSigner { account.hideWord(word) }
fun isLoggedUser(pubkeyHex: HexKey?): Boolean = account.signer.pubKey == pubkeyHex fun isLoggedUser(pubkeyHex: HexKey?): Boolean = account.signer.pubKey == pubkeyHex
@@ -859,21 +859,21 @@ class AccountViewModel(
fun filterSpamFromStrangers() = account.settings.syncedSettings.security.filterSpamFromStrangers fun filterSpamFromStrangers() = account.settings.syncedSettings.security.filterSpamFromStrangers
fun updateWarnReports(warnReports: Boolean) = runIOCatching { account.updateWarnReports(warnReports) } fun updateWarnReports(warnReports: Boolean) = launchSigner { account.updateWarnReports(warnReports) }
fun updateFilterSpam(filterSpam: Boolean) = fun updateFilterSpam(filterSpam: Boolean) =
runIOCatching { launchSigner {
if (account.updateFilterSpam(filterSpam)) { if (account.updateFilterSpam(filterSpam)) {
LocalCache.antiSpam.active = filterSpamFromStrangers().value LocalCache.antiSpam.active = filterSpamFromStrangers().value
} }
} }
fun updateShowSensitiveContent(show: Boolean?) = runIOCatching { account.updateShowSensitiveContent(show) } fun updateShowSensitiveContent(show: Boolean?) = launchSigner { account.updateShowSensitiveContent(show) }
fun changeReactionTypes( fun changeReactionTypes(
reactionSet: List<String>, reactionSet: List<String>,
onDone: () -> Unit, onDone: () -> Unit,
) = runIOCatching { ) = launchSigner {
account.changeReactionTypes(reactionSet) account.changeReactionTypes(reactionSet)
onDone() onDone()
} }
@@ -882,37 +882,37 @@ class AccountViewModel(
amountSet: List<Long>, amountSet: List<Long>,
selectedZapType: LnZapEvent.ZapType, selectedZapType: LnZapEvent.ZapType,
nip47Update: Nip47WalletConnect.Nip47URINorm?, nip47Update: Nip47WalletConnect.Nip47URINorm?,
) = runIOCatching { account.updateZapAmounts(amountSet, selectedZapType, nip47Update) } ) = launchSigner { account.updateZapAmounts(amountSet, selectedZapType, nip47Update) }
fun toggleDontTranslateFrom(languageCode: String) = runIOCatching { account.toggleDontTranslateFrom(languageCode) } fun toggleDontTranslateFrom(languageCode: String) = launchSigner { account.toggleDontTranslateFrom(languageCode) }
fun updateTranslateTo(languageCode: Locale) = runIOCatching { account.updateTranslateTo(languageCode) } fun updateTranslateTo(languageCode: Locale) = launchSigner { account.updateTranslateTo(languageCode) }
fun prefer( fun prefer(
source: String, source: String,
target: String, target: String,
preference: String, preference: String,
) = runIOCatching { account.prefer(source, target, preference) } ) = launchSigner { account.prefer(source, target, preference) }
fun show(user: User) = runIOCatching { account.showUser(user.pubkeyHex) } fun show(user: User) = launchSigner { account.showUser(user.pubkeyHex) }
fun hide(user: User) = runIOCatching { account.hideUser(user.pubkeyHex) } fun hide(user: User) = launchSigner { account.hideUser(user.pubkeyHex) }
fun hide(word: String) = runIOCatching { account.hideWord(word) } fun hide(word: String) = launchSigner { account.hideWord(word) }
fun showUser(pubkeyHex: String) = runIOCatching { account.showUser(pubkeyHex) } fun showUser(pubkeyHex: String) = launchSigner { account.showUser(pubkeyHex) }
fun createStatus(newStatus: String) = runIOCatching { account.createStatus(newStatus) } fun createStatus(newStatus: String) = launchSigner { account.createStatus(newStatus) }
fun updateStatus( fun updateStatus(
address: Address, address: Address,
newStatus: String, newStatus: String,
) = runIOCatching { ) = launchSigner {
account.updateStatus(LocalCache.getOrCreateAddressableNote(address), newStatus) account.updateStatus(LocalCache.getOrCreateAddressableNote(address), newStatus)
} }
fun deleteStatus(address: Address) = fun deleteStatus(address: Address) =
runIOCatching { launchSigner {
account.deleteStatus(LocalCache.getOrCreateAddressableNote(address)) account.deleteStatus(LocalCache.getOrCreateAddressableNote(address))
} }
@@ -1181,7 +1181,7 @@ class AccountViewModel(
val hint = note.toEventHint<VoiceEvent>() val hint = note.toEventHint<VoiceEvent>()
if (hint == null) return if (hint == null) return
runIOCatching { launchSigner {
val uploader = UploadOrchestrator() val uploader = UploadOrchestrator()
val result = val result =
uploader.upload( uploader.upload(
@@ -1274,7 +1274,7 @@ class AccountViewModel(
if (isWriteable()) { if (isWriteable()) {
val boosts = baseNote.boostedBy(userProfile()) val boosts = baseNote.boostedBy(userProfile())
if (boosts.isNotEmpty()) { if (boosts.isNotEmpty()) {
runIOCatching { launchSigner {
account.delete(boosts) account.delete(boosts)
} }
} else { } else {
@@ -1404,7 +1404,7 @@ class AccountViewModel(
fun unwrapIfNeeded( fun unwrapIfNeeded(
note: Note?, note: Note?,
onReady: (Note) -> Unit = {}, onReady: (Note) -> Unit = {},
) = runIOCatching { ) = launchSigner {
val noteEvent = note?.event val noteEvent = note?.event
if (noteEvent != null) { if (noteEvent != null) {
val resultingNote = unwrapIfNeeded(noteEvent) val resultingNote = unwrapIfNeeded(noteEvent)
@@ -1436,7 +1436,7 @@ class AccountViewModel(
dvmPublicKey: User, dvmPublicKey: User,
onReady: (event: Note) -> Unit, onReady: (event: Note) -> Unit,
) { ) {
runIOCatching { launchSigner {
account.requestDVMContentDiscovery(dvmPublicKey) { account.requestDVMContentDiscovery(dvmPublicKey) {
onReady(LocalCache.getOrCreateNote(it.id)) onReady(LocalCache.getOrCreateNote(it.id))
} }
@@ -1470,7 +1470,7 @@ class AccountViewModel(
zappedNote: Note?, zappedNote: Note?,
onSent: () -> Unit = {}, onSent: () -> Unit = {},
onResponse: (Response?) -> Unit, onResponse: (Response?) -> Unit,
) = runIOCatching { ) = launchSigner {
account.sendZapPaymentRequestFor(bolt11, zappedNote, onResponse) account.sendZapPaymentRequestFor(bolt11, zappedNote, onResponse)
onSent() onSent()
} }
@@ -1481,7 +1481,7 @@ class AccountViewModel(
root: InteractiveStoryBaseEvent, root: InteractiveStoryBaseEvent,
readingScene: InteractiveStoryBaseEvent, readingScene: InteractiveStoryBaseEvent,
) { ) {
runIOCatching { launchSigner {
val sceneNoteRelayHint = LocalCache.getOrCreateAddressableNote(readingScene.address()).relayHintUrl() val sceneNoteRelayHint = LocalCache.getOrCreateAddressableNote(readingScene.address()).relayHintUrl()
val readingState = getInteractiveStoryReadingState(root.addressTag()) val readingState = getInteractiveStoryReadingState(root.addressTag())
@@ -98,7 +98,7 @@ fun NewChatroomSubjectDialog(
PostButton( PostButton(
onPost = { onPost = {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
val template = val template =
ChatMessageEvent.build( ChatMessageEvent.build(
message.value, message.value,
@@ -114,7 +114,7 @@ class ChatNewMessageViewModel :
draftTag.versions.collectLatest { draftTag.versions.collectLatest {
// don't save the first // don't save the first
if (it > 0) { if (it > 0) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
sendDraftSync() sendDraftSync()
} }
} }
@@ -393,7 +393,7 @@ class ChatNewMessageViewModel :
) { ) {
val uploadState = uploadState ?: return val uploadState = uploadState ?: return
accountViewModel.runIOCatching { accountViewModel.launchSigner {
if (nip17) { if (nip17) {
ChatFileUploader(account).justUploadNIP17(uploadState, onError, context) { ChatFileUploader(account).justUploadNIP17(uploadState, onError, context) {
uploadsWaitingToBeSent += it uploadsWaitingToBeSent += it
@@ -418,7 +418,7 @@ class ChatNewMessageViewModel :
val room = room ?: return val room = room ?: return
val uploadState = uploadState ?: return val uploadState = uploadState ?: return
accountViewModel.runIOCatching { accountViewModel.launchSigner {
if (nip17) { if (nip17) {
ChatFileUploader(account).justUploadNIP17(uploadState, onError, context) { ChatFileUploader(account).justUploadNIP17(uploadState, onError, context) {
ChatFileSender(room, account).sendNIP17(it) ChatFileSender(room, account).sendNIP17(it)
@@ -169,7 +169,7 @@ fun NewGroupDMScreen(
WatchAndLoadMyEmojiList(accountViewModel) WatchAndLoadMyEmojiList(accountViewModel)
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -184,7 +184,7 @@ fun NewGroupDMScreen(
onCancel = { onCancel = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -193,7 +193,7 @@ fun NewGroupDMScreen(
onPost = { onPost = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendPostSync() postViewModel.sendPostSync()
postViewModel.room?.let { postViewModel.room?.let {
nav.nav(routeToMessage(it, null, null, null, null, accountViewModel)) nav.nav(routeToMessage(it, null, null, null, null, accountViewModel))
@@ -85,7 +85,7 @@ fun PrivateMessageEditFieldRow(
nav: INav, nav: INav,
) { ) {
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
channelScreenModel.sendDraftSync() channelScreenModel.sendDraftSync()
channelScreenModel.cancel() channelScreenModel.cancel()
} }
@@ -170,7 +170,7 @@ fun EditField(
isActive = channelScreenModel.canPost(), isActive = channelScreenModel.canPost(),
modifier = EditFieldTrailingIconModifier, modifier = EditFieldTrailingIconModifier,
) { ) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
channelScreenModel.sendPostSync() channelScreenModel.sendPostSync()
onSendNewMessage() onSendNewMessage()
} }
@@ -107,7 +107,7 @@ open class ChannelNewMessageViewModel :
draftTag.versions.collectLatest { draftTag.versions.collectLatest {
// don't save the first // don't save the first
if (it > 0) { if (it > 0) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
sendDraftSync() sendDraftSync()
} }
} }
@@ -263,7 +263,7 @@ open class ChannelNewMessageViewModel :
} }
fun sendPost(onDone: suspend () -> Unit) { fun sendPost(onDone: suspend () -> Unit) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
sendPostSync() sendPostSync()
onDone() onDone()
} }
@@ -62,7 +62,7 @@ fun EditFieldRow(
nav: INav, nav: INav,
) { ) {
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
channelScreenModel.sendDraftSync() channelScreenModel.sendDraftSync()
channelScreenModel.cancel() channelScreenModel.cancel()
} }
@@ -139,7 +139,7 @@ fun NewProductScreen(
WatchAndLoadMyEmojiList(accountViewModel) WatchAndLoadMyEmojiList(accountViewModel)
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -154,7 +154,7 @@ fun NewProductScreen(
onCancel = { onCancel = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -112,7 +112,7 @@ open class NewProductViewModel :
draftTag.versions.collectLatest { draftTag.versions.collectLatest {
// don't save the first // don't save the first
if (it > 0) { if (it > 0) {
accountViewModel?.runIOCatching { accountViewModel?.launchSigner {
sendDraftSync() sendDraftSync()
} }
} }
@@ -167,7 +167,7 @@ private fun NewPostScreenInner(
WatchAndLoadMyEmojiList(accountViewModel) WatchAndLoadMyEmojiList(accountViewModel)
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -181,7 +181,7 @@ private fun NewPostScreenInner(
onPost = { onPost = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendPostSync() postViewModel.sendPostSync()
nav.popBack() nav.popBack()
} }
@@ -189,7 +189,7 @@ private fun NewPostScreenInner(
onCancel = { onCancel = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -146,7 +146,7 @@ open class ShortNotePostViewModel :
draftTag.versions.collectLatest { draftTag.versions.collectLatest {
// don't save the first // don't save the first
if (it > 0) { if (it > 0) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
sendDraftSync() sendDraftSync()
} }
} }
@@ -237,7 +237,7 @@ private fun ListViewAndEditColumn(
pagerState = pagerState, pagerState = pagerState,
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
onDeleteUser = { user, isPrivate -> onDeleteUser = { user, isPrivate ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
viewModel.removeUserFromSet(user, isPrivate) viewModel.removeUserFromSet(user, isPrivate)
} }
}, },
@@ -303,7 +303,7 @@ private fun RenderAddUserFieldAndSuggestions(
viewModel.hasUserFlow(user, pagerState.currentPage == 1) viewModel.hasUserFlow(user, pagerState.currentPage == 1)
}, },
onSelect = { user -> onSelect = { user ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
viewModel.addUserToSet(user, pagerState.currentPage == 1) viewModel.addUserToSet(user, pagerState.currentPage == 1)
} }
userName = userName =
@@ -312,7 +312,7 @@ private fun RenderAddUserFieldAndSuggestions(
) )
}, },
onDelete = { user -> onDelete = { user ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
viewModel.removeUserFromSet(user, pagerState.currentPage == 1) viewModel.removeUserFromSet(user, pagerState.currentPage == 1)
} }
userName = userName =
@@ -563,14 +563,14 @@ fun ListActionsMenuButton(
) { ) {
ListActionsMenuButton( ListActionsMenuButton(
onBroadcastList = { onBroadcastList = {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
viewModel.loadNote()?.let { updatedSetNote -> viewModel.loadNote()?.let { updatedSetNote ->
accountViewModel.broadcast(updatedSetNote) accountViewModel.broadcast(updatedSetNote)
} }
} }
}, },
onDeleteList = { onDeleteList = {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
viewModel.deleteFollowSet() viewModel.deleteFollowSet()
} }
nav.popBack() nav.popBack()
@@ -52,7 +52,7 @@ fun ListOfPeopleListsScreen(
ListOfPeopleListsScreen( ListOfPeopleListsScreen(
listFlow = accountViewModel.account.peopleLists.uiListFlow, listFlow = accountViewModel.account.peopleLists.uiListFlow,
addItem = { title: String, description: String? -> addItem = { title: String, description: String? ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.addFollowList( accountViewModel.account.peopleLists.addFollowList(
listName = title, listName = title,
listDescription = description, listDescription = description,
@@ -64,7 +64,7 @@ fun ListOfPeopleListsScreen(
nav.nav(Route.PeopleListView(it)) nav.nav(Route.PeopleListView(it))
}, },
renameItem = { followSet, newValue -> renameItem = { followSet, newValue ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.renameFollowList( accountViewModel.account.peopleLists.renameFollowList(
newName = newValue, newName = newValue,
peopleList = followSet, peopleList = followSet,
@@ -73,7 +73,7 @@ fun ListOfPeopleListsScreen(
} }
}, },
changeItemDescription = { followSet, newDescription -> changeItemDescription = { followSet, newDescription ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.modifyFollowSetDescription( accountViewModel.account.peopleLists.modifyFollowSetDescription(
newDescription = newDescription, newDescription = newDescription,
peopleList = followSet, peopleList = followSet,
@@ -82,7 +82,7 @@ fun ListOfPeopleListsScreen(
} }
}, },
cloneItem = { followSet, customName, customDescription -> cloneItem = { followSet, customName, customDescription ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.cloneFollowSet( accountViewModel.account.peopleLists.cloneFollowSet(
currentPeopleList = followSet, currentPeopleList = followSet,
customCloneName = customName, customCloneName = customName,
@@ -92,7 +92,7 @@ fun ListOfPeopleListsScreen(
} }
}, },
deleteItem = { followSet -> deleteItem = { followSet ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.deleteFollowSet( accountViewModel.account.peopleLists.deleteFollowSet(
identifierTag = followSet.identifierTag, identifierTag = followSet.identifierTag,
account = accountViewModel.account, account = accountViewModel.account,
@@ -135,7 +135,7 @@ private fun PeopleListAndUserFab(accountViewModel: AccountViewModel) {
isOpen = false isOpen = false
}, },
onCreateList = { name, description -> onCreateList = { name, description ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.addFollowList( accountViewModel.account.peopleLists.addFollowList(
listName = name, listName = name,
listDescription = description, listDescription = description,
@@ -75,7 +75,7 @@ fun PeopleListAndUserView(
userIsPrivateMember = list.privateMembers.contains(userToAddOrRemove), userIsPrivateMember = list.privateMembers.contains(userToAddOrRemove),
userIsPublicMember = list.publicMembers.contains(userToAddOrRemove), userIsPublicMember = list.publicMembers.contains(userToAddOrRemove),
onRemoveUser = { onRemoveUser = {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.removeUserFromSet( accountViewModel.account.peopleLists.removeUserFromSet(
userToAddOrRemove, userToAddOrRemove,
isPrivate = list.privateMembers.contains(userToAddOrRemove), isPrivate = list.privateMembers.contains(userToAddOrRemove),
@@ -87,7 +87,7 @@ fun PeopleListAndUserView(
privateMemberSize = list.privateMembers.size, privateMemberSize = list.privateMembers.size,
publicMemberSize = list.publicMembers.size, publicMemberSize = list.publicMembers.size,
onAddUserToList = { userShouldBePrivate -> onAddUserToList = { userShouldBePrivate ->
accountViewModel.runIOCatching { accountViewModel.launchSigner {
accountViewModel.account.peopleLists.addUserToSet( accountViewModel.account.peopleLists.addUserToSet(
userToAddOrRemove, userToAddOrRemove,
list.identifierTag, list.identifierTag,
@@ -129,7 +129,7 @@ fun NewPublicMessageScreen(
WatchAndLoadMyEmojiList(accountViewModel) WatchAndLoadMyEmojiList(accountViewModel)
BackHandler { BackHandler {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -144,7 +144,7 @@ fun NewPublicMessageScreen(
onCancel = { onCancel = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendDraftSync() postViewModel.sendDraftSync()
postViewModel.cancel() postViewModel.cancel()
} }
@@ -153,7 +153,7 @@ fun NewPublicMessageScreen(
onPost = { onPost = {
// uses the accountViewModel scope to avoid cancelling this // uses the accountViewModel scope to avoid cancelling this
// function when the postViewModel is released // function when the postViewModel is released
accountViewModel.runIOCatching { accountViewModel.launchSigner {
postViewModel.sendPostSync() postViewModel.sendPostSync()
nav.popBack() nav.popBack()
} }
@@ -126,7 +126,7 @@ class NewPublicMessageViewModel :
draftTag.versions.collectLatest { draftTag.versions.collectLatest {
// don't save the first // don't save the first
if (it > 0) { if (it > 0) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
sendDraftSync() sendDraftSync()
} }
} }
@@ -58,7 +58,7 @@ abstract class BasicRelaySetupInfoModel : ViewModel() {
fun create() { fun create() {
if (hasModified) { if (hasModified) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
saveRelayList(_relays.value.map { it.relay }) saveRelayList(_relays.value.map { it.relay })
clear() clear()
} }
@@ -62,7 +62,7 @@ class Nip65RelayListViewModel : ViewModel() {
fun create() { fun create() {
if (hasModified) { if (hasModified) {
accountViewModel.runIOCatching { accountViewModel.launchSigner {
val writes = _homeRelays.value.map { it.relay }.toSet() val writes = _homeRelays.value.map { it.relay }.toSet()
val reads = _notificationRelays.value.map { it.relay }.toSet() val reads = _notificationRelays.value.map { it.relay }.toSet()