Remove safe loadedViaUrl from storage

This commit is contained in:
Mati Dastugue 2021-03-31 19:49:09 -03:00
parent 08ec0a34b6
commit 9a845a2039
5 changed files with 16 additions and 6 deletions

View File

@ -24,6 +24,7 @@ import {
safeTotalFiatBalanceSelector,
safeNameSelector,
safeParamAddressFromStateSelector,
safeLoadedViaUrlSelector,
} from 'src/logic/safe/store/selectors'
import { currentCurrencySelector } from 'src/logic/currencyValues/store/selectors'
import Modal from 'src/components/Modal'
@ -83,8 +84,8 @@ const App: React.FC = ({ children }) => {
const currentCurrency = useSelector(currentCurrencySelector)
const granted = useSelector(grantedSelector)
const sidebarItems = useSidebarItems()
const safeLoaded = useLoadSafe(safeAddress)
const isSafeLoadedViaUrl = useSelector(safeLoadedViaUrlSelector)
const safeLoaded = useLoadSafe(safeAddress, isSafeLoadedViaUrl)
useSafeScheduledUpdates(safeLoaded, safeAddress)
const sendFunds = safeActionsState.sendFunds

View File

@ -21,8 +21,13 @@ const addressBookMiddleware = (store) => (next) => async (action) => {
const { dispatch } = store
const addressBook = addressBookSelector(state)
const safes = safesListSelector(state)
if (addressBook.length) {
await saveAddressBook(addressBook)
const filteredSafeAddresses = safes
.filter((safe) => !safe.loadedViaUrl)
.map((safe) => safe.address)
.toJS()
await saveAddressBook(addressBook.filter((entry) => filteredSafeAddresses.includes(entry.address)))
}
switch (action.type) {

View File

@ -10,7 +10,7 @@ import fetchTransactions from 'src/logic/safe/store/actions/transactions/fetchTr
import { Dispatch } from 'src/logic/safe/store/actions/types.d'
import { updateAvailableCurrencies } from 'src/logic/currencyValues/store/actions/updateAvailableCurrencies'
export const useLoadSafe = (safeAddress?: string): boolean => {
export const useLoadSafe = (safeAddress?: string, loadedViaUrl = true): boolean => {
const dispatch = useDispatch<Dispatch>()
const [isSafeLoaded, setIsSafeLoaded] = useState(false)
@ -23,9 +23,11 @@ export const useLoadSafe = (safeAddress?: string): boolean => {
await dispatch(fetchSafeTokens(safeAddress))
await dispatch(updateAvailableCurrencies())
await dispatch(fetchTransactions(safeAddress))
if (!loadedViaUrl) {
dispatch(addViewedSafe(safeAddress))
}
}
}
dispatch(loadAddressBookFromStorage())
fetchData()

View File

@ -31,7 +31,7 @@ export const safeStorageMiddleware = (store) => (next) => async (action) => {
const state = store.getState()
const { dispatch } = store
const safes = safesMapSelector(state)
await saveSafes(safes.toJSON())
await saveSafes(safes.filter((safe) => !safe.loadedViaUrl).toJSON())
switch (action.type) {
case ADD_OR_UPDATE_SAFE: {

View File

@ -104,6 +104,8 @@ export const safeFeaturesEnabledSelector = createSelector(safeSelector, safeFiel
export const safeSpendingLimitsSelector = createSelector(safeSelector, safeFieldSelector('spendingLimits'))
export const safeLoadedViaUrlSelector = createSelector(safeSelector, safeFieldSelector('loadedViaUrl'))
export const safeOwnersAddressesListSelector = createSelector(
safeOwnersSelector,
(owners): List<string> => {