1
0
Fork 0
mirror of https://github.com/anyproto/anytype-heart.git synced 2025-06-08 05:47:07 +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

@ -116,6 +116,10 @@ func validateDetails(s *pb.SnapshotWithType, info *useCaseInfo) (err error) {
continue
}
if k == bundle.RelationKeyAutoWidgetTargets.String() && val == "bin" {
continue
}
_, found := info.objects[val]
if !found {
if isBrokenTemplate(k, val) {

View file

@ -55,7 +55,7 @@ func (w *WidgetObject) Init(ctx *smartblock.InitContext) (err error) {
func (w *WidgetObject) CreationStateMigration(ctx *smartblock.InitContext) migration.Migration {
return migration.Migration{
Version: 2,
Version: 3,
Proc: func(st *state.State) {
// we purposefully do not add the ALl Objects widget here(as in migration3), because for new users we don't want to auto-create it
template.InitTemplate(st,

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)