You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
111 lines
4.3 KiB
TypeScript
111 lines
4.3 KiB
TypeScript
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
|
|
import { SessionConfirmDialogProps } from '../../components/session/SessionConfirm';
|
|
|
|
export type ConfirmModalState = SessionConfirmDialogProps | null;
|
|
export type InviteContactModalState = { conversationId: string } | null;
|
|
export type AddModeratorsModalState = InviteContactModalState;
|
|
export type RemoveModeratorsModalState = InviteContactModalState;
|
|
export type UpdateGroupMembersModalState = InviteContactModalState;
|
|
export type UpdateGroupNameModalState = InviteContactModalState;
|
|
export type ChangeNickNameModalState = InviteContactModalState;
|
|
export type AdminLeaveClosedGroupModalState = InviteContactModalState;
|
|
export type EditProfileModalState = {} | null;
|
|
export type OnionPathModalState = EditProfileModalState;
|
|
export type RecoveryPhraseModalState = EditProfileModalState;
|
|
|
|
export type UserDetailsModalState = {
|
|
conversationId: string;
|
|
authorAvatarPath?: string;
|
|
userName: string;
|
|
} | null;
|
|
|
|
export type ModalState = {
|
|
confirmModal: ConfirmModalState;
|
|
inviteContactModal: InviteContactModalState;
|
|
addModeratorsModal: AddModeratorsModalState;
|
|
removeModeratorsModal: RemoveModeratorsModalState;
|
|
groupNameModal: UpdateGroupNameModalState;
|
|
groupMembersModal: UpdateGroupMembersModalState;
|
|
userDetailsModal: UserDetailsModalState;
|
|
nickNameModal: ChangeNickNameModalState;
|
|
editProfileModal: EditProfileModalState;
|
|
onionPathModal: OnionPathModalState;
|
|
recoveryPhraseModal: RecoveryPhraseModalState;
|
|
adminLeaveClosedGroup: AdminLeaveClosedGroupModalState;
|
|
};
|
|
|
|
export const initialModalState: ModalState = {
|
|
confirmModal: null,
|
|
inviteContactModal: null,
|
|
addModeratorsModal: null,
|
|
removeModeratorsModal: null,
|
|
groupNameModal: null,
|
|
groupMembersModal: null,
|
|
userDetailsModal: null,
|
|
nickNameModal: null,
|
|
editProfileModal: null,
|
|
onionPathModal: null,
|
|
recoveryPhraseModal: null,
|
|
adminLeaveClosedGroup: null,
|
|
};
|
|
|
|
const ModalSlice = createSlice({
|
|
name: 'modals',
|
|
initialState: initialModalState,
|
|
reducers: {
|
|
updateConfirmModal(state, action: PayloadAction<ConfirmModalState | null>) {
|
|
return { ...state, confirmModal: action.payload };
|
|
},
|
|
updateInviteContactModal(state, action: PayloadAction<InviteContactModalState | null>) {
|
|
return { ...state, inviteContactModal: action.payload };
|
|
},
|
|
updateAddModeratorsModal(state, action: PayloadAction<AddModeratorsModalState | null>) {
|
|
return { ...state, addModeratorsModal: action.payload };
|
|
},
|
|
updateRemoveModeratorsModal(state, action: PayloadAction<RemoveModeratorsModalState | null>) {
|
|
return { ...state, removeModeratorsModal: action.payload };
|
|
},
|
|
updateGroupNameModal(state, action: PayloadAction<UpdateGroupNameModalState | null>) {
|
|
return { ...state, groupNameModal: action.payload };
|
|
},
|
|
updateGroupMembersModal(state, action: PayloadAction<UpdateGroupMembersModalState | null>) {
|
|
return { ...state, groupMembersModal: action.payload };
|
|
},
|
|
updateUserDetailsModal(state, action: PayloadAction<UserDetailsModalState | null>) {
|
|
return { ...state, userDetailsModal: action.payload };
|
|
},
|
|
changeNickNameModal(state, action: PayloadAction<ChangeNickNameModalState | null>) {
|
|
return { ...state, nickNameModal: action.payload };
|
|
},
|
|
editProfileModal(state, action: PayloadAction<EditProfileModalState | null>) {
|
|
return { ...state, editProfileModal: action.payload };
|
|
},
|
|
onionPathModal(state, action: PayloadAction<OnionPathModalState | null>) {
|
|
return { ...state, onionPathModal: action.payload };
|
|
},
|
|
recoveryPhraseModal(state, action: PayloadAction<RecoveryPhraseModalState | null>) {
|
|
return { ...state, recoveryPhraseModal: action.payload };
|
|
},
|
|
adminLeaveClosedGroup(state, action: PayloadAction<AdminLeaveClosedGroupModalState | null>) {
|
|
return { ...state, adminLeaveClosedGroup: action.payload };
|
|
},
|
|
},
|
|
});
|
|
|
|
export const { actions, reducer } = ModalSlice;
|
|
export const {
|
|
updateConfirmModal,
|
|
updateInviteContactModal,
|
|
updateAddModeratorsModal,
|
|
updateRemoveModeratorsModal,
|
|
updateGroupNameModal,
|
|
updateGroupMembersModal,
|
|
updateUserDetailsModal,
|
|
changeNickNameModal,
|
|
editProfileModal,
|
|
onionPathModal,
|
|
recoveryPhraseModal,
|
|
adminLeaveClosedGroup,
|
|
} = actions;
|
|
export const modalReducer = reducer;
|