Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gkasdorf committed Jul 5, 2023
1 parent fdb7bfb commit 7d6af23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
4 changes: 1 addition & 3 deletions components/ui/Feed/FeedHeaderDropdownDrawer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ import { Pressable, ScrollView, View } from "native-base";
import Animated, { FadeOutUp, FadeInUp } from "react-native-reanimated";
import { useAppDispatch, useAppSelector } from "../../../store";
import { selectFeed, setDropdownVisible } from "../../../slices/feed/feedSlice";
import {
selectAccounts,
} from "../../../slices/accounts/accountsSlice";
import { selectAccounts } from "../../../slices/accounts/accountsSlice";
import CTable from "../table/CTable";
import CSection from "../table/CSection";
import { Account } from "../../../types/Account";
Expand Down
11 changes: 5 additions & 6 deletions slices/accounts/accountsActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const addAccount = createAsyncThunk(
async (account: Account) => {
const accounts =
(JSON.parse(await AsyncStorage.getItem("@accounts")) as Account[]) ?? [];
accounts.forEach(a => delete a.isCurrent);
accounts.forEach((a) => delete a.isCurrent);
account.isCurrent = true;
accounts.push(account);
await AsyncStorage.setItem("@accounts", JSON.stringify(accounts));
Expand Down Expand Up @@ -72,14 +72,13 @@ export const setCurrentAccount = createAsyncThunk(
const accounts =
(JSON.parse(await AsyncStorage.getItem("@accounts")) as Account[]) ?? [];

accounts.forEach(a => {
accounts.forEach((a) => {
if (a.username === account.username && a.instance === account.instance)
a.isCurrent = true;
else
delete a.isCurrent;
})
else delete a.isCurrent;
});

await AsyncStorage.setItem("@accounts", JSON.stringify(accounts));
return account;
}
);
);
13 changes: 7 additions & 6 deletions slices/accounts/accountsSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
deleteAccount,
editAccount,
loadAccounts,
setCurrentAccount
setCurrentAccount,
} from "./accountsActions";
import { RootState } from "../../store";
import { Account } from "../../types/Account";
Expand All @@ -25,13 +25,13 @@ const initialState: AccountsState = {
const accountsSlice = createSlice({
name: "accounts",
initialState,
reducers: {
},
reducers: {},
extraReducers: (builder) => {
builder.addCase(loadAccounts.fulfilled, (state, action) => {
if (action.payload) {
state.accounts = action.payload;
const mainAccount = action.payload.find(a => a.isCurrent) || action.payload[0];
const mainAccount =
action.payload.find((a) => a.isCurrent) || action.payload[0];
state.currentAccount = mainAccount;
}

Expand All @@ -52,14 +52,15 @@ const accountsSlice = createSlice({
state.accounts = action.payload.updatedAccounts;

if (
action.payload.deletedAccount.username === state.currentAccount.username &&
action.payload.deletedAccount.username ===
state.currentAccount.username &&
action.payload.deletedAccount.instance === state.currentAccount.instance
) {
state.currentAccount = state.accounts[0];
}
});
builder.addCase(setCurrentAccount.fulfilled, (state, action) => {
state.currentAccount = action.payload
state.currentAccount = action.payload;
});
},
});
Expand Down

0 comments on commit 7d6af23

Please sign in to comment.