Skip to content

Commit

Permalink
Merge pull request #631 from Adamant-im/fix/unsupported-transaction
Browse files Browse the repository at this point in the history
Handle unsupported transaction
  • Loading branch information
bludnic authored Jun 4, 2024
2 parents a5b6d80 + ffe26e9 commit c97eb2f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/components/AChat/QuotedMessage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ export default defineComponent({
})
const messageLabel = computed(() => {
if (transaction.value.i18n) {
return t(transaction.value.message)
}
return store.state.options.formatMessages
? formatMessage(transaction.value.message)
: transaction.value.message
Expand Down
16 changes: 14 additions & 2 deletions src/lib/chat/helpers/normalizeMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function normalizeMessage(abstract) {
} else {
transaction.type = 'message'
}
} else {
} else if (abstract.message.reply_message.type) {
// reply with a crypto transfer
transaction.asset = abstract.message
transaction.message = abstract.message.reply_message.comments || ''
Expand All @@ -70,6 +70,12 @@ export function normalizeMessage(abstract) {
transaction.type = notSupportedYetCrypto || 'UNKNOWN_CRYPTO'
transaction.status = TS.UNKNOWN
}
} else {
// Unsupported transaction type. May require updating the PWA version.
transaction.message = 'chats.unsupported_transaction_type'
transaction.i18n = true
transaction.hash = abstract.id // adm transaction id (hash)
transaction.type = 'message'
}

transaction.isReply = true
Expand All @@ -90,12 +96,18 @@ export function normalizeMessage(abstract) {
transaction.type = notSupportedYetCrypto || 'UNKNOWN_CRYPTO'
transaction.status = TS.UNKNOWN
}
} else {
} else if (typeof abstract.message === 'string') {
// ADM transaction or Message
transaction.message = abstract.message || ''
transaction.hash = abstract.id // adm transaction id (hash)

abstract.amount > 0 ? (transaction.type = 'ADM') : (transaction.type = 'message')
} else {
// Unsupported transaction type. May require updating the PWA version.
transaction.message = 'chats.unsupported_transaction_type'
transaction.i18n = true
transaction.hash = abstract.id // adm transaction id (hash)
transaction.type = 'message'
}

return transaction
Expand Down
3 changes: 2 additions & 1 deletion src/locales/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
"you_reacted": "Reacted",
"partner_reacted": "Reacted",
"you_removed_reaction": "Removed reaction",
"partner_removed_reaction": "Removed reaction"
"partner_removed_reaction": "Removed reaction",
"unsupported_transaction_type": "This transaction type is not supported. Please refresh the page or install the latest version of the app."
},
"common": {
"cancel": "Abbrechen",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"you_reacted": "Reacted",
"partner_reacted": "Reacted",
"you_removed_reaction": "Removed reaction",
"partner_removed_reaction": "Removed reaction"
"partner_removed_reaction": "Removed reaction",
"unsupported_transaction_type": "This transaction type is not supported. Please refresh the page or install the latest version of the app."
},
"common": {
"cancel": "Cancel",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"you_reacted": "Отреагировали",
"partner_reacted": "Отреагировал",
"you_removed_reaction": "Убрали реакцию",
"partner_removed_reaction": "Убрал реакцию"
"partner_removed_reaction": "Убрал реакцию",
"unsupported_transaction_type": "Данный тип транзакции не поддерживается. Пожалуйста, обновите страницу, либо установите последнюю версию приложения."
},
"common": {
"cancel": "Отменить",
Expand Down
3 changes: 2 additions & 1 deletion src/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
"you_reacted": "反应",
"partner_reacted": "已反应",
"you_removed_reaction": "已删除反应",
"partner_removed_reaction": "已删除的反应"
"partner_removed_reaction": "已删除的反应",
"unsupported_transaction_type": "This transaction type is not supported. Please refresh the page or install the latest version of the app."
},
"common": {
"cancel": "取消",
Expand Down

0 comments on commit c97eb2f

Please sign in to comment.