Skip to content

Commit

Permalink
polish
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexErrant committed Dec 11, 2024
1 parent 42cc131 commit ee6c49e
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
27 changes: 14 additions & 13 deletions app/src/components/addNote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@ export default function AddNote() {
if (note != null && template != null) {
const ords = C.noteOrds(note, template)
const now = C.getDate()
const cards = ords.map((ord) => {
return {
id: ulidAsBase64Url() as CardId,
ord,
noteId: note.id,
tags: new Set(),
created: now,
edited: now,
due: now,
lapses: 0,
repCount: 0,
} satisfies Card
})
const cards = ords.map(
(ord) =>
({
id: ulidAsBase64Url() as CardId,
ord,
noteId: note.id,
tags: new Set(),
created: now,
edited: now,
due: now,
lapses: 0,
repCount: 0,
}) satisfies Card,
)
setWip('noteCard', 'cards', cards)
}
},
Expand Down
12 changes: 6 additions & 6 deletions app/src/uiLogic/aggrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ export function createGrid<TData>(

export function registerGridUpdate<T>(
gridApi: GridApi<T>,
[templateRowDelta, setTemplateRowDelta]: Signal<number | undefined>,
[rowDelta, setRowDelta]: Signal<number | undefined>,
) {
createEffect(
on(
templateRowDelta,
(templateRowDelta) => {
if (templateRowDelta != null) {
rowDelta,
(rowDelta) => {
if (rowDelta != null) {
// This code is copied from the "Using Cache API Methods" example
// https://www.ag-grid.com/javascript-data-grid/infinite-scrolling/#example-using-cache-api-methods
// https://codesandbox.io/p/sandbox/v6klrp
Expand All @@ -91,10 +91,10 @@ export function registerGridUpdate<T>(
const maxRowFound = gridApi.isLastRowIndexKnown()
if (maxRowFound ?? false) {
const rowCount = gridApi.getDisplayedRowCount()
gridApi.setRowCount(rowCount + templateRowDelta)
gridApi.setRowCount(rowCount + rowDelta)
}
gridApi.refreshInfiniteCache()
setTemplateRowDelta(undefined) // "unset" add so we can listen to new changes
setRowDelta(undefined) // "unset" add so we can listen to new changes
}
},
{ defer: true },
Expand Down

0 comments on commit ee6c49e

Please sign in to comment.