feat: done command parsing

starting to come together
I realized I'm going to have to seperate selection and filter state
And do actions based on that, some how show that different context
depending on which action is selected
This commit is contained in:
Anish Lakhwara 2025-02-23 19:58:00 -08:00
parent 1c27dd249e
commit b268065d13
4 changed files with 29 additions and 21 deletions

View file

@ -85,6 +85,14 @@ function App({ ctx }) {
const todos = useQuery(ctx, "SELECT * FROM todos where completed = 0").data; const todos = useQuery(ctx, "SELECT * FROM todos where completed = 0").data;
const [newText, setNewText] = useState(""); const [newText, setNewText] = useState("");
const [rowSelection, setRowSelection] = useState({}); const [rowSelection, setRowSelection] = useState({});
// TODO:
// We need to seperate selection state
// From filter state
// Since we don't want selection to impact filter when we're filtering
// We want add to our selection state while we filter
// But selection state should apply to modify and done
// (but probably not add?)
const [selectionContext, setSelectionContext] = useState({});
const [currentAction, setCurrentAction] = useState("add"); const [currentAction, setCurrentAction] = useState("add");
const handleActionChange = (action: string) => { const handleActionChange = (action: string) => {

View file

@ -1,4 +1,4 @@
// @generated by Peggy 4.1.1. // @generated by Peggy 4.2.0.
// //
// https://peggyjs.org/ // https://peggyjs.org/
@ -533,22 +533,22 @@ function peg$parse(input, options) {
var s0, s1, s2, s3, s4; var s0, s1, s2, s3, s4;
s0 = peg$currPos; s0 = peg$currPos;
s1 = peg$parseFilters(); if (input.substr(peg$currPos, 4) === peg$c1) {
s1 = peg$c1;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e1); }
}
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
s2 = peg$parse_(); s2 = peg$parse_();
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c1) { s3 = peg$parseFilters();
s3 = peg$c1;
peg$currPos += 4;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e1); }
}
if (s3 !== peg$FAILED) { if (s3 !== peg$FAILED) {
s4 = peg$parseEOF(); s4 = peg$parseEOF();
if (s4 !== peg$FAILED) { if (s4 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
s0 = peg$f1(s1); s0 = peg$f1(s3);
} else { } else {
peg$currPos = s0; peg$currPos = s0;
s0 = peg$FAILED; s0 = peg$FAILED;

View file

@ -59,7 +59,7 @@ AddCommand = "add" _ parts:(Part / _)+ EOF {
} }
// DONE COMMAND // DONE COMMAND
DoneCommand = filters:Filters _ "done" EOF { DoneCommand = "done" _ filters:Filters EOF {
return makeCommand('done', filters, null); return makeCommand('done', filters, null);
} }

View file

@ -1,4 +1,4 @@
// @generated by Peggy 4.1.1. // @generated by Peggy 4.2.0.
// //
// https://peggyjs.org/ // https://peggyjs.org/
@ -533,22 +533,22 @@ function peg$parse(input, options) {
var s0, s1, s2, s3, s4; var s0, s1, s2, s3, s4;
s0 = peg$currPos; s0 = peg$currPos;
s1 = peg$parseFilters(); if (input.substr(peg$currPos, 4) === peg$c1) {
s1 = peg$c1;
peg$currPos += 4;
} else {
s1 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e1); }
}
if (s1 !== peg$FAILED) { if (s1 !== peg$FAILED) {
s2 = peg$parse_(); s2 = peg$parse_();
if (s2 !== peg$FAILED) { if (s2 !== peg$FAILED) {
if (input.substr(peg$currPos, 4) === peg$c1) { s3 = peg$parseFilters();
s3 = peg$c1;
peg$currPos += 4;
} else {
s3 = peg$FAILED;
if (peg$silentFails === 0) { peg$fail(peg$e1); }
}
if (s3 !== peg$FAILED) { if (s3 !== peg$FAILED) {
s4 = peg$parseEOF(); s4 = peg$parseEOF();
if (s4 !== peg$FAILED) { if (s4 !== peg$FAILED) {
peg$savedPos = s0; peg$savedPos = s0;
s0 = peg$f1(s1); s0 = peg$f1(s3);
} else { } else {
peg$currPos = s0; peg$currPos = s0;
s0 = peg$FAILED; s0 = peg$FAILED;