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

GO-5409 onboarding fixes

This commit is contained in:
Roman Khafizianov 2025-04-04 14:22:31 +02:00
parent e5a52131fd
commit 0e092fc5ee
No known key found for this signature in database
GPG key ID: F07A7D55A2684852
2 changed files with 1 additions and 27 deletions

View file

@ -392,7 +392,7 @@ func (b *builtinObjects) createWidgets(ctx session.Context, spaceId string, useC
log.Errorf("failed to get type id: %w", err)
return
}
for _, typeId := range []string{taskTypeId, pageTypeId} {
for _, typeId := range []string{pageTypeId, taskTypeId} {
if has, err := b.typeHasObjects(spaceId, typeId); err != nil {
log.Warnf("failed to check if type '%s' has objects: %v", pageTypeId, err)
} else if has {
@ -400,36 +400,10 @@ func (b *builtinObjects) createWidgets(ctx session.Context, spaceId string, useC
}
}
var welcomePageId string
if useCase == pb.RpcObjectImportUseCaseRequest_GET_STARTED {
welcomePageId, err = b.getNewObjectID(spaceId, "bafyreidbxbw522cupdbxgzdpqayqb33ttvhyhlquprnbcgvpfp2p7pd4tq")
if err != nil {
log.Errorf("failed to get welcome page: %v", err)
}
}
if len(widgetTargetsToCreate) == 0 {
return
}
if err = cache.DoStateCtx(b.objectGetter, ctx, widgetObjectID, func(s *state.State, w widget.Widget) error {
if useCase == pb.RpcObjectImportUseCaseRequest_GET_STARTED && welcomePageId != "" {
if _, err = w.CreateBlock(s, &pb.RpcBlockCreateWidgetRequest{
ContextId: s.RootId(),
WidgetLayout: model.BlockContentWidget_Link,
Position: model.Block_InnerFirst,
TargetId: s.RootId(),
Block: &model.Block{
Id: "welcome",
Content: &model.BlockContentOfLink{Link: &model.BlockContentLink{
TargetBlockId: welcomePageId,
}},
},
}); err != nil {
log.Errorf("failed to add welcome page widget: %v", err)
}
}
for _, targetId := range widgetTargetsToCreate {
if err := w.AddAutoWidget(s, targetId, "", addr.ObjectTypeAllViewId, model.BlockContentWidget_View, ""); err != nil {
log.Errorf("failed to create widget block for type '%s': %v", targetId, err)