Make user data source refreshable in client apps
This commit is contained in:
parent
a67a8fb957
commit
d27dff0261
|
@ -11,6 +11,7 @@
|
|||
screenStore,
|
||||
authStore,
|
||||
} from "../store"
|
||||
import { TableNames, ActionTypes } from "../constants"
|
||||
|
||||
// Provide contexts
|
||||
setContext("sdk", SDK)
|
||||
|
@ -25,10 +26,20 @@
|
|||
await authStore.actions.fetchUser()
|
||||
loaded = true
|
||||
})
|
||||
|
||||
// Register this as a refreshable datasource so that user changes cause
|
||||
// the user object to be refreshed
|
||||
$: actions = [
|
||||
{
|
||||
type: ActionTypes.RefreshDatasource,
|
||||
callback: () => authStore.actions.fetchUser(),
|
||||
metadata: { datasource: { type: "table", tableId: TableNames.USERS } },
|
||||
},
|
||||
]
|
||||
</script>
|
||||
|
||||
{#if loaded && $screenStore.activeLayout}
|
||||
<Provider key="user" data={$authStore}>
|
||||
<Provider key="user" data={$authStore} {actions}>
|
||||
<Component definition={$screenStore.activeLayout.props} />
|
||||
<NotificationDisplay />
|
||||
</Provider>
|
||||
|
|
Loading…
Reference in New Issue