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
|
// Row events
|
||||||
socket.on("row-change", data => {
|
socket.on("row-change", async data => {
|
||||||
if (data.id) {
|
if (data.id) {
|
||||||
rows.actions.replaceRow(data.id, data.row)
|
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] })
|
const saved = await API.saveRow({ ...row, ...get(rowChangeCache)[rowId] })
|
||||||
|
|
||||||
// Update state after a successful change
|
// Update state after a successful change
|
||||||
rows.update(state => {
|
if (saved?._id) {
|
||||||
state[index] = saved
|
rows.update(state => {
|
||||||
return state.slice()
|
state[index] = saved
|
||||||
})
|
return state.slice()
|
||||||
|
})
|
||||||
|
} else if (saved?.id) {
|
||||||
|
// Handle users table edge case
|
||||||
|
await refreshRow(saved.id)
|
||||||
|
}
|
||||||
rowChangeCache.update(state => {
|
rowChangeCache.update(state => {
|
||||||
delete state[rowId]
|
delete state[rowId]
|
||||||
return state
|
return state
|
||||||
|
|
Loading…
Reference in New Issue