Extract file operations into higher level abstraction.
This commit is contained in:
parent
b76afe0aa9
commit
e8064b0aff
2 changed files with 10 additions and 11 deletions
2
TODO.md
2
TODO.md
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
## Refactor
|
||||
|
||||
- [ ] Extract file operations into higher-level abstraction
|
||||
- [ ] Simplify drop indicator logic
|
||||
- [ ] Consolidate menu creation (card menus and burger menu)
|
||||
- [ ] Extract line parsing logic - separate parsing from state management
|
||||
|
|
@ -25,6 +24,7 @@
|
|||
|
||||
## Done
|
||||
|
||||
- [x] Extract file operations into higher-level abstraction
|
||||
- [x] Consolidate modal logic into generic modal handler
|
||||
- [x] Warning colored note on home and about page if browser doesn't support FileSystem Access API.
|
||||
- [x] Ability to delete an item, with confirmation.
|
||||
|
|
|
|||
19
index.html
19
index.html
|
|
@ -1346,15 +1346,20 @@ chmod 755 kbtd
|
|||
return null;
|
||||
}
|
||||
|
||||
async function updateCardInFile(lineNumber, newTitle, newNestedContent, baseIndent) {
|
||||
console.log('updateCardInFile:', lineNumber, newTitle, newNestedContent, baseIndent);
|
||||
async function modifyCard(lineNumber, fn) {
|
||||
await modifyFileLines(lines => {
|
||||
const cardInfo = findCardByLineNumber(lineNumber);
|
||||
if (!cardInfo) {
|
||||
console.error('Could not find card with line number', lineNumber);
|
||||
return;
|
||||
}
|
||||
|
||||
fn(lines, cardInfo);
|
||||
});
|
||||
}
|
||||
|
||||
async function updateCardInFile(lineNumber, newTitle, newNestedContent, baseIndent) {
|
||||
console.log('updateCardInFile:', lineNumber, newTitle, newNestedContent, baseIndent);
|
||||
await modifyCard(lineNumber, (lines, cardInfo) => {
|
||||
const card = cardInfo.card;
|
||||
const oldNestedLineCount = card.nestedLines.length;
|
||||
|
||||
|
|
@ -1371,13 +1376,7 @@ chmod 755 kbtd
|
|||
|
||||
async function deleteCard(lineNumber) {
|
||||
console.log('deleteCard:', lineNumber);
|
||||
await modifyFileLines(lines => {
|
||||
const cardInfo = findCardByLineNumber(lineNumber);
|
||||
if (!cardInfo) {
|
||||
console.error('Could not find card with line number', lineNumber);
|
||||
return;
|
||||
}
|
||||
|
||||
await modifyCard(lineNumber, (lines, cardInfo) => {
|
||||
const card = cardInfo.card;
|
||||
const nestedLineCount = card.nestedLines.length;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue