1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-11 02:13:41 +09:00

Merge pull request #1172 from anytypeio/fix-options

Fix options
This commit is contained in:
Roman Khafizianov 2021-08-11 01:53:41 +04:00 committed by GitHub
commit 585c07010d
Signed by: github
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 13 deletions

View file

@ -186,6 +186,16 @@ func (d *dataviewCollectionImpl) UpdateRelation(ctx *state.Context, blockId stri
}
}
if relation.Format == model.RelationFormat_status || relation.Format == model.RelationFormat_tag {
// reinject relation options
options, err := d.Anytype().ObjectStore().GetAggregatedOptions(relationKey, relation.Format, tb.GetSource())
if err != nil {
log.Errorf("failed to GetAggregatedOptionsForRelation %s", err.Error())
} else {
relation.SelectDict = options
}
}
if err = tb.UpdateRelation(relationKey, relation); err != nil {
return err
}
@ -812,14 +822,7 @@ func (d *dataviewCollectionImpl) updateAggregatedOptionsForRelation(st *state.St
rel.SelectDict = options
dvBlock.UpdateRelation(rel.Key, *rel)
// we need to send event manually because selectDict is trimmed from the pb changes
d.SendEvent([]*pb.EventMessage{
{Value: &pb.EventMessageValueOfBlockDataviewRelationSet{
&pb.EventBlockDataviewRelationSet{
Id: dvBlock.Model().Id,
RelationKey: rel.Key,
Relation: rel,
}}}})
st.Set(dvBlock)
return d.Apply(st)
}

View file

@ -257,7 +257,7 @@ func (s *Dataview) UpdateRelation(relationKey string, rel model.Relation) error
if v.Key == relationKey {
found = true
s.content.Relations[i] = &rel
s.content.Relations[i] = pbtypes.CopyRelation(&rel)
break
}
}

View file

@ -435,7 +435,7 @@ func (m *dsObjectStore) AggregateObjectIdsByOptionForRelation(relationKey string
txn, err := m.ds.NewTransaction(true)
defer txn.Discard()
res, err := localstore.GetKeysByIndexParts(txn, pagesPrefix, indexRelationOptionObject.Name, []string{relationKey}, "/", false, 100)
res, err := localstore.GetKeysByIndexParts(txn, pagesPrefix, indexRelationOptionObject.Name, []string{relationKey}, "/", false, 0)
if err != nil {
return nil, err
}
@ -470,7 +470,7 @@ func (m *dsObjectStore) getAggregatedOptionsForFormat(format model.RelationForma
txn, err := m.ds.NewTransaction(true)
defer txn.Discard()
res, err := localstore.GetKeysByIndexParts(txn, pagesPrefix, indexFormatOptionObject.Name, []string{format.String()}, "/", false, 100)
res, err := localstore.GetKeysByIndexParts(txn, pagesPrefix, indexFormatOptionObject.Name, []string{format.String()}, "/", false, 0)
if err != nil {
return nil, err
}
@ -1828,7 +1828,7 @@ func (m *dsObjectStore) updateDetails(txn ds.Txn, id string, oldDetails *model.O
return nil
}
log.Debugf("updateDetails %s: %s", id, pbtypes.Sprint(newDetails.GetDetails()))
log.Debugf("updateDetails %s: diff %s", id, pbtypes.Sprint(pbtypes.StructDiff(oldDetails.GetDetails(), newDetails.GetDetails())))
err = localstore.UpdateIndexesWithTxn(m, txn, oldDetails, newDetails, id)
if err != nil {
return err
@ -1889,7 +1889,7 @@ func (m *dsObjectStore) makeFTSQuery(text string, dsq query.Query) (query.Query,
}
func (m *dsObjectStore) listIdsOfType(txn ds.Txn, ot string) ([]string, error) {
res, err := localstore.GetKeysByIndexParts(txn, pagesPrefix, indexObjectTypeObject.Name, []string{ot}, "", false, 100)
res, err := localstore.GetKeysByIndexParts(txn, pagesPrefix, indexObjectTypeObject.Name, []string{ot}, "", false, 0)
if err != nil {
return nil, err
}