Spaces:
Paused
Paused
Download client/src/store/contactsSlice.js from arabdullah/chatty: direct link, hf CLI and curl.
- Browser
- Download file 788 Bytes
-
https://huggingface.co/spaces/arabdullah/chatty/resolve/main/client/src/store/contactsSlice.js
- Command line
-
hf download hf://spaces/arabdullah/chatty/client/src/store/contactsSlice.js
-
curl -L -o contactsSlice.js https://huggingface.co/spaces/arabdullah/chatty/resolve/main/client/src/store/contactsSlice.js
788 Bytes
| import { createSlice } from "@reduxjs/toolkit"; | |
| const contactsSlice = createSlice({ | |
| name: "contactsSlice", | |
| initialState: [], | |
| reducers: { | |
| setContacts: (state, { payload: contacts }) => contacts, | |
| addContact: (state, { payload: contact }) => { | |
| state.push(contact); | |
| }, | |
| removeContact: (state, { payload }) => { | |
| return state.filter( | |
| (contact) => contact.contactDetails._id !== payload.id | |
| ); | |
| }, | |
| setContactOnlineStatus: (state, { payload }) => { | |
| const contactIndex = state.findIndex( | |
| (contact) => contact.contactDetails._id === payload.id | |
| ); | |
| state[contactIndex].contactDetails.status = payload.status; | |
| }, | |
| }, | |
| }); | |
| export const contactsActions = contactsSlice.actions; | |
| export default contactsSlice.reducer; | |