Repository navigation
refactor(application): edit records through ports that take the change - #998
Merged
Merged
Conversation
Renaming an instance read the meta through readMeta, then saved the renamed record through saveMeta, again() trying both again on a 412. saveMeta read the document a second time and sent If-Match on that read, so a change made elsewhere between the two reads was written over with the record the first read gave, and no 412 ever came. editMeta takes the change instead: the adapter reads the meta, has the use case change it, and writes the record changed from that same read, If-Match it, read and changed again on a 412 (editDocument). The use case keeps only its rule, that a name already so is not written again. saveMeta, which nothing else called, is gone. Refs: #997
…n edit port Renaming an instance and describing its catalog read the catalog through readCatalog, then saved the changed one through saveCatalog, again() trying both again on a 412. saveCatalog read the document a second time and sent If-Match on that read, so a change made elsewhere between the two reads was written over and no 412 ever came. editCatalog takes the change instead: the adapter reads the catalog, has the use case change it, and writes the one changed from that same read, If-Match it, read and changed again on a 412 (editDocument). The use cases keep only their rules: no catalog, one that does not fit its shape, a name already so. The rename still checks the catalog's write before it writes anything. saveCatalog stays, for the instance a session makes. Refs: #997
Setting a deck's authors and license read the deck through readDeck, then saved the changed one through saveDeck, again() trying both again on a 412. saveDeck read the catalog a second time and sent If-Match on that read, so a change made elsewhere to the entry between the two reads was written over and no 412 ever came. editDeck takes the change instead: the adapter reads the entry, has the use case change the deck, and writes the entry changed from that same read, If-Match it, read and changed again on a 412 (editDocument). The use case keeps only its rule, the provenance it sets. saveDeck stays for the edits made from the deck as shown. Refs: #997
The preferences and the palettes were the last documents a Solid adapter read, changed, checked and saved by hand, and whether a write was made again on a 412 was said in two layers: the choice to skip the Connected screen was made again by the preferences use cases, through again() and a second try of their own on createdElsewhere, while every other preference write was made once. Each is now an edit made by editDocument. The choice to skip the Connected screen is made again in the adapter, on the preferences as they are then, as the use cases made it; the other preference writes and a palette's are made once, as before, since they write what the screen showed. With that, nothing calls again() or METADATA_ATTEMPTS, and both are gone: every write that re-applies its change does so in the Solid adapters. The data model's write discipline says so. Closes: #997
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Renaming an instance, describing its catalog and setting a deck's authors and license each edited a record through two ports: a read (
readMeta,readCatalog,readDeck) and then a save (saveMeta,saveCatalog,saveDeck), both insideagain(), which tried them again on a 412. Each save port read the document a second time and sentIf-Matchon that second read. What it wrote, though, was the record the use case had built from the first read. When another tab or device changed the document between the two reads, the whole record went back as the first read had it, and no 412 ever came. The retry policy was also split over two layers:editDocument(#995) in the Solid adapters, andagain()withMETADATA_ATTEMPTSin the use cases.This gives those edits ports that take the change, as
editDeckTreeandcompleteChapteralready do, each built oneditDocument. One port per commit:editMeta(instanceUrl, change)for the rename. It replacessaveMeta, which nothing else called.editCatalog(instanceUrl, change)for the rename anddescribeCatalog. The change gets the catalog asreadCatalogreads it (null,"misfit"or the catalog), so the use cases keep their rules. The rename still checks the catalog's write before it writes anything.saveCatalogstays, for the instance a session makes.editDeck(deck, change)forsetDeckProvenance. It takes the deck rather than its URL so it can throwdeckGonewith the title, aseditEntrydoes.saveDeckstays for the edits made from the deck as shown.editDocument.again()plus a second try oncreatedElsewhere.savePreferences,markSchedulerInvitationDismissed,upgradePreferencesandsavePaletteare still made once, as before. They write what the screen showed, so a 412 should reach the user rather than be retried over what changed elsewhere. Adapter tests pin both behaviors down.With that,
again()andMETADATA_ATTEMPTSare gone, and every write that re-applies its change does so in the Solid adapters. The use-case test fakes (fakePorts.ts) model each edit port as read, change and save on top of the existing read mocks.docs/data-model.md(write discipline) and the port docs describe the change. What the app writes to a pod stays the same.The full check passes on each commit.
Merge order: this builds on #996 (
editDocument). Until #996 is merged, this pull request also shows its six commits. Merge #996 first; this branch is then rebased ontomain.Not part of this:
describeDeck,setDeckDirectionandsetDeckPacestill save the deck as the screen shows it, and have the same gap. #997 didn't list them.Closes: #997