Handle users tables edges cases when working with grids
This commit is contained in:
parent
25f469dc28
commit
7c2d15be8d
|
@ -33,9 +33,12 @@ export const createGridWebsocket = context => {
|
|||
})
|
||||
|
||||
// Row events
|
||||
socket.on("row-change", data => {
|
||||
socket.on("row-change", async data => {
|
||||
if (data.id) {
|
||||
rows.actions.replaceRow(data.id, data.row)
|
||||
} else if (data.row.id) {
|
||||
// Handle users table edge case
|
||||
await rows.actions.refreshRow(data.row.id)
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -345,10 +345,15 @@ export const deriveStores = context => {
|
|||
const saved = await API.saveRow({ ...row, ...get(rowChangeCache)[rowId] })
|
||||
|
||||
// Update state after a successful change
|
||||
rows.update(state => {
|
||||
state[index] = saved
|
||||
return state.slice()
|
||||
})
|
||||
if (saved?._id) {
|
||||
rows.update(state => {
|
||||
state[index] = saved
|
||||
return state.slice()
|
||||
})
|
||||
} else if (saved?.id) {
|
||||
// Handle users table edge case
|
||||
await refreshRow(saved.id)
|
||||
}
|
||||
rowChangeCache.update(state => {
|
||||
delete state[rowId]
|
||||
return state
|
||||
|
|
Loading…
Reference in New Issue