This commit is contained in:
mgabdev
2020-04-17 01:35:46 -04:00
parent 35852e7fee
commit 4d7aee59c9
37 changed files with 568 additions and 319 deletions

View File

@@ -100,12 +100,11 @@ function getFromDB(dispatch, getState, index, id) {
export function fetchAccount(id) {
return (dispatch, getState) => {
dispatch(fetchRelationships([id]));
if (id === -1 || getState().getIn(['accounts', id], null) !== null) {
return;
}
dispatch(fetchRelationships([id]));
dispatch(fetchAccountRequest(id));
openDB().then(db => getFromDB(
@@ -128,8 +127,13 @@ export function fetchAccount(id) {
export function fetchAccountByUsername(username) {
return (dispatch, getState) => {
if (!username) {
return;
}
api(getState).get(`/api/v1/account_by_username/${username}`).then(response => {
dispatch(importFetchedAccount(response.data));
dispatch(importFetchedAccount(response.data))
dispatch(fetchRelationships([response.data.id]))
}).then(() => {
dispatch(fetchAccountSuccess());
}).catch(error => {