Skip to content

Commit

Permalink
Merge pull request #713 from anyproto/go-2552-cosmetic-changes-on-links
Browse files Browse the repository at this point in the history
GO-2552 Cosmetic changes on links and backlinks
  • Loading branch information
KirillSto authored Dec 15, 2023
2 parents c0fc83e + fc3800c commit 291c913
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 29 deletions.
25 changes: 7 additions & 18 deletions docs/Flow.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
# Flow
## Back links
To handle editor navigation and support object links consistency `backlinks` built-in relation is provided by Middleware. This relation handles a list of objects that have a link to the object the relation is set to.
## Links to this object
To handle editor navigation and support object links consistency `Links to this object` (key=`backlinks`) built-in relation is provided by Middleware. This relation handles a list of objects that have a link to the object the relation is set to.

Relation is updated on every `smartBlock.updateBackLinks` invocation that is called from `Show` and from `injectLocalDetails` methods of `smartBlock` object, so from the user perspective back links are updated on following object actions:
Every time link from one object to another is created - besides setting `Links from this object`, new link is saved to the ObjectStore.

- Object initialization
- Object opening, as ObjectOpen gRPC request triggers `smartBlock.Show` method
- State Rebuild of a particular object that is triggered from the any-sync side
- Resetting of Object version that needs repetitive injection of local details
ObjectStore provides method `SubscribeBacklinksUpdate` that generates subscription on every links changes in store.

### TODO:
The drawback of this behavior is that back links update is not triggered on every actual change of back links content.

Need to redesign this approach the way to handle every possible change of object's incoming links:

- Creation of link block
- Creation of inline set or collection
- Creation of widget (?)
- Creation of bookmark
- ...
Special service `backlinks.UpdateWatcher` was designed to look after changes on links using backlinks subscription. On links change the service triggers `StateAppend` of target objects, that helps to:

As now backlinks are gotten from the object store, all these changes need to be done after store redesign, so mechanism of getting links of object and saving it both to store and to backlinks relation has same enter point.
- inject derived details of target object. Backlinks are retrieved from store on this step
- generate necessary events to notify dependent objects about details changes

## Internal Flags
All objects can have relation `InternalFlags` set to its details. This relation handles list of flags used mainly by client:
Expand Down
11 changes: 5 additions & 6 deletions pkg/lib/bundle/relation.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/anyproto/anytype-heart/pkg/lib/pb/model"
)

const RelationChecksum = "d0dd6cb34ebb2790c1ece96722a701cfe434e67d726871749b7e3b01e7659def"
const RelationChecksum = "9d13b57d26e1a12a93d497a0016a692457a39e7fa73797a1ba27a4957cb9b734"
const (
RelationKeyTag domain.RelationKey = "tag"
RelationKeyCamera domain.RelationKey = "camera"
Expand Down Expand Up @@ -345,11 +345,10 @@ var (
Format: model.RelationFormat_object,
Id: "_brbacklinks",
Key: "backlinks",
MaxCount: 1,
Name: "Links to object",
Name: "Links to this object",
ReadOnly: true,
ReadOnlyRelation: true,
Revision: 1,
Revision: 2,
Scope: model.Relation_type,
},
RelationKeyBudget: {
Expand Down Expand Up @@ -1213,10 +1212,10 @@ var (
Format: model.RelationFormat_object,
Id: "_brlinks",
Key: "links",
Name: "Links from object",
Name: "Links from this object",
ReadOnly: true,
ReadOnlyRelation: true,
Revision: 1,
Revision: 2,
Scope: model.Relation_type,
},
RelationKeyLogic: {
Expand Down
10 changes: 5 additions & 5 deletions pkg/lib/bundle/relations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1123,10 +1123,10 @@
"hidden": false,
"key": "links",
"maxCount": 0,
"name": "Links from object",
"name": "Links from this object",
"readonly": true,
"source": "derived",
"revision": 1
"revision": 2
},
{
"format": "number",
Expand Down Expand Up @@ -1427,12 +1427,12 @@
"description": "List of links coming to object",
"format": "object",
"key": "backlinks",
"maxCount": 1,
"maxCount": 0,
"hidden": false,
"name": "Links to object",
"name": "Links to this object",
"readonly": true,
"source": "local",
"revision": 1
"revision": 2
},
{
"description": "Relation that indicates document has been uninstalled",
Expand Down
Binary file modified util/builtinobjects/data/empty.zip
Binary file not shown.
Binary file modified util/builtinobjects/data/knowledge_base.zip
Binary file not shown.
Binary file modified util/builtinobjects/data/migration_dashboard.zip
Binary file not shown.
Binary file modified util/builtinobjects/data/notes_diary.zip
Binary file not shown.
Binary file modified util/builtinobjects/data/personal_projects.zip
Binary file not shown.
Binary file modified util/builtinobjects/data/skip.zip
Binary file not shown.
Binary file modified util/builtinobjects/data/strategic_writing.zip
Binary file not shown.

0 comments on commit 291c913

Please sign in to comment.