From d4b91845d5160508384a64324080efc0f82b6505 Mon Sep 17 00:00:00 2001 From: Vitor Pamplona Date: Tue, 11 Nov 2025 16:10:49 -0500 Subject: [PATCH] rename runIOCatching to launchSigner --- .../ui/actions/NewUserMetadataViewModel.kt | 6 +- .../mediaServers/BlossomServersViewModel.kt | 2 +- .../mediaServers/NIP96ServersViewModel.kt | 2 +- .../nip22Comments/GenericCommentPostScreen.kt | 6 +- .../ui/screen/loggedIn/AccountViewModel.kt | 110 +++++++++--------- .../header/NewChatroomSubjectDialog.kt | 2 +- .../privateDM/send/ChatNewMessageViewModel.kt | 6 +- .../chats/privateDM/send/NewGroupDMScreen.kt | 6 +- .../send/PrivateMessageEditFieldRow.kt | 4 +- .../send/ChannelNewMessageViewModel.kt | 4 +- .../chats/publicChannels/send/EditFieldRow.kt | 2 +- .../nip99Classifieds/NewProductScreen.kt | 4 +- .../nip99Classifieds/NewProductViewModel.kt | 2 +- .../loggedIn/home/ShortNotePostScreen.kt | 6 +- .../loggedIn/home/ShortNotePostViewModel.kt | 2 +- .../lists/display/PeopleListScreen.kt | 10 +- .../lists/list/ListOfPeopleListsScreen.kt | 10 +- .../memberEdit/PeopleListAndUserScreen.kt | 2 +- .../lists/memberEdit/PeopleListAndUserView.kt | 4 +- .../publicMessages/NewPublicMessageScreen.kt | 6 +- .../NewPublicMessageViewModel.kt | 2 +- .../relays/common/BasicRelaySetupInfoModel.kt | 2 +- .../relays/nip65/Nip65RelayListViewModel.kt | 2 +- 23 files changed, 101 insertions(+), 101 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataViewModel.kt index bb6263bd9..139bf9587 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/NewUserMetadataViewModel.kt @@ -102,7 +102,7 @@ class NewUserMetadataViewModel : ViewModel() { fun create() { // Tries to not delete any existing attribute that we do not work with. - accountViewModel.runIOCatching { + accountViewModel.launchSigner { val metadata = account.userMetadata.sendNewUserMetadata( name = displayName.value, @@ -145,7 +145,7 @@ class NewUserMetadataViewModel : ViewModel() { context: Context, onError: (String, String) -> Unit, ) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { upload( uri, context, @@ -161,7 +161,7 @@ class NewUserMetadataViewModel : ViewModel() { context: Context, onError: (String, String) -> Unit, ) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { upload( uri, context, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/BlossomServersViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/BlossomServersViewModel.kt index 8d1d601b9..c230ec35e 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/BlossomServersViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/BlossomServersViewModel.kt @@ -124,7 +124,7 @@ class BlossomServersViewModel : ViewModel() { fun saveFileServers() { if (isModified) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { val serverList = _fileServers.value.map { it.baseUrl } account.sendBlossomServersList(serverList) refresh() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/NIP96ServersViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/NIP96ServersViewModel.kt index c09bd7eb9..1523e75f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/NIP96ServersViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/actions/mediaServers/NIP96ServersViewModel.kt @@ -119,7 +119,7 @@ class NIP96ServersViewModel : ViewModel() { fun saveFileServers() { if (isModified) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { val serverList = _fileServers.value.map { it.baseUrl } account.sendFileServersList(serverList) refresh() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt index de6bf1f60..6f5d1e758 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/note/nip22Comments/GenericCommentPostScreen.kt @@ -138,7 +138,7 @@ fun GenericCommentPostScreen( WatchAndLoadMyEmojiList(accountViewModel) BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -152,7 +152,7 @@ fun GenericCommentPostScreen( onCancel = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -161,7 +161,7 @@ fun GenericCommentPostScreen( onPost = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendPostSync() nav.popBack() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 46085c9b6..e40d72a45 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -313,7 +313,7 @@ class AccountViewModel( note: Note, reaction: String, ) { - runIOCatching { + launchSigner { val currentReactions = note.allReactionsOfContentByAuthor(userProfile(), reaction) if (currentReactions.isNotEmpty()) { account.delete(currentReactions) @@ -679,7 +679,7 @@ class AccountViewModel( onProgress: (percent: Float) -> Unit, onPayViaIntent: (ImmutableList) -> Unit, zapType: LnZapEvent.ZapType? = null, - ) = runIOCatching { + ) = launchSigner { ZapPaymentHandler(account).zap( note = note, amountMilliSats = amountInMillisats, @@ -699,23 +699,23 @@ class AccountViewModel( note: Note, type: ReportType, content: String = "", - ) = runIOCatching { account.report(note, type, content) } + ) = launchSigner { account.report(note, type, content) } fun report( user: User, type: ReportType, ) { - runIOCatching { + launchSigner { account.report(user, type) 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( hex: String, @@ -725,40 +725,40 @@ class AccountViewModel( dim: DimensionTag?, hash: 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 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) = runIOCatching { account.delete(notes) } + fun delete(notes: List) = 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 decrypt( note: Note, onReady: (String) -> Unit, - ) = runIOCatching { + ) = launchSigner { account.decryptContent(note)?.let { onReady(it) } } - inline fun runIOCatching(crossinline action: suspend () -> Unit) { + inline fun launchSigner(crossinline action: suspend () -> Unit) { viewModelScope.launch(Dispatchers.IO) { try { action() @@ -796,35 +796,35 @@ class AccountViewModel( fun approveCommunityPost( post: Note, 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 @@ -859,21 +859,21 @@ class AccountViewModel( 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) = - runIOCatching { + launchSigner { if (account.updateFilterSpam(filterSpam)) { LocalCache.antiSpam.active = filterSpamFromStrangers().value } } - fun updateShowSensitiveContent(show: Boolean?) = runIOCatching { account.updateShowSensitiveContent(show) } + fun updateShowSensitiveContent(show: Boolean?) = launchSigner { account.updateShowSensitiveContent(show) } fun changeReactionTypes( reactionSet: List, onDone: () -> Unit, - ) = runIOCatching { + ) = launchSigner { account.changeReactionTypes(reactionSet) onDone() } @@ -882,37 +882,37 @@ class AccountViewModel( amountSet: List, selectedZapType: LnZapEvent.ZapType, 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( source: String, target: 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( address: Address, newStatus: String, - ) = runIOCatching { + ) = launchSigner { account.updateStatus(LocalCache.getOrCreateAddressableNote(address), newStatus) } fun deleteStatus(address: Address) = - runIOCatching { + launchSigner { account.deleteStatus(LocalCache.getOrCreateAddressableNote(address)) } @@ -1181,7 +1181,7 @@ class AccountViewModel( val hint = note.toEventHint() if (hint == null) return - runIOCatching { + launchSigner { val uploader = UploadOrchestrator() val result = uploader.upload( @@ -1274,7 +1274,7 @@ class AccountViewModel( if (isWriteable()) { val boosts = baseNote.boostedBy(userProfile()) if (boosts.isNotEmpty()) { - runIOCatching { + launchSigner { account.delete(boosts) } } else { @@ -1404,7 +1404,7 @@ class AccountViewModel( fun unwrapIfNeeded( note: Note?, onReady: (Note) -> Unit = {}, - ) = runIOCatching { + ) = launchSigner { val noteEvent = note?.event if (noteEvent != null) { val resultingNote = unwrapIfNeeded(noteEvent) @@ -1436,7 +1436,7 @@ class AccountViewModel( dvmPublicKey: User, onReady: (event: Note) -> Unit, ) { - runIOCatching { + launchSigner { account.requestDVMContentDiscovery(dvmPublicKey) { onReady(LocalCache.getOrCreateNote(it.id)) } @@ -1470,7 +1470,7 @@ class AccountViewModel( zappedNote: Note?, onSent: () -> Unit = {}, onResponse: (Response?) -> Unit, - ) = runIOCatching { + ) = launchSigner { account.sendZapPaymentRequestFor(bolt11, zappedNote, onResponse) onSent() } @@ -1481,7 +1481,7 @@ class AccountViewModel( root: InteractiveStoryBaseEvent, readingScene: InteractiveStoryBaseEvent, ) { - runIOCatching { + launchSigner { val sceneNoteRelayHint = LocalCache.getOrCreateAddressableNote(readingScene.address()).relayHintUrl() val readingState = getInteractiveStoryReadingState(root.addressTag()) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/header/NewChatroomSubjectDialog.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/header/NewChatroomSubjectDialog.kt index e8fd51ae0..d9c4564f0 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/header/NewChatroomSubjectDialog.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/header/NewChatroomSubjectDialog.kt @@ -98,7 +98,7 @@ fun NewChatroomSubjectDialog( PostButton( onPost = { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { val template = ChatMessageEvent.build( message.value, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt index ed36b2e20..b3d43b380 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/ChatNewMessageViewModel.kt @@ -114,7 +114,7 @@ class ChatNewMessageViewModel : draftTag.versions.collectLatest { // don't save the first if (it > 0) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { sendDraftSync() } } @@ -393,7 +393,7 @@ class ChatNewMessageViewModel : ) { val uploadState = uploadState ?: return - accountViewModel.runIOCatching { + accountViewModel.launchSigner { if (nip17) { ChatFileUploader(account).justUploadNIP17(uploadState, onError, context) { uploadsWaitingToBeSent += it @@ -418,7 +418,7 @@ class ChatNewMessageViewModel : val room = room ?: return val uploadState = uploadState ?: return - accountViewModel.runIOCatching { + accountViewModel.launchSigner { if (nip17) { ChatFileUploader(account).justUploadNIP17(uploadState, onError, context) { ChatFileSender(room, account).sendNIP17(it) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt index 21f0f7f6c..ab72a1d18 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/NewGroupDMScreen.kt @@ -169,7 +169,7 @@ fun NewGroupDMScreen( WatchAndLoadMyEmojiList(accountViewModel) BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -184,7 +184,7 @@ fun NewGroupDMScreen( onCancel = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -193,7 +193,7 @@ fun NewGroupDMScreen( onPost = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendPostSync() postViewModel.room?.let { nav.nav(routeToMessage(it, null, null, null, null, accountViewModel)) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/PrivateMessageEditFieldRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/PrivateMessageEditFieldRow.kt index f129856d4..34f637ef7 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/PrivateMessageEditFieldRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/privateDM/send/PrivateMessageEditFieldRow.kt @@ -85,7 +85,7 @@ fun PrivateMessageEditFieldRow( nav: INav, ) { BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { channelScreenModel.sendDraftSync() channelScreenModel.cancel() } @@ -170,7 +170,7 @@ fun EditField( isActive = channelScreenModel.canPost(), modifier = EditFieldTrailingIconModifier, ) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { channelScreenModel.sendPostSync() onSendNewMessage() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt index 433a9aaf2..2b8e18167 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/ChannelNewMessageViewModel.kt @@ -107,7 +107,7 @@ open class ChannelNewMessageViewModel : draftTag.versions.collectLatest { // don't save the first if (it > 0) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { sendDraftSync() } } @@ -263,7 +263,7 @@ open class ChannelNewMessageViewModel : } fun sendPost(onDone: suspend () -> Unit) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { sendPostSync() onDone() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/EditFieldRow.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/EditFieldRow.kt index 0b6085faa..6cc1c9370 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/EditFieldRow.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/chats/publicChannels/send/EditFieldRow.kt @@ -62,7 +62,7 @@ fun EditFieldRow( nav: INav, ) { BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { channelScreenModel.sendDraftSync() channelScreenModel.cancel() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt index 4f5a33799..c8deefa59 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductScreen.kt @@ -139,7 +139,7 @@ fun NewProductScreen( WatchAndLoadMyEmojiList(accountViewModel) BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -154,7 +154,7 @@ fun NewProductScreen( onCancel = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt index 6b7d21dd1..094886da4 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/discover/nip99Classifieds/NewProductViewModel.kt @@ -112,7 +112,7 @@ open class NewProductViewModel : draftTag.versions.collectLatest { // don't save the first if (it > 0) { - accountViewModel?.runIOCatching { + accountViewModel?.launchSigner { sendDraftSync() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt index bf5ebb91f..581d6825d 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostScreen.kt @@ -167,7 +167,7 @@ private fun NewPostScreenInner( WatchAndLoadMyEmojiList(accountViewModel) BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -181,7 +181,7 @@ private fun NewPostScreenInner( onPost = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendPostSync() nav.popBack() } @@ -189,7 +189,7 @@ private fun NewPostScreenInner( onCancel = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt index 28bafef82..0820ab5f6 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/home/ShortNotePostViewModel.kt @@ -146,7 +146,7 @@ open class ShortNotePostViewModel : draftTag.versions.collectLatest { // don't save the first if (it > 0) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { sendDraftSync() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListScreen.kt index 3397c139e..b330b0d51 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/display/PeopleListScreen.kt @@ -237,7 +237,7 @@ private fun ListViewAndEditColumn( pagerState = pagerState, modifier = Modifier.weight(1f), onDeleteUser = { user, isPrivate -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { viewModel.removeUserFromSet(user, isPrivate) } }, @@ -303,7 +303,7 @@ private fun RenderAddUserFieldAndSuggestions( viewModel.hasUserFlow(user, pagerState.currentPage == 1) }, onSelect = { user -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { viewModel.addUserToSet(user, pagerState.currentPage == 1) } userName = @@ -312,7 +312,7 @@ private fun RenderAddUserFieldAndSuggestions( ) }, onDelete = { user -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { viewModel.removeUserFromSet(user, pagerState.currentPage == 1) } userName = @@ -563,14 +563,14 @@ fun ListActionsMenuButton( ) { ListActionsMenuButton( onBroadcastList = { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { viewModel.loadNote()?.let { updatedSetNote -> accountViewModel.broadcast(updatedSetNote) } } }, onDeleteList = { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { viewModel.deleteFollowSet() } nav.popBack() diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt index 627ea4534..bb13ab681 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/list/ListOfPeopleListsScreen.kt @@ -52,7 +52,7 @@ fun ListOfPeopleListsScreen( ListOfPeopleListsScreen( listFlow = accountViewModel.account.peopleLists.uiListFlow, addItem = { title: String, description: String? -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.addFollowList( listName = title, listDescription = description, @@ -64,7 +64,7 @@ fun ListOfPeopleListsScreen( nav.nav(Route.PeopleListView(it)) }, renameItem = { followSet, newValue -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.renameFollowList( newName = newValue, peopleList = followSet, @@ -73,7 +73,7 @@ fun ListOfPeopleListsScreen( } }, changeItemDescription = { followSet, newDescription -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.modifyFollowSetDescription( newDescription = newDescription, peopleList = followSet, @@ -82,7 +82,7 @@ fun ListOfPeopleListsScreen( } }, cloneItem = { followSet, customName, customDescription -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.cloneFollowSet( currentPeopleList = followSet, customCloneName = customName, @@ -92,7 +92,7 @@ fun ListOfPeopleListsScreen( } }, deleteItem = { followSet -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.deleteFollowSet( identifierTag = followSet.identifierTag, account = accountViewModel.account, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserScreen.kt index 935f3f1e1..d86ea40f5 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserScreen.kt @@ -135,7 +135,7 @@ private fun PeopleListAndUserFab(accountViewModel: AccountViewModel) { isOpen = false }, onCreateList = { name, description -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.addFollowList( listName = name, listDescription = description, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserView.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserView.kt index 09ff56919..b07704762 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserView.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/lists/memberEdit/PeopleListAndUserView.kt @@ -75,7 +75,7 @@ fun PeopleListAndUserView( userIsPrivateMember = list.privateMembers.contains(userToAddOrRemove), userIsPublicMember = list.publicMembers.contains(userToAddOrRemove), onRemoveUser = { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.removeUserFromSet( userToAddOrRemove, isPrivate = list.privateMembers.contains(userToAddOrRemove), @@ -87,7 +87,7 @@ fun PeopleListAndUserView( privateMemberSize = list.privateMembers.size, publicMemberSize = list.publicMembers.size, onAddUserToList = { userShouldBePrivate -> - accountViewModel.runIOCatching { + accountViewModel.launchSigner { accountViewModel.account.peopleLists.addUserToSet( userToAddOrRemove, list.identifierTag, diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt index 728ea9a9f..1643a6798 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageScreen.kt @@ -129,7 +129,7 @@ fun NewPublicMessageScreen( WatchAndLoadMyEmojiList(accountViewModel) BackHandler { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -144,7 +144,7 @@ fun NewPublicMessageScreen( onCancel = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendDraftSync() postViewModel.cancel() } @@ -153,7 +153,7 @@ fun NewPublicMessageScreen( onPost = { // uses the accountViewModel scope to avoid cancelling this // function when the postViewModel is released - accountViewModel.runIOCatching { + accountViewModel.launchSigner { postViewModel.sendPostSync() nav.popBack() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt index df9a033cc..19ba54057 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/notifications/publicMessages/NewPublicMessageViewModel.kt @@ -126,7 +126,7 @@ class NewPublicMessageViewModel : draftTag.versions.collectLatest { // don't save the first if (it > 0) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { sendDraftSync() } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoModel.kt index a24e7f683..fa660b662 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/common/BasicRelaySetupInfoModel.kt @@ -58,7 +58,7 @@ abstract class BasicRelaySetupInfoModel : ViewModel() { fun create() { if (hasModified) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { saveRelayList(_relays.value.map { it.relay }) clear() } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip65/Nip65RelayListViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip65/Nip65RelayListViewModel.kt index 8999830e2..1d2f34960 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip65/Nip65RelayListViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/relays/nip65/Nip65RelayListViewModel.kt @@ -62,7 +62,7 @@ class Nip65RelayListViewModel : ViewModel() { fun create() { if (hasModified) { - accountViewModel.runIOCatching { + accountViewModel.launchSigner { val writes = _homeRelays.value.map { it.relay }.toSet() val reads = _notificationRelays.value.map { it.relay }.toSet()