@@ -892,6 +892,15 @@ func (sb *smartBlock) injectLinksDetails(s *state.State) {
892
892
}
893
893
894
894
func (sb * smartBlock ) injectLocalDetails (s * state.State ) error {
895
+ if pbtypes .GetString (s .LocalDetails (), bundle .RelationKeyWorkspaceId .String ()) == "" {
896
+ wsId , err := sb .coreService .GetWorkspaceIdForObject (sb .Id ())
897
+ if wsId != "" {
898
+ s .SetDetailAndBundledRelation (bundle .RelationKeyWorkspaceId , pbtypes .String (wsId ))
899
+ } else {
900
+ log .With ("objectID" , sb .Id ()).Errorf ("injectLocalDetails empty workspace: %v" , err )
901
+ }
902
+ }
903
+
895
904
if sb .objectStore == nil {
896
905
return nil
897
906
}
@@ -943,15 +952,11 @@ func (sb *smartBlock) injectLocalDetails(s *state.State) error {
943
952
s .SetDetailAndBundledRelation (bundle .RelationKeyCreator , pbtypes .String (creator ))
944
953
}
945
954
946
- s .SetDetailAndBundledRelation (bundle .RelationKeyCreatedDate , pbtypes .Float64 (float64 (createdDate )))
947
- }
948
-
949
- if pbtypes .GetString (s .LocalDetails (), bundle .RelationKeyWorkspaceId .String ()) == "" {
950
- wsId , _ := sb .coreService .GetWorkspaceIdForObject (sb .Id ())
951
- if wsId != "" {
952
- s .SetDetailAndBundledRelation (bundle .RelationKeyWorkspaceId , pbtypes .String (wsId ))
955
+ if createdDate != 0 {
956
+ s .SetDetailAndBundledRelation (bundle .RelationKeyCreatedDate , pbtypes .Float64 (float64 (createdDate )))
953
957
}
954
958
}
959
+
955
960
return nil
956
961
}
957
962
@@ -1022,6 +1027,10 @@ func (sb *smartBlock) StateRebuild(d state.Doc) (err error) {
1022
1027
return ErrIsDeleted
1023
1028
}
1024
1029
d .(* state.State ).InjectDerivedDetails ()
1030
+ err = sb .injectLocalDetails (d .(* state.State ))
1031
+ if err != nil {
1032
+ log .Errorf ("failed to inject local details in StateRebuild: %v" , err )
1033
+ }
1025
1034
d .(* state.State ).SetParent (sb .Doc .(* state.State ))
1026
1035
// todo: make store diff
1027
1036
sb .execHooks (HookBeforeApply , ApplyInfo {State : d .(* state.State )})
0 commit comments