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

GO-5279 New welcome page

This commit is contained in:
kirillston 2025-04-03 17:19:50 +03:00
parent 05e5843426
commit 3349007072
No known key found for this signature in database
GPG key ID: BE4BF014F0ECDFE8
4 changed files with 31 additions and 1 deletions

View file

@ -400,10 +400,36 @@ 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)