mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2025-09-28 22:03:01 +02:00
Corrects a bug of not showing the user's own messages on chat
This commit is contained in:
@@ -1424,8 +1424,6 @@ class Account(
|
||||
template: EventTemplate<ChatMessageEvent>,
|
||||
draftTag: String? = null,
|
||||
) {
|
||||
if (!isWriteable()) return
|
||||
|
||||
if (draftTag != null) {
|
||||
if (template.content.isEmpty()) {
|
||||
deleteDraft(draftTag)
|
||||
|
@@ -42,8 +42,6 @@ class Chatroom {
|
||||
|
||||
@Synchronized
|
||||
fun addMessageSync(msg: Note) {
|
||||
checkNotInMainThread()
|
||||
|
||||
if (msg !in roomMessages) {
|
||||
roomMessages = roomMessages + msg
|
||||
|
||||
|
@@ -53,8 +53,9 @@ abstract class FeedViewModel(
|
||||
init {
|
||||
Log.d("Init", "Starting new Model: ${this.javaClass.simpleName}")
|
||||
collectorJob =
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
viewModelScope.launch(Dispatchers.Default) {
|
||||
LocalCache.live.newEventBundles.collect { newNotes ->
|
||||
Log.d("Rendering Metrics", "Update feeds: ${this@FeedViewModel.javaClass.simpleName} with ${newNotes.size}")
|
||||
feedState.updateFeedWith(newNotes)
|
||||
}
|
||||
}
|
||||
|
@@ -765,6 +765,23 @@ class AccountViewModel(
|
||||
R.string.unauthorized_exception,
|
||||
R.string.unauthorized_exception_description,
|
||||
)
|
||||
} catch (e: SignerExceptions.SignerNotFoundException) {
|
||||
toastManager.toast(
|
||||
R.string.signer_not_found_exception,
|
||||
R.string.signer_not_found_exception_description,
|
||||
)
|
||||
} catch (e: SignerExceptions.TimedOutException) {
|
||||
Log.w("AccountViewModel", "TimedOutException", e)
|
||||
} catch (e: SignerExceptions.NothingToDecrypt) {
|
||||
Log.w("AccountViewModel", "NothingToDecrypt", e)
|
||||
} catch (e: SignerExceptions.CouldNotPerformException) {
|
||||
Log.w("AccountViewModel", "CouldNotPerformException", e)
|
||||
} catch (e: SignerExceptions.ManuallyUnauthorizedException) {
|
||||
Log.w("AccountViewModel", "ManuallyUnauthorizedException", e)
|
||||
} catch (e: SignerExceptions.AutomaticallyUnauthorizedException) {
|
||||
Log.w("AccountViewModel", "AutomaticallyUnauthorizedException", e)
|
||||
} catch (e: SignerExceptions.RunningOnBackgroundWithoutAutomaticPermissionException) {
|
||||
Log.w("AccountViewModel", "TimedOutRunningOnBackgroundWithoutAutomaticPermissionExceptionException", e)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -56,8 +56,6 @@ import com.vitorpamplona.amethyst.ui.theme.placeholderText
|
||||
import com.vitorpamplona.quartz.nip17Dm.base.ChatroomKey
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.ChatMessageEvent
|
||||
import com.vitorpamplona.quartz.nip17Dm.messages.changeSubject
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
@Composable
|
||||
fun NewChatroomSubjectDialog(
|
||||
@@ -100,7 +98,7 @@ fun NewChatroomSubjectDialog(
|
||||
|
||||
PostButton(
|
||||
onPost = {
|
||||
scope.launch(Dispatchers.IO) {
|
||||
accountViewModel.runIOCatching {
|
||||
val template =
|
||||
ChatMessageEvent.build(
|
||||
message.value,
|
||||
|
@@ -345,13 +345,6 @@ class ChatNewMessageViewModel :
|
||||
nip17 = draftEvent is NIP17Group
|
||||
}
|
||||
|
||||
fun sendPost(onDone: () -> Unit) {
|
||||
viewModelScope.launch(Dispatchers.IO) {
|
||||
sendPostSync()
|
||||
onDone()
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun sendPostSync() {
|
||||
innerSendPost(null)
|
||||
accountViewModel.deleteDraft(draftTag.current)
|
||||
|
@@ -70,7 +70,6 @@ import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.compose.collectAsStateWithLifecycle
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import androidx.lifecycle.viewmodel.compose.viewModel
|
||||
import com.vitorpamplona.amethyst.Amethyst
|
||||
import com.vitorpamplona.amethyst.R
|
||||
@@ -174,7 +173,7 @@ fun NewGroupDMScreen(
|
||||
onCancel = {
|
||||
// uses the accountViewModel scope to avoid cancelling this
|
||||
// function when the postViewModel is released
|
||||
accountViewModel.viewModelScope.launch(Dispatchers.IO) {
|
||||
accountViewModel.runIOCatching {
|
||||
postViewModel.sendDraftSync()
|
||||
delay(100)
|
||||
nav.popBack()
|
||||
@@ -184,7 +183,7 @@ fun NewGroupDMScreen(
|
||||
onPost = {
|
||||
// uses the accountViewModel scope to avoid cancelling this
|
||||
// function when the postViewModel is released
|
||||
accountViewModel.viewModelScope.launch(Dispatchers.IO) {
|
||||
accountViewModel.runIOCatching {
|
||||
postViewModel.sendPostSync()
|
||||
postViewModel.room?.let {
|
||||
nav.nav(routeToMessage(it, null, null, null, accountViewModel))
|
||||
|
@@ -145,7 +145,10 @@ fun EditField(
|
||||
isActive = channelScreenModel.canPost(),
|
||||
modifier = EditFieldTrailingIconModifier,
|
||||
) {
|
||||
channelScreenModel.sendPost(onSendNewMessage)
|
||||
accountViewModel.runIOCatching {
|
||||
channelScreenModel.sendPostSync()
|
||||
onSendNewMessage()
|
||||
}
|
||||
}
|
||||
},
|
||||
leadingIcon = {
|
||||
|
@@ -63,6 +63,9 @@
|
||||
<string name="unauthorized_exception">Unauthorized Decryption</string>
|
||||
<string name="unauthorized_exception_description">The signer did not authorize a decryption that is required to make this operation. Activate NIP-44 decryptions in your signer app and try again</string>
|
||||
|
||||
<string name="signer_not_found_exception">Signer not found</string>
|
||||
<string name="signer_not_found_exception_description">Was the Signer app uninstalled? Check if the signer is installed and has this account. Log off and Log in again of the signer app has changed.</string>
|
||||
|
||||
|
||||
<string name="zaps">Zaps</string>
|
||||
<string name="view_count">View count</string>
|
||||
|
@@ -69,7 +69,7 @@ open class BaseDMGroupEvent(
|
||||
return result
|
||||
}
|
||||
|
||||
override fun isIncluded(pubKey: HexKey) = tags.any(PTag::isTagged, pubKey)
|
||||
override fun isIncluded(pubKey: HexKey) = pubKey == this.pubKey || tags.any(PTag::isTagged, pubKey)
|
||||
|
||||
override fun groupMembers() = recipientsPubKey().plus(pubKey).toSet()
|
||||
|
||||
|
Reference in New Issue
Block a user