github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/chat/commands/collapse.go (about) 1 package commands 2 3 import ( 4 "context" 5 6 "github.com/keybase/client/go/chat/globals" 7 "github.com/keybase/client/go/chat/utils" 8 "github.com/keybase/client/go/protocol/chat1" 9 "github.com/keybase/client/go/protocol/gregor1" 10 ) 11 12 type Collapse struct { 13 *baseCommand 14 } 15 16 func NewCollapse(g *globals.Context) *Collapse { 17 return &Collapse{ 18 baseCommand: newBaseCommand(g, "collapse", "", "Collapse all inline previews", false), 19 } 20 } 21 22 func (h *Collapse) Execute(ctx context.Context, uid gregor1.UID, convID chat1.ConversationID, 23 tlfName, text string, replyTo *chat1.MessageID) (err error) { 24 defer h.Trace(ctx, &err, "Collapse")() 25 if !h.Match(ctx, text) { 26 return ErrInvalidCommand 27 } 28 conv, err := getConvByID(ctx, h.G(), uid, convID) 29 if err != nil { 30 return err 31 } 32 maxMsgID := conv.Conv.ReaderInfo.MaxMsgid 33 if err := utils.NewCollapses(h.G()).ToggleRange(ctx, uid, convID, maxMsgID, true); err != nil { 34 return err 35 } 36 h.G().ActivityNotifier.ThreadsStale(ctx, uid, []chat1.ConversationStaleUpdate{ 37 { 38 ConvID: convID, 39 UpdateType: chat1.StaleUpdateType_NEWACTIVITY, 40 }, 41 }) 42 return nil 43 }