From 53575048f933fec0a6822211ee7390db97870f9a Mon Sep 17 00:00:00 2001 From: 1aerostorm Date: Sun, 15 Sep 2024 05:26:11 +0300 Subject: [PATCH] HF 30 - Fixes --- .../elements/common/AccountName/index.jsx | 6 ++++++ .../modules/groups/GroupMembers.jsx | 8 +++++++ src/components/pages/Messages.jsx | 5 +++-- src/redux/FetchDataSaga.js | 21 +++++++++++-------- src/utils/Normalizators.js | 9 +++++--- 5 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/components/elements/common/AccountName/index.jsx b/src/components/elements/common/AccountName/index.jsx index 8f0e6c70..fa9e578e 100644 --- a/src/components/elements/common/AccountName/index.jsx +++ b/src/components/elements/common/AccountName/index.jsx @@ -15,6 +15,11 @@ class AccountName extends React.Component { this.ref = React.createRef() } + onAccountsLoad = (accs) => { + const { onAccountsLoad } = this.props + onAccountsLoad(accs) + } + lookupAccounts = async (value) => { try { //await new Promise(resolve => setTimeout(resolve, 2000)) @@ -24,6 +29,7 @@ class AccountName extends React.Component { filter_accounts: [...filterAccounts], }) const accs = await api.lookupAccountNamesAsync(accNames) + this.onAccountsLoad(accs) return accs } catch (err) { console.error(err) diff --git a/src/components/modules/groups/GroupMembers.jsx b/src/components/modules/groups/GroupMembers.jsx index f2cd45e1..633b8810 100644 --- a/src/components/modules/groups/GroupMembers.jsx +++ b/src/components/modules/groups/GroupMembers.jsx @@ -199,6 +199,9 @@ class GroupMembers extends React.Component { placeholder={tt('create_group_jsx.add_member')} onChange={this.onAddAccount} filterAccounts={filterAccs} + onAccountsLoad={(accs) => { + this.props.receiveAccounts(accs) + }} /> : null} @@ -300,6 +303,11 @@ export default connect( dispatch(g.actions.fetchGroupMembers({ group: group.name, creatingNew: !!group.creatingNew, memberTypes, sortConditions, })) }, + receiveAccounts: (accs) => { + for (const acc of accs) { + dispatch(g.actions.receiveAccount({ account: acc })) + } + }, updateGroupMember: (group, member, member_type) => { dispatch(g.actions.updateGroupMember({ group, member, member_type, })) diff --git a/src/components/pages/Messages.jsx b/src/components/pages/Messages.jsx index 6985542c..554a8720 100644 --- a/src/components/pages/Messages.jsx +++ b/src/components/pages/Messages.jsx @@ -232,8 +232,9 @@ class Messages extends React.Component { const takeResult = await notificationTake(username, removeTaskIds, (type, op, timestamp, task_id) => { const isDonate = type === 'donate' const toAcc = this.getToAcc() - let updateMessage = opGroup(op) === this.state.to || (op.from === toAcc || - op.to === toAcc) + const group = opGroup(op) + let updateMessage = group === this.state.to || (!group && (op.from === toAcc || + op.to === toAcc)) const isMine = username === op.from; if (type === 'private_message') { if (op.update) { diff --git a/src/redux/FetchDataSaga.js b/src/redux/FetchDataSaga.js index 77108a8e..9e4eae00 100644 --- a/src/redux/FetchDataSaga.js +++ b/src/redux/FetchDataSaga.js @@ -37,20 +37,21 @@ const addMiniAccounts = (state, accounts) => { export function* fetchState(location_change_action) { try { - const { pathname } = location_change_action.payload.location - const { fake } = location_change_action.payload + const { fake, isFirstRendering } = location_change_action.payload const parts = pathname.split('/') const state = {} state.nodeError = null - state.contacts = []; - state.the_group = undefined - state.messages = []; - state.messages_update = '0'; - state.accounts = {} - state.assets = {} - state.groups = {} + if (isFirstRendering || fake) { + state.contacts = []; + state.the_group = undefined + state.messages = []; + state.messages_update = '0'; + state.accounts = {} + state.assets = {} + state.groups = {} + } let hasErr = false @@ -87,6 +88,7 @@ export function* fetchState(location_change_action) { owner: account, limit: 100, cache: Object.keys(conCache), accounts: true, + relations: false, }) } }) @@ -144,6 +146,7 @@ export function* fetchState(location_change_action) { contacts: { owner: account, limit: 100, cache: Object.keys(conCache), + relations: false, }, } const getThread = async (loginData) => { diff --git a/src/utils/Normalizators.js b/src/utils/Normalizators.js index 0e18875e..a3509b01 100644 --- a/src/utils/Normalizators.js +++ b/src/utils/Normalizators.js @@ -50,12 +50,14 @@ const cacheKey = (msg) => { return key } -export const saveToCache = (msg, contact = false) => { +export const saveToCache = (msg, contact = false, general = true) => { if (!msg.message) return false if (msg.group && msg.decrypt_date !== msg.receive_date) return false - const space = getSpaceInCache(msg) const key = cacheKey(msg) - space[key] = { message: msg.message } + if (general) { + const space = getSpaceInCache(msg) + space[key] = { message: msg.message } + } if (contact) { const cont = getContactsSpace(msg) cont[key] = { message: msg.message } @@ -139,6 +141,7 @@ export async function normalizeContacts(contacts, accounts, currentUser, cachedP on_error: (msg, idx, exception) => { console.error(exception) msg.message = { body: tt_invalid_message, invalid: true, }; + saveToCache(msg, true, false) }, begin_idx: 0, end_idx: messages.length,