Skip to content

Commit

Permalink
Merge pull request #493 from VictoriaShyika/276-autosave
Browse files Browse the repository at this point in the history
473: Added autosave to Jumpstart
  • Loading branch information
atulbhatt-system32 authored Dec 7, 2023
2 parents 6bcf530 + 847b02f commit 0132af5
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/_ref/cmdk.ref/Jumpstart.csv
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ Open,folder,Open a folder,o,Projects
Guide,help,Learn something,g,Help
Support,person,Get some help,,Help
Community,people,Talk with people,,Help
Theme,,Switch themes,m,Settings
Theme,,Switch themes,m,Settings
Autosave,,Switch autosave,,Settings
26 changes: 26 additions & 0 deletions src/pages/main/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,9 @@ export default function MainPage() {
case "Turn into":
onTurnInto();
break;
case "Autosave":
onToggleAutoSave();
break;
default:
return;
}
Expand Down Expand Up @@ -1174,6 +1177,11 @@ export default function MainPage() {
}
}, [theme]);

const [autoSave, setAutoSave] = useState(false);
const onToggleAutoSave = () => {
setAutoSave(!autoSave);
};

// web-tab close event handler
useEffect(() => {
let changed = false;
Expand Down Expand Up @@ -1539,6 +1547,7 @@ export default function MainPage() {

// keep modal open when toogling theme or go "Add" menu from "Actions" menu
command.Name !== "Theme" &&
command.Name !== "Autosave" &&
command.Name !== "Add" &&
command.Name !== "Turn into" &&
dispatch(setCmdkOpen(false));
Expand Down Expand Up @@ -1617,6 +1626,23 @@ export default function MainPage() {
<span className="text-m">{theme}</span>
</div>
</>
) : command.Name === "Autosave" ? (
<>
<div className="padding-xs">
<div className="radius-m icon-xs align-center background-tertiary"></div>
</div>
<div className="gap-s align-center">
<span className="text-m opacity-m">
Autosave
</span>
<span className="text-s opacity-m">
/
</span>
<span className="text-m">
{autoSave ? "On" : "Off"}
</span>
</div>
</>
) : (
<>
<div className="padding-xs">
Expand Down

0 comments on commit 0132af5

Please sign in to comment.