oh sorry here is my loadeditorstate. This works but its not triggered on refresh:
export const loadEditorState: LoadEditorState<LoadEditorStateArgs, string | null> = async (args, context) => {
if (!context.user) {
throw new HttpError(401, 'User not authenticated');
}
const { projectId } = args;
const userId = context.user.id;
// Try to find the ProjectEditorState for the given user and project
const state = await context.entities.ProjectEditorState.findFirst({
where: {
AND: [
{ userId: userId },
{ projectId: projectId },
],
},
});
console.log('Loaded state:', state); // Add this line to log the loaded state
// Return the state if found, otherwise return null
return state ? state.state : null;
};