diff --git a/src/components/pages/Messages.jsx b/src/components/pages/Messages.jsx index cee1aac7..046f5079 100644 --- a/src/components/pages/Messages.jsx +++ b/src/components/pages/Messages.jsx @@ -500,7 +500,7 @@ class Messages extends React.Component { onPanelDeleteClick = (event) => { const { messages } = this.state; - const { account, accounts, } = this.props; + const { account, accounts, the_group } = this.props; const to = this.getToAcc() // TODO: works wrong if few messages have same create_time @@ -533,6 +533,14 @@ class Messages extends React.Component { if (!this.state.selectedMessages[message_object.nonce]) { continue; } + + const extensions = [] + if (this.isGroup()) { + extensions.push([0, { + group: the_group.name + }]) + } + const json = JSON.stringify(['private_delete_message', { requester: account.name, from: message_object.from, @@ -540,6 +548,7 @@ class Messages extends React.Component { start_date: '1970-01-01T00:00:00', stop_date: '1970-01-01T00:00:00', nonce: message_object.nonce, + extensions, }]); OPERATIONS.push(['custom_json', { @@ -550,7 +559,9 @@ class Messages extends React.Component { ]); } - this.props.sendOperations(account, accounts[to], OPERATIONS); + this.props.sendOperations(account, accounts[to], OPERATIONS, (err, errStr) => { + this.props.showError(errStr, 10000) + }) this.setState({ selectedMessages: {}, @@ -1078,15 +1089,16 @@ export default withRouter(connect( fake: true }}); }, - sendOperations: (senderAcc, toAcc, OPERATIONS) => { + sendOperations: (senderAcc, toAcc, OPERATIONS, onError = null) => { if (!OPERATIONS.length) return; dispatch( transaction.actions.broadcastOperation({ type: 'custom_json', trx: OPERATIONS, successCallback: null, - errorCallback: (e) => { - console.log(e); + errorCallback: (e, errStr) => { + if (onError) onError(e, errStr) + console.error(e) } }) ); @@ -1125,14 +1137,14 @@ export default withRouter(connect( const opData = { from: senderAcc.name, to: toAcc ? toAcc.name : '', - nonce: /*editInfo ? editInfo.nonce : */data.nonce, + nonce: editInfo ? editInfo.nonce : data.nonce, from_memo_key: data.from_memo_key, to_memo_key: data.to_memo_key, checksum: data.checksum, update: editInfo ? true : false, encrypted_message: data.encrypted_message, } - alert(JSON.stringify(data.encrypted_message)) + //alert(JSON.stringify(data.encrypted_message)) if (group) { opData.extensions = [[0, { @@ -1158,7 +1170,7 @@ export default withRouter(connect( json, }, successCallback: null, - errorCallback: (err) => { + errorCallback: (err, errStr) => { if (err && err.message) { if (err.message.includes('blocked by')) { this.showError(tt( @@ -1178,6 +1190,7 @@ export default withRouter(connect( } } console.error(err) + this.showError(errStr, 10000) }, })); }, diff --git a/src/locales/ru-RU.json b/src/locales/ru-RU.json index 5db3838a..384b1269 100644 --- a/src/locales/ru-RU.json +++ b/src/locales/ru-RU.json @@ -110,7 +110,10 @@ "sync_error": "Ошибка синхронизации. Для получения новых сообщений обновляйте страницу.", "sync_error_short": "Ошибка синхронизации. Для получения новых сообщений нажимайте ", "blocked_BY": "Вы заблокированы пользователем @%(BY)s.", - "do_not_bother_BY": "@%(BY)s просит пользователей с низкой репутацией не беспокоить." + "do_not_bother_BY": "@%(BY)s просит пользователей с низкой репутацией не беспокоить.", + "too_low_gp": "Не хватает Силы Голоса. Для участия в группах нужно не менее ", + "too_low_gp2": ".", + "you_not_moder": "Вы не модератор." }, "msgs_group_dropdown": { "join": "Вступить", @@ -374,6 +377,7 @@ "login": "Войти", "logout": "Выйти", "mentions": "Упоминания", + "modified": " (изменено)", "name": "Имя", "night_mode": "Ночной режим", "ok": "OK", diff --git a/src/redux/TransactionSaga.js b/src/redux/TransactionSaga.js index 534e3850..e6e85f3d 100644 --- a/src/redux/TransactionSaga.js +++ b/src/redux/TransactionSaga.js @@ -44,10 +44,21 @@ function* preBroadcast_custom_json({operation}) { updater: msgs => { const idx = msgs.findIndex(i => i.get('nonce') === json[1].nonce); if (idx === -1) { + let group = '' + const exts = json[1].extensions || [] + for (const [key, val ] of exts) { + if (key === 0) { + group = val.group + break + } + } msgs = msgs.insert(0, fromJS({ nonce: json[1].nonce, checksum: json[1].checksum, from: json[1].from, + from_memo_key: json[1].from_memo_key, + to_memo_key: json[1].to_memo_key, + group, read_date: '1970-01-01T00:00:00', create_date: new Date().toISOString().split('.')[0], receive_date: '1970-01-01T00:00:00', diff --git a/src/redux/UserSaga.js b/src/redux/UserSaga.js index 5f211017..3b57ef34 100644 --- a/src/redux/UserSaga.js +++ b/src/redux/UserSaga.js @@ -244,9 +244,7 @@ function* getAccountHandler({ payload: { usernames, resolve, reject }}) { usernames = [current.get('username')] } -alert('ac') const accounts = yield call([api, api.getAccountsAsync], usernames) -alert('ac2') for (let account of accounts) { yield put(g.actions.receiveAccount({ account })) } diff --git a/src/utils/Normalizators.js b/src/utils/Normalizators.js index 560fb088..8eeef7aa 100644 --- a/src/utils/Normalizators.js +++ b/src/utils/Normalizators.js @@ -164,7 +164,7 @@ export async function normalizeMessages(messages, accounts, currentUser, to, pre saveToCache(preDecoded, msg) }, on_error: (msg, i, err) => { - console.error(err) + console.error(err, msg) msg.message = {body: tt_invalid_message, invalid: true} }, begin_idx: messagesCopy.length - 1, diff --git a/src/utils/translateError.js b/src/utils/translateError.js index ddd0c428..92c78d42 100644 --- a/src/utils/translateError.js +++ b/src/utils/translateError.js @@ -6,9 +6,10 @@ const getErrorData = (errPayload, errName, depth = 0) => { if (depth > 50) { throw new Error('getErrorData - infinity loop detected...') } - if (errPayload === null) { + if (!errPayload) { return null } + console.error(errPayload.name) if (errPayload.name === errName) { let { stack } = errPayload stack = stack && stack[0] @@ -69,6 +70,7 @@ export function translateError(string, errPayload) { 'Account exceeded maximum allowed bandwidth per vesting share' )) { string = tt('chain_errors.exceeded_maximum_allowed_bandwidth') + return string } if (string.includes( @@ -91,11 +93,34 @@ export function translateError(string, errPayload) { } else { string += '.' } + return string } } catch (err) { console.error('getErrorData', err) } } + if (string.includes( + 'Too low golos power' + )) { + let errData + try { + errData = getErrorData(errPayload, 'logic_exception') + if (errData && errData.r) { + string = tt('messages.too_low_gp') + string += Asset(errData.r).floatString + string += tt('messages.too_low_gp2') + return string + } + } catch (err) { + console.error('getErrorData', err) + } + } + + if (string.includes('You should be moder')) { + string = tt('messages.you_not_moder') + return string + } + return string }