Fixes image uploading crash
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
<a id="v1.07.5"></a>
|
||||||
|
# [Release v1.07.5: Image upload fix](https://github.com/vitorpamplona/amethyst/releases/tag/v1.07.5) - 2026-03-31
|
||||||
|
|
||||||
|
- Fixes Image uploads crashing the app
|
||||||
|
|
||||||
<a id="v1.07.4"></a>
|
<a id="v1.07.4"></a>
|
||||||
# [Release v1.07.4: NWC fix](https://github.com/vitorpamplona/amethyst/releases/tag/v1.07.4) - 2026-03-31
|
# [Release v1.07.4: NWC fix](https://github.com/vitorpamplona/amethyst/releases/tag/v1.07.4) - 2026-03-31
|
||||||
|
|
||||||
|
|||||||
@@ -205,7 +205,8 @@ open class EditPostViewModel : ViewModel() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach { state ->
|
val urls =
|
||||||
|
results.successful.mapNotNull { state ->
|
||||||
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
||||||
val nip95 =
|
val nip95 =
|
||||||
myAccount.createNip95(
|
myAccount.createNip95(
|
||||||
@@ -218,10 +219,8 @@ open class EditPostViewModel : ViewModel() {
|
|||||||
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
||||||
|
|
||||||
note?.let {
|
note?.let {
|
||||||
message = message.insertUrlAtCursor("nostr:" + it.toNEvent())
|
"nostr:" + it.toNEvent()
|
||||||
}
|
}
|
||||||
|
|
||||||
urlPreview = findUrlInMessage()
|
|
||||||
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
val iMeta =
|
val iMeta =
|
||||||
IMetaTagBuilder(state.result.url)
|
IMetaTagBuilder(state.result.url)
|
||||||
@@ -242,10 +241,14 @@ open class EditPostViewModel : ViewModel() {
|
|||||||
|
|
||||||
iMetaAttachments = iMetaAttachments.filter { it.url != iMeta.url } + iMeta
|
iMetaAttachments = iMetaAttachments.filter { it.url != iMeta.url } + iMeta
|
||||||
|
|
||||||
message = message.insertUrlAtCursor(state.result.url)
|
state.result.url
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
urlPreview = findUrlInMessage()
|
urlPreview = findUrlInMessage()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this@EditPostViewModel.multiOrchestrator = null
|
this@EditPostViewModel.multiOrchestrator = null
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-6
@@ -521,15 +521,15 @@ open class CommentPostViewModel :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach { state ->
|
val urls =
|
||||||
|
results.successful.mapNotNull { state ->
|
||||||
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
||||||
val nip95 = account.createNip95(state.result.bytes, headerInfo = state.result.fileHeader, alt, contentWarningReason)
|
val nip95 = account.createNip95(state.result.bytes, headerInfo = state.result.fileHeader, alt, contentWarningReason)
|
||||||
nip95attachments = nip95attachments + nip95
|
nip95attachments = nip95attachments + nip95
|
||||||
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
||||||
|
|
||||||
note?.let {
|
note?.let {
|
||||||
message.insertUrlAtCursor("nostr:" + it.toNEvent())
|
"nostr:" + it.toNEvent()
|
||||||
urlPreviews.update(message.text.toString())
|
|
||||||
}
|
}
|
||||||
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
val iMeta =
|
val iMeta =
|
||||||
@@ -552,10 +552,14 @@ open class CommentPostViewModel :
|
|||||||
|
|
||||||
iMetaAttachments.replace(iMeta.url, iMeta)
|
iMetaAttachments.replace(iMeta.url, iMeta)
|
||||||
|
|
||||||
message.insertUrlAtCursor(state.result.url)
|
state.result.url
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
urlPreviews.update(message.text.toString())
|
urlPreviews.update(message.text.toString())
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-9
@@ -360,24 +360,25 @@ open class ChannelNewMessageViewModel :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach { upload ->
|
val urls =
|
||||||
|
results.successful.mapNotNull { upload ->
|
||||||
if (upload.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
if (upload.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
||||||
val nip95 = account.createNip95(upload.result.bytes, headerInfo = upload.result.fileHeader, uploadState.caption, uploadState.contentWarningReason)
|
val nip95 = account.createNip95(upload.result.bytes, headerInfo = upload.result.fileHeader, uploadState.caption, uploadState.contentWarningReason)
|
||||||
nip95attachments = nip95attachments + nip95
|
nip95attachments = nip95attachments + nip95
|
||||||
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
||||||
|
|
||||||
note?.let {
|
note?.toNostrUri()
|
||||||
message.insertUrlAtCursor(it.toNostrUri())
|
|
||||||
}
|
|
||||||
|
|
||||||
urlPreview = findUrlInMessage()
|
|
||||||
} else if (upload.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
} else if (upload.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
iMetaAttachments.add(upload.result, uploadState.caption, uploadState.contentWarningReason)
|
iMetaAttachments.add(upload.result, uploadState.caption, uploadState.contentWarningReason)
|
||||||
|
|
||||||
message.insertUrlAtCursor(upload.result.url)
|
upload.result.url
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
urlPreview = findUrlInMessage()
|
urlPreview = findUrlInMessage()
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uploadState.reset()
|
uploadState.reset()
|
||||||
onceUploaded()
|
onceUploaded()
|
||||||
|
|||||||
+7
-2
@@ -519,7 +519,8 @@ class LongFormPostViewModel :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach { state ->
|
val urls =
|
||||||
|
results.successful.mapNotNull { state ->
|
||||||
if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
val iMeta =
|
val iMeta =
|
||||||
IMetaTagBuilder(state.result.url)
|
IMetaTagBuilder(state.result.url)
|
||||||
@@ -541,10 +542,14 @@ class LongFormPostViewModel :
|
|||||||
iMetaAttachments.replace(iMeta.url, iMeta)
|
iMetaAttachments.replace(iMeta.url, iMeta)
|
||||||
|
|
||||||
val markdownImage = ""
|
val markdownImage = ""
|
||||||
message.insertUrlAtCursor(markdownImage)
|
markdownImage
|
||||||
|
} else {
|
||||||
|
null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
|
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
} else {
|
} else {
|
||||||
val errorMessages = results.errors.map { stringRes(context, it.errorResource, *it.params) }.distinct()
|
val errorMessages = results.errors.map { stringRes(context, it.errorResource, *it.params) }.distinct()
|
||||||
|
|||||||
+10
-5
@@ -421,7 +421,8 @@ open class NewProductViewModel :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach {
|
val urls =
|
||||||
|
results.successful.mapNotNull {
|
||||||
if (it.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
if (it.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
if (it.result.fileHeader.mimeType
|
if (it.result.fileHeader.mimeType
|
||||||
?.startsWith("image") == true
|
?.startsWith("image") == true
|
||||||
@@ -440,11 +441,15 @@ open class NewProductViewModel :
|
|||||||
} else {
|
} else {
|
||||||
iMetaDescription.add(it.result, alt, contentWarningReason)
|
iMetaDescription.add(it.result, alt, contentWarningReason)
|
||||||
|
|
||||||
message.insertUrlAtCursor(it.result.url)
|
it.result.url
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
urlPreviews.update(message.text.toString())
|
urlPreviews.update(message.text.toString())
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-6
@@ -996,15 +996,15 @@ open class ShortNotePostViewModel :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach { state ->
|
val urls =
|
||||||
|
results.successful.mapNotNull { state ->
|
||||||
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
||||||
val nip95 = account.createNip95(state.result.bytes, headerInfo = state.result.fileHeader, alt, contentWarningReason)
|
val nip95 = account.createNip95(state.result.bytes, headerInfo = state.result.fileHeader, alt, contentWarningReason)
|
||||||
nip95attachments = nip95attachments + nip95
|
nip95attachments = nip95attachments + nip95
|
||||||
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
||||||
|
|
||||||
note?.let {
|
note?.let {
|
||||||
message.insertUrlAtCursor("nostr:" + it.toNEvent())
|
"nostr:" + it.toNEvent()
|
||||||
urlPreviews.update(message.text.toString())
|
|
||||||
}
|
}
|
||||||
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
val iMeta =
|
val iMeta =
|
||||||
@@ -1027,10 +1027,14 @@ open class ShortNotePostViewModel :
|
|||||||
|
|
||||||
iMetaAttachments.replace(iMeta.url, iMeta)
|
iMetaAttachments.replace(iMeta.url, iMeta)
|
||||||
|
|
||||||
message.insertUrlAtCursor(state.result.url)
|
state.result.url
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
urlPreviews.update(message.text.toString())
|
urlPreviews.update(message.text.toString())
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+10
-6
@@ -464,15 +464,15 @@ class NewPublicMessageViewModel :
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (results.allGood) {
|
if (results.allGood) {
|
||||||
results.successful.forEach { state ->
|
val urls =
|
||||||
|
results.successful.mapNotNull { state ->
|
||||||
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
if (state.result is UploadOrchestrator.OrchestratorResult.NIP95Result) {
|
||||||
val nip95 = account.createNip95(state.result.bytes, headerInfo = state.result.fileHeader, alt, contentWarningReason)
|
val nip95 = account.createNip95(state.result.bytes, headerInfo = state.result.fileHeader, alt, contentWarningReason)
|
||||||
nip95attachments = nip95attachments + nip95
|
nip95attachments = nip95attachments + nip95
|
||||||
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
val note = nip95.let { it1 -> account.consumeNip95(it1.first, it1.second) }
|
||||||
|
|
||||||
note?.let {
|
note?.let {
|
||||||
message.insertUrlAtCursor("nostr:" + it.toNEvent())
|
"nostr:" + it.toNEvent()
|
||||||
urlPreviews.update(message.text.toString())
|
|
||||||
}
|
}
|
||||||
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
} else if (state.result is UploadOrchestrator.OrchestratorResult.ServerResult) {
|
||||||
val iMeta =
|
val iMeta =
|
||||||
@@ -495,10 +495,14 @@ class NewPublicMessageViewModel :
|
|||||||
|
|
||||||
iMetaAttachments.replace(iMeta.url, iMeta)
|
iMetaAttachments.replace(iMeta.url, iMeta)
|
||||||
|
|
||||||
message.insertUrlAtCursor(state.result.url)
|
state.result.url
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
message.insertUrlAtCursor(urls.joinToString(" "))
|
||||||
urlPreviews.update(message.text.toString())
|
urlPreviews.update(message.text.toString())
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
multiOrchestrator = null
|
multiOrchestrator = null
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user