1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-09 17:44:59 +09:00

PROD-605 Change default sort

This commit is contained in:
Mikhail Iudin 2023-04-25 18:17:59 +02:00
parent 215c5fca58
commit 5e57cec391
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0

View file

@ -301,11 +301,7 @@ func (d *sdataview) CreateView(ctx *session.Context, id string,
if len(view.Sorts) == 0 {
// todo: set depends on the view type
view.Sorts = []*model.BlockContentDataviewSort{{
Id: bson.NewObjectId().Hex(),
RelationKey: bundle.RelationKeyLastModifiedDate.String(),
Type: model.BlockContentDataviewSort_Desc,
}}
view.Sorts = defaultLastModifiedDateSort()
}
sbType, err := d.sbtProvider.Type(d.Id())
@ -327,6 +323,16 @@ func (d *sdataview) CreateView(ctx *session.Context, id string,
return &view, d.Apply(s)
}
func defaultLastModifiedDateSort() []*model.BlockContentDataviewSort {
return []*model.BlockContentDataviewSort{
{
Id: bson.NewObjectId().Hex(),
RelationKey: bundle.RelationKeyLastModifiedDate.String(),
Type: model.BlockContentDataviewSort_Desc,
},
}
}
func (d *sdataview) UpdateViewGroupOrder(ctx *session.Context, blockId string, order *model.BlockContentDataviewGroupOrder) error {
st := d.NewStateCtx(ctx)
dvBlock, err := getDataviewBlock(st, blockId)
@ -630,15 +636,10 @@ func DataviewBlockBySource(sbtProvider typeprovider.SmartBlockTypeProvider, stor
RelationLinks: relations,
Views: []*model.BlockContentDataviewView{
{
Id: bson.NewObjectId().Hex(),
Type: model.BlockContentDataviewView_Table,
Name: "All",
Sorts: []*model.BlockContentDataviewSort{
{
RelationKey: "name",
Type: model.BlockContentDataviewSort_Asc,
},
},
Id: bson.NewObjectId().Hex(),
Type: model.BlockContentDataviewView_Table,
Name: "All",
Sorts: defaultLastModifiedDateSort(),
Filters: nil,
Relations: viewRelations,
},