mirror of
https://github.com/status-im/safe-react.git
synced 2025-01-09 09:42:07 +00:00
keep safes with no name for the list of safes (#2387)
* keep safes with no name for the list of safes * prevent storing only those safes whose `loadedViaUrl` flag is true * update AB before Safe store * default safe name to empty string if it is not available
This commit is contained in:
parent
e66040d32f
commit
50a7a49d1b
@ -4,7 +4,7 @@ import { saveDefaultSafe, saveSafes } from 'src/logic/safe/utils'
|
||||
import { REMOVE_SAFE } from 'src/logic/safe/store/actions/removeSafe'
|
||||
import { SET_DEFAULT_SAFE } from 'src/logic/safe/store/actions/setDefaultSafe'
|
||||
import { UPDATE_SAFE } from 'src/logic/safe/store/actions/updateSafe'
|
||||
import { safesListWithAddressBookNameSelector, safesMapSelector } from 'src/logic/safe/store/selectors'
|
||||
import { safesMapSelector } from 'src/logic/safe/store/selectors'
|
||||
import { SafeRecord } from '../models/safe'
|
||||
|
||||
const watchedActions = [REMOVE_SAFE, SET_DEFAULT_SAFE, UPDATE_SAFE]
|
||||
@ -24,12 +24,7 @@ export const safeStorageMiddleware = (store: Store) => (
|
||||
if (watchedActions.includes(action.type)) {
|
||||
const state = store.getState()
|
||||
const safes = safesMapSelector(state)
|
||||
const safeNameMap = Object.fromEntries(
|
||||
safesListWithAddressBookNameSelector(state)
|
||||
.map((safe) => [safe.address, safe.name])
|
||||
.toJSON(),
|
||||
)
|
||||
await saveSafes(safes.filter((safe) => safeNameMap[safe.address]).toJSON())
|
||||
await saveSafes(safes.filter((safe) => !safe.loadedViaUrl).toJSON())
|
||||
|
||||
switch (action.type) {
|
||||
case SET_DEFAULT_SAFE: {
|
||||
|
@ -35,10 +35,9 @@ export const safesListWithAddressBookNameSelector = createSelector(
|
||||
.filter((safeRecord) => !safeRecord.loadedViaUrl)
|
||||
.map((safeRecord) => {
|
||||
const safe = safeRecord.toObject()
|
||||
const name = addressBook?.[safe.address]?.name
|
||||
const name = addressBook?.[safe.address]?.name ?? ''
|
||||
return { ...safe, name }
|
||||
})
|
||||
.filter((safeRecord: SafeRecordWithName) => safeRecord.name)
|
||||
},
|
||||
)
|
||||
|
||||
|
@ -177,13 +177,13 @@ const Open = (): ReactElement => {
|
||||
ownersAddresses = getAccountsFrom(pendingCreation)
|
||||
}
|
||||
|
||||
const safeProps = await buildSafe(safeAddress)
|
||||
await dispatch(addOrUpdateSafe(safeProps))
|
||||
|
||||
const owners = ownersAddresses.map((address, index) => makeAddressBookEntry({ address, name: ownersNames[index] }))
|
||||
const safe = makeAddressBookEntry({ address: safeAddress, name })
|
||||
await dispatch(addressBookSafeLoad([...owners, safe]))
|
||||
|
||||
const safeProps = await buildSafe(safeAddress)
|
||||
await dispatch(addOrUpdateSafe(safeProps))
|
||||
|
||||
trackEvent({
|
||||
category: 'User',
|
||||
action: 'Created a safe',
|
||||
|
Loading…
x
Reference in New Issue
Block a user