Skip to content

Commit

Permalink
HF 30 - Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
1aerostorm committed Sep 15, 2024
1 parent 4eaf6e9 commit 5357504
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/components/elements/common/AccountName/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions src/components/modules/groups/GroupMembers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}}
/>
</div>
</div> : null}
Expand Down Expand Up @@ -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, }))
Expand Down
5 changes: 3 additions & 2 deletions src/components/pages/Messages.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
21 changes: 12 additions & 9 deletions src/redux/FetchDataSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -87,6 +88,7 @@ export function* fetchState(location_change_action) {
owner: account, limit: 100,
cache: Object.keys(conCache),
accounts: true,
relations: false,
})
}
})
Expand Down Expand Up @@ -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) => {
Expand Down
9 changes: 6 additions & 3 deletions src/utils/Normalizators.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5357504

Please sign in to comment.