Skip to content

Commit 5655954

Browse files
committed
wip
1 parent 0d078a3 commit 5655954

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

db/document.go

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ func (doc *Document) updateChannels(ctx context.Context, newChannels base.Set) (
987987
doc.updateChannelHistory(channel, doc.Sequence, true)
988988
}
989989
}
990+
doc.currentRevChannels = newChannels
990991
if changed != nil {
991992
base.InfofCtx(ctx, base.KeyCRUD, "\tDoc %q / %q in channels %q", base.UD(doc.ID), doc.CurrentRev, base.UD(newChannels))
992993
changedChannels, err = channels.SetFromArray(changed, channels.KeepStar)
@@ -1093,13 +1094,15 @@ func (doc *Document) UnmarshalJSON(data []byte) error {
10931094
}
10941095

10951096
// determine current revision's channels and store in-memory (avoids doc.Channels iteration at access-check time)
1096-
ch := base.SetOf()
1097-
for channelName, channelRemoval := range doc.Channels {
1098-
if channelRemoval == nil || channelRemoval.Seq == 0 {
1099-
ch.Add(channelName)
1097+
if len(doc.Channels) > 0 {
1098+
ch := base.SetOf()
1099+
for channelName, channelRemoval := range doc.Channels {
1100+
if channelRemoval == nil || channelRemoval.Seq == 0 {
1101+
ch.Add(channelName)
1102+
}
11001103
}
1104+
doc.currentRevChannels = ch
11011105
}
1102-
doc.currentRevChannels = ch
11031106

11041107
// Unmarshal the rest of the doc body as map[string]interface{}
11051108
if err := doc._body.Unmarshal(data); err != nil {

0 commit comments

Comments
 (0)