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