🔧 refactor(App.tsx): import AppRegistry, Platform from react-native for better platform detection 🔧 refactor(App.tsx): import persistor from redux store to persist redux state 🔧 refactor(App.tsx): wrap app in PersistGate to persist and rehydrate a redux store 🔧 refactor(App.tsx): change initial token state to use token from redux store 🔧 refactor(app.json): add package name to app.json for unique app identification 🔧 refactor(package.json): change android and ios scripts to use expo run:android and expo run:ios 🔧 refactor(package.json): add react-native-android-notification-listener and react-native-pager-view dependencies 🔧 refactor(package.json): add redux-persist-expo-filesystem for redux state persistence 🔧 refactor(ClipElementLocal.tsx): remove unnecessary whitespace 🔧 refactor(ClipList.tsx): replace ScrollView with FlatList for better performance 🔧 refactor(ClipList.tsx): use nanoid for unique key generation in FlatList 🔧 refactor(ClipView.tsx): add Button for compact layout 🔧 refactor(ClipView.tsx): adjust Searchbar style for better layout 🔧 refactor(ClipViewLocal.tsx): use localClipAddToList action for adding to local clip list 🔧 refactor(ClipViewLocal.tsx): set initial clips state to use localClip from redux store 🔧 refactor(ClipViewRemote.tsx): use remoteClipAddToList action for adding to remote clip list 🔧 refactor(ClipViewRemote.tsx): set initial clips state to use remoteClip from redux store 🔧 refactor(Clips.tsx): add signout function to clear all redux states on signout 🔧 refactor(Clips.tsx): add Notifications to Drawer 🔧 refactor(Clips.tsx): replace ClipView with NotifView for notif active state 🔧 refactor(reducers.tsx): rename localAddToList to localClipAddToList for better semantics 🔧 refactor(reducers.tsx): rename remoteAddToList to remoteClipAddToList for better semantics 🔧 refactor(reducers.tsx): add localNotifsSlice and remoteNotifsSlice for handling local and remote notifications
118 lines
2.9 KiB
TypeScript
118 lines
2.9 KiB
TypeScript
import { applyMiddleware,createSlice } from "@reduxjs/toolkit";
|
|
|
|
console.log(applyMiddleware);
|
|
|
|
export const userSlice = createSlice({
|
|
name: 'user',
|
|
initialState: {
|
|
token: "",
|
|
username:"",
|
|
},
|
|
reducers: {
|
|
login: (state, action) => {
|
|
state.token = action.payload.token;
|
|
state.username = action.payload.username;
|
|
},
|
|
disconnect: state => {
|
|
state.token = "";
|
|
state.username = "";
|
|
}
|
|
},
|
|
|
|
})
|
|
|
|
export const {login, disconnect} = userSlice.actions;
|
|
|
|
// Local clip structure
|
|
// [
|
|
// {"content":"first"},
|
|
// ]
|
|
|
|
export const localClipsSlice = createSlice({
|
|
name: 'localClips',
|
|
initialState: {
|
|
localClip:[],
|
|
},
|
|
reducers: {
|
|
localClipAddToList: (state,action) => {
|
|
state.localClip = [...state.localClip,action.payload]
|
|
},
|
|
localClipRemoveFromList: (state,action) => {
|
|
state.localClip = state.localClip.filter(e => e !== action.payload)
|
|
},
|
|
localClipClear : (state,action) =>{
|
|
state.localClip = []
|
|
}
|
|
}
|
|
})
|
|
|
|
export const {localClipAddToList, localClipRemoveFromList, localClipClear} = localClipsSlice.actions;
|
|
|
|
// Remote clip structure
|
|
// [
|
|
// {"content":"first","device":"user_pc","timestamp":1711819286000}
|
|
// ]
|
|
|
|
export const remoteClipsSlice = createSlice({
|
|
name: 'remoteClips',
|
|
initialState: {
|
|
remoteClip:[],
|
|
},
|
|
reducers: {
|
|
remoteClipAddToList: (state,action) => {
|
|
console.log(action.payload);
|
|
state.remoteClip = action.payload
|
|
},
|
|
remoteClipRemoveFromList: (state,action) => {
|
|
state.remoteClip = state.remoteClip.filter(e => e !== action.payload);
|
|
},
|
|
remoteClipClear : (state,action) =>{
|
|
state.remoteClip = []
|
|
},
|
|
|
|
}
|
|
})
|
|
|
|
export const {remoteClipAddToList, remoteClipRemoveFromList, remoteClipClear} = remoteClipsSlice.actions;
|
|
|
|
|
|
export const localNotifsSlice = createSlice({
|
|
name: 'localNotifs',
|
|
initialState: {
|
|
localNotif:[],
|
|
},
|
|
reducers: {
|
|
localNotifAddToList: (state,action) => {
|
|
state.localNotif = [...state.localNotif,action.payload]
|
|
},
|
|
localNotifRemoveFromList: (state,action) => {
|
|
state.localNotif = state.localNotif.filter(e => e !== action.payload)
|
|
},
|
|
localNotifClear : (state,action) =>{
|
|
state.localNotif = []
|
|
}
|
|
}
|
|
})
|
|
|
|
export const {localNotifAddToList, localNotifRemoveFromList, localNotifClear} = localNotifsSlice.actions;
|
|
|
|
export const remoteNotifsSlice = createSlice({
|
|
name: 'remoteNotifs',
|
|
initialState: {
|
|
remoteNotif:[],
|
|
},
|
|
reducers: {
|
|
remoteNotifAddToList: (state,action) => {
|
|
state.remoteNotif = [...action.payload]
|
|
},
|
|
remoteNotifRemoveFromList: (state,action) => {
|
|
state.remoteNotif = state.remoteNotif.filter(e => e !== action.payload);
|
|
},
|
|
remoteNotifClear : (state,action) =>{
|
|
state.remoteNotif = []
|
|
}
|
|
}
|
|
})
|
|
|
|
export const {remoteNotifAddToList, remoteNotifRemoveFromList, remoteNotifClear} = remoteNotifsSlice.actions;
|