Skip to content

Frontend UX: Implement Persistent Editor State #12

@codeCraft-Ritik

Description

@codeCraft-Ritik

Issue :

In PyIDE.jsx, if a user accidentally refreshes the page or navigates away, unsaved local changes to the code might be lost before they are synced to the shared project.

Recommendation : Save the current editor content to localStorage as a temporary backup.

File Path : pytogether/frontend/reactapp/src/pages/PyIDE.jsx

Suggested Logic :

// Inside the component
useEffect(() => {
    const backup = localStorage.getItem(`editor_backup_${projectId}`);
    if (backup && !code) {
        setCode(backup);
    }
}, [projectId]);

const handleCodeChange = (newCode) => {
    setCode(newCode);
    localStorage.setItem(`editor_backup_${projectId}`, newCode);
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions