Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle unsupported transaction #631

Merged
merged 5 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/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 type of transaction is not supported. Please update the app to the latest version."
bludnic marked this conversation as resolved.
Show resolved Hide resolved
},
"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": "Данный тип транзакции не поддерживается. Пожалуйста, обновите приложение до последней версии."
bludnic marked this conversation as resolved.
Show resolved Hide resolved
},
"common": {
"cancel": "Отменить",
Expand Down
Loading