mirror of
https://git.kescher.at/CatCatNya/catstodon.git
synced 2024-11-24 08:08:07 +01:00
919ed0e469
Port 4b7bc1f07c
to glitch-soc
Signed-off-by: Claire <claire.github-309c@sitedethib.com>
33 lines
820 B
TypeScript
33 lines
820 B
TypeScript
import { createReducer } from '@reduxjs/toolkit';
|
|
|
|
import { closeDropdownMenu, openDropdownMenu } from '../actions/dropdown_menu';
|
|
|
|
interface DropdownMenuState {
|
|
openId: string | null;
|
|
keyboard: boolean;
|
|
scrollKey: string | null;
|
|
}
|
|
|
|
const initialState: DropdownMenuState = {
|
|
openId: null,
|
|
keyboard: false,
|
|
scrollKey: null,
|
|
};
|
|
|
|
export const dropdownMenuReducer = createReducer(initialState, (builder) => {
|
|
builder
|
|
.addCase(
|
|
openDropdownMenu,
|
|
(state, { payload: { id, keyboard, scrollKey } }) => {
|
|
state.openId = id;
|
|
state.keyboard = keyboard;
|
|
state.scrollKey = scrollKey;
|
|
},
|
|
)
|
|
.addCase(closeDropdownMenu, (state, { payload: { id } }) => {
|
|
if (state.openId === id) {
|
|
state.openId = null;
|
|
state.scrollKey = null;
|
|
}
|
|
});
|
|
});
|