Skip to content

web app: Backlinks, Outgoing links and the backlink count refetch on every save #212

Closed

Description

@frostyard-machines

In lodge's web app, 3 hooks refetch from notesd on every change to the file list:

  • useBacklinkCount (app/src/app/status.ts:43-63): note.backlinks
  • BacklinksContainer (app/src/app/panes/links.tsx:85-106): note.backlinks, then unlinkedGroups (links.tsx:47-70), which is note.read plus 1 note.search for the title and for each alias
  • OutgoingContainer (app/src/app/panes/links.tsx:122-136): note.links

Each has files (useFiles((s) => s.files)) in its effect's dependencies, as the trigger. applyFileEvent (app/src/data/files.ts:83-92) makes a new files map for each note.changed whose hash differs, and each save emits one. So while a person types, each autosave costs 2 note.backlinks, 1 note.read, 1 or more note.search and 1 note.links round trips through lodge, even when no link changed. useNoteCounts and the aliases sync already wait for the changes to stop (COUNT_DELAY, status.ts:66-67); these 3 do not.

What's wanted: let these hooks wait until the changes stop (as COUNT_DELAY does) or trigger on pathsVersion plus a debounced content change, so a burst of saves costs 1 refresh. The panes then catch up a short time after typing stops; that is a change in behavior, so it is not done in a grooming pass.

Found in a code review of main at b9c6c90.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions