Skip to content

Commit

Permalink
no connection error when sending messages while offline
Browse files Browse the repository at this point in the history
  • Loading branch information
zyuhel committed Dec 14, 2017
1 parent 9179a82 commit 2488834
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/components/Chat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export default {
if (this.message) {
var message = this.message
var partner = this.$route.params.partner
this.encodeMessageForAddress(message, partner)
this.encodeMessageForAddress(message, partner, this)
this.message = ''
this.$refs.messageField.$el.value = ''
}
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
'no_money': 'Not enough funds. Top up your balance.',
'no_empty': 'Message can\'t be empty',
'no_address': 'Please specify recipient address',
'no_connection': 'Connection problems',
'too_long': 'Message is too long',
'incorrect_address': 'Incorrect recipient address',
'title': 'Chats',
Expand Down
1 change: 1 addition & 0 deletions src/i18n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
'no_money': 'Недостаточно токенов. Пополните баланс.',
'no_empty': 'Сообщение не может быть пустым',
'no_address': 'Укажите адрес получателя сообщения',
'no_connection': 'Проблема с соединением',
'too_long': 'Сообщение слишком длинное',
'incorrect_address': 'Адрес получателя неверный',
'title': 'Диалоги',
Expand Down
8 changes: 5 additions & 3 deletions src/lib/adamantServerApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ function install (Vue) {
}
Vue.prototype.getAddressPublicKey = function (recipientAddress) {
if (window.pk_cache[recipientAddress]) {
// return Promise.resolve(window.pk_cache[recipientAddress])
return window.pk_cache[recipientAddress]
}
return this.$http.get(this.getAddressString() + '/api/accounts/getPublicKey?address=' + recipientAddress).then(response => {
Expand All @@ -179,8 +178,7 @@ function install (Vue) {
// error callback
})
}
Vue.prototype.encodeMessageForAddress = function (msg, recipientAddress) {
// recipientAddress = 'U14345892393468009728'
Vue.prototype.encodeMessageForAddress = function (msg, recipientAddress, caller) {
this.$http.get(this.getAddressString() + '/api/accounts/getPublicKey?address=' + recipientAddress).then(response => {
if (response.body.success) {
var msgObject = this.encodeMessage(msg, response.body.publicKey)
Expand All @@ -189,6 +187,10 @@ function install (Vue) {
this.sendMessage(msgObject, recipientAddress)
}
}, response => {
if (caller) {
caller.message = msg
caller.errorMessage('no_connection')
}
// error callback
})
}
Expand Down

0 comments on commit 2488834

Please sign in to comment.