WIP create change continue
This commit is contained in:
parent
2f66bd3e9c
commit
8f704e6de0
@ -15,6 +15,7 @@ type AccountData struct {
|
||||
}
|
||||
|
||||
type Document struct {
|
||||
// TODO: ensure that every operation on Document is synchronized
|
||||
thread threadmodels.Thread
|
||||
stateProvider InitialStateProvider
|
||||
accountData *AccountData
|
||||
@ -99,6 +100,14 @@ func (d *Document) Create(payload *CreateChangePayload) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if aclChange.AclData != nil {
|
||||
// we can apply change right away without going through builder, because
|
||||
err = d.docContext.aclState.ApplyChange(payload.Id, aclChange)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
d.docContext.fullTree.AddFast(ch)
|
||||
|
||||
err = d.thread.AddChange(&threadmodels.RawChange{
|
||||
@ -157,6 +166,7 @@ func (d *Document) Update(changes ...*threadmodels.RawChange) (DocumentState, Up
|
||||
break
|
||||
}
|
||||
|
||||
// TODO: we should still check if the user making those changes are able to write using "aclState"
|
||||
// decrypting everything, because we have no new keys
|
||||
for _, ch := range treeChanges {
|
||||
if ch.Content.GetChangesData() != nil {
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package data
|
||||
|
||||
type documentContext struct {
|
||||
aclTree *Tree
|
||||
aclTree *Tree // TODO: remove it, because we don't use it
|
||||
fullTree *Tree
|
||||
aclState *ACLState
|
||||
docState DocumentState
|
||||
|
||||
@ -66,6 +66,7 @@ func (d *documentStateBuilder) build() (s DocumentState, err error) {
|
||||
func (d *documentStateBuilder) appendFrom(fromId string, init DocumentState) (s DocumentState, err error) {
|
||||
// TODO: we should do something like state copy probably
|
||||
s = init
|
||||
// TODO: we should have the same logic as in ACLStateBuilder, that means we should either pass in both methods state from the outside or save the state inside the builder
|
||||
d.tree.Iterate(fromId, func(c *Change) (isContinue bool) {
|
||||
if c.Id == fromId {
|
||||
return true
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user