diff --git a/fuel/app/classes/materia/widget/instance/manager.php b/fuel/app/classes/materia/widget/instance/manager.php index d6ef5f140..ff345715f 100644 --- a/fuel/app/classes/materia/widget/instance/manager.php +++ b/fuel/app/classes/materia/widget/instance/manager.php @@ -89,7 +89,7 @@ public static function get_paginated_for_user($user_id, $page_number = 0) $displayable_inst = array_slice($displayable_inst, $offset, $widgets_per_page); $data = [ - 'pagination' => $displayable_inst, + 'pagination' => $displayable_inst ]; if ($has_next_page) $data['next_page'] = $page_number + 1; diff --git a/src/components/hooks/useCopyWidget.jsx b/src/components/hooks/useCopyWidget.jsx index 61811706a..a37934bb2 100644 --- a/src/components/hooks/useCopyWidget.jsx +++ b/src/components/hooks/useCopyWidget.jsx @@ -36,7 +36,8 @@ export default function useCopyWidget() { pages: previous.pages.map((page, index) => { if (index == 0) return { ...page, pagination: [ newInst, ...page.pagination] } else return page - }) + }), + modified: Math.floor(Date.now() / 1000) })) return { previousValue } @@ -51,7 +52,8 @@ export default function useCopyWidget() { return inst }) } else return page - }) + }), + modified: Math.floor(Date.now() / 1000) })) variables.successFunc(data) }, diff --git a/src/components/hooks/useDeleteWidget.jsx b/src/components/hooks/useDeleteWidget.jsx index 036b564cc..c956f4d11 100644 --- a/src/components/hooks/useDeleteWidget.jsx +++ b/src/components/hooks/useDeleteWidget.jsx @@ -19,7 +19,8 @@ export default function useDeleteWidget() { pages: previous.pages.map((page) => ({ ...page, pagination: page.pagination.filter(widget => widget.id !== inst.instId) - })) + })), + modified: Math.floor(Date.now() / 1000) } }) diff --git a/src/components/hooks/useUpdateWidget.jsx b/src/components/hooks/useUpdateWidget.jsx index 39321e331..96c563369 100644 --- a/src/components/hooks/useUpdateWidget.jsx +++ b/src/components/hooks/useUpdateWidget.jsx @@ -16,7 +16,7 @@ export default function useUpdateWidget() { widgetList = queryClient.getQueryData('widgets') // widgetList is passed to onSuccess or onError depending on resolution of mutation function - return { widgetList } + return { ...widgetList } }, onSuccess: (updatedInst, variables) => { @@ -24,9 +24,9 @@ export default function useUpdateWidget() { for (const page of widgetList?.pages) { for (const inst of page?.pagination) { if (inst.id === variables.args[0]) { - inst.open_at = `${variables.args[4]}` - inst.close_at = `${variables.args[5]}` - inst.attempts = `${variables.args[6]}` + inst.open_at = parseInt(variables.args[4]) + inst.close_at = parseInt(variables.args[5]) + inst.attempts = parseInt(variables.args[6]) inst.guest_access = variables.args[7] inst.embedded_only = variables.args[8] break @@ -34,9 +34,14 @@ export default function useUpdateWidget() { } } - // update query cache for widgets. This does NOT invalidate the cache, forcing a re-fetch!! - queryClient.setQueryData('widgets', widgetList) + queryClient.setQueryData('widgets', previous => { + return { + ...widgetList, + modified: Math.floor(Date.now() / 1000) + } + }) + queryClient.invalidateQueries(['user-perms', variables.args[0]]) variables.successFunc(updatedInst)