Skip to content

Commit cdc0d0b

Browse files
joshblummmaxim
authored andcommitted
utils.NullChatUI (keybase#20015)
1 parent 4b0d64f commit cdc0d0b

5 files changed

Lines changed: 81 additions & 52 deletions

File tree

‎go/chat/bots/commands.go‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,11 @@ func (b *CachingBotCommandManager) UpdateCommands(ctx context.Context, convID ch
253253
})
254254
}
255255

256-
type nullChatUI struct {
257-
libkb.ChatUI
258-
}
259-
260-
func (n nullChatUI) ChatBotCommandsUpdateStatus(ctx context.Context, convID chat1.ConversationID,
261-
status chat1.UIBotCommandsUpdateStatus) error {
262-
return nil
263-
}
264-
265256
func (b *CachingBotCommandManager) getChatUI(ctx context.Context) libkb.ChatUI {
266257
ui, err := b.G().UIRouter.GetChatUI()
267258
if err != nil || ui == nil {
268259
b.Debug(ctx, "getChatUI: no chat UI found: err: %s", err)
269-
return nullChatUI{}
260+
return utils.NullChatUI{}
270261
}
271262
return ui
272263
}

‎go/chat/commands/base.go‎

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,6 @@ import (
1212
"github.com/keybase/client/go/protocol/gregor1"
1313
)
1414

15-
type nullChatUI struct {
16-
libkb.ChatUI
17-
}
18-
19-
func (n nullChatUI) ChatCommandStatus(context.Context, chat1.ConversationID, string,
20-
chat1.UICommandStatusDisplayTyp, []chat1.UICommandStatusActionTyp) error {
21-
return nil
22-
}
23-
24-
func (n nullChatUI) ChatCommandMarkdown(context.Context, chat1.ConversationID, *chat1.UICommandMarkdown) error {
25-
return nil
26-
}
27-
2815
type baseCommand struct {
2916
globals.Contextified
3017
utils.DebugLabeler
@@ -70,7 +57,7 @@ func (b *baseCommand) getChatUI() libkb.ChatUI {
7057
ui, err := b.G().UIRouter.GetChatUI()
7158
if err != nil || ui == nil {
7259
b.Debug(context.Background(), "getChatUI: no chat UI found: err: %s", err)
73-
return nullChatUI{}
60+
return utils.NullChatUI{}
7461
}
7562
return ui
7663
}

‎go/chat/commands/giphy.go‎

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,6 @@ func (s *Giphy) Execute(ctx context.Context, uid gregor1.UID, convID chat1.Conve
8484
return err
8585
}
8686

87-
func (n nullChatUI) ChatGiphySearchResults(ctx context.Context, convID chat1.ConversationID,
88-
results chat1.GiphySearchResults) error {
89-
return nil
90-
}
91-
92-
func (n nullChatUI) ChatGiphyToggleResultWindow(ctx context.Context, convID chat1.ConversationID,
93-
show, clearInput bool) error {
94-
return nil
95-
}
96-
9787
func (s *Giphy) queryEqual(query *string, shown *string) bool {
9888
if query == nil && shown == nil {
9989
return true

‎go/chat/maps/livelocation.go‎

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -112,28 +112,11 @@ func (l *LiveLocationTracker) restoreLocked(ctx context.Context) {
112112
}
113113
}
114114

115-
type nullChatUI struct {
116-
libkb.ChatUI
117-
}
118-
119-
func (n nullChatUI) ChatWatchPosition(context.Context, chat1.ConversationID, chat1.UIWatchPositionPerm) (chat1.LocationWatchID, error) {
120-
return chat1.LocationWatchID(0), errors.New("no chat UI")
121-
}
122-
123-
func (n nullChatUI) ChatClearWatch(context.Context, chat1.LocationWatchID) error {
124-
return nil
125-
}
126-
127-
func (n nullChatUI) ChatCommandStatus(context.Context, chat1.ConversationID, string,
128-
chat1.UICommandStatusDisplayTyp, []chat1.UICommandStatusActionTyp) error {
129-
return nil
130-
}
131-
132115
func (l *LiveLocationTracker) getChatUI(ctx context.Context) libkb.ChatUI {
133116
ui, err := l.G().UIRouter.GetChatUI()
134117
if err != nil || ui == nil {
135118
l.Debug(ctx, "getChatUI: no chat UI found: err: %s", err)
136-
return nullChatUI{}
119+
return utils.NullChatUI{}
137120
}
138121
return ui
139122
}

‎go/chat/utils/null_chat_ui.go‎

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
package utils
2+
3+
import (
4+
"github.com/keybase/client/go/libkb"
5+
"github.com/keybase/client/go/protocol/chat1"
6+
"github.com/keybase/client/go/protocol/keybase1"
7+
"golang.org/x/net/context"
8+
)
9+
10+
type NullChatUI struct{}
11+
12+
var _ libkb.ChatUI = (*NullChatUI)(nil)
13+
14+
func (u NullChatUI) ChatAttachmentDownloadStart(context.Context) error { return nil }
15+
func (u NullChatUI) ChatAttachmentDownloadProgress(context.Context, chat1.ChatAttachmentDownloadProgressArg) error {
16+
return nil
17+
}
18+
func (u NullChatUI) ChatAttachmentDownloadDone(context.Context) error { return nil }
19+
func (u NullChatUI) ChatInboxUnverified(context.Context, chat1.ChatInboxUnverifiedArg) error {
20+
return nil
21+
}
22+
func (u NullChatUI) ChatInboxConversation(context.Context, chat1.ChatInboxConversationArg) error {
23+
return nil
24+
}
25+
func (u NullChatUI) ChatInboxFailed(context.Context, chat1.ChatInboxFailedArg) error { return nil }
26+
func (u NullChatUI) ChatThreadCached(context.Context, *string) error { return nil }
27+
func (u NullChatUI) ChatThreadFull(context.Context, string) error { return nil }
28+
func (u NullChatUI) ChatThreadStatus(context.Context, chat1.UIChatThreadStatus) error { return nil }
29+
func (u NullChatUI) ChatConfirmChannelDelete(context.Context, chat1.ChatConfirmChannelDeleteArg) (bool, error) {
30+
return false, nil
31+
}
32+
func (u NullChatUI) ChatSearchHit(context.Context, chat1.ChatSearchHitArg) error { return nil }
33+
func (u NullChatUI) ChatSearchDone(context.Context, chat1.ChatSearchDoneArg) error { return nil }
34+
func (u NullChatUI) ChatSearchInboxHit(context.Context, chat1.ChatSearchInboxHitArg) error { return nil }
35+
func (u NullChatUI) ChatSearchInboxStart(context.Context) error { return nil }
36+
func (u NullChatUI) ChatSearchInboxDone(context.Context, chat1.ChatSearchInboxDoneArg) error {
37+
return nil
38+
}
39+
func (u NullChatUI) ChatSearchIndexStatus(context.Context, chat1.ChatSearchIndexStatusArg) error {
40+
return nil
41+
}
42+
func (u NullChatUI) ChatSearchConvHits(context.Context, chat1.UIChatSearchConvHits) error { return nil }
43+
func (u NullChatUI) ChatStellarShowConfirm(context.Context) error { return nil }
44+
func (u NullChatUI) ChatStellarDataConfirm(context.Context, chat1.UIChatPaymentSummary) (bool, error) {
45+
return false, nil
46+
}
47+
func (u NullChatUI) ChatStellarDataError(context.Context, keybase1.Status) (bool, error) {
48+
return false, nil
49+
}
50+
func (u NullChatUI) ChatStellarDone(context.Context, bool) error { return nil }
51+
func (u NullChatUI) ChatGiphySearchResults(ctx context.Context, convID chat1.ConversationID,
52+
results chat1.GiphySearchResults) error {
53+
return nil
54+
}
55+
func (u NullChatUI) ChatGiphyToggleResultWindow(ctx context.Context, convID chat1.ConversationID, show, clearInput bool) error {
56+
return nil
57+
}
58+
func (u NullChatUI) ChatShowManageChannels(context.Context, string) error { return nil }
59+
func (u NullChatUI) ChatCoinFlipStatus(context.Context, []chat1.UICoinFlipStatus) error { return nil }
60+
func (u NullChatUI) ChatCommandMarkdown(context.Context, chat1.ConversationID, *chat1.UICommandMarkdown) error {
61+
return nil
62+
}
63+
func (u NullChatUI) ChatMaybeMentionUpdate(context.Context, string, string, chat1.UIMaybeMentionInfo) error {
64+
return nil
65+
}
66+
func (u NullChatUI) ChatLoadGalleryHit(context.Context, chat1.UIMessage) error { return nil }
67+
func (u NullChatUI) ChatWatchPosition(context.Context, chat1.ConversationID, chat1.UIWatchPositionPerm) (chat1.LocationWatchID, error) {
68+
return 0, nil
69+
}
70+
func (u NullChatUI) ChatClearWatch(context.Context, chat1.LocationWatchID) error { return nil }
71+
func (u NullChatUI) ChatCommandStatus(context.Context, chat1.ConversationID, string, chat1.UICommandStatusDisplayTyp,
72+
[]chat1.UICommandStatusActionTyp) error {
73+
return nil
74+
}
75+
func (u NullChatUI) ChatBotCommandsUpdateStatus(context.Context, chat1.ConversationID, chat1.UIBotCommandsUpdateStatus) error {
76+
return nil
77+
}
78+
func (u NullChatUI) TriggerContactSync(context.Context) error { return nil }

0 commit comments

Comments
 (0)