Преглед на файлове

Handle all errors returned by .Write()

ayntgl преди 4 години
родител
ревизия
76781ed1dd
променени са 2 файла, в които са добавени 8 реда и са изтрити 2 реда
  1. 4 1
      ui/app.go
  2. 4 1
      ui/handlers.go

+ 4 - 1
ui/app.go

@@ -93,7 +93,10 @@ func (app *App) onGuildCreate(_ *discordgo.Session, g *discordgo.GuildCreate) {
 func (app *App) onSessionMessageCreate(_ *discordgo.Session, m *discordgo.MessageCreate) {
 	if app.SelectedChannel != nil && app.SelectedChannel.ID == m.ChannelID {
 		app.SelectedChannel.Messages = append(app.SelectedChannel.Messages, m.Message)
-		app.MessagesTextView.Write(buildMessage(app, m.Message))
+		_, err := app.MessagesTextView.Write(buildMessage(app, m.Message))
+		if err != nil {
+			return
+		}
 
 		if len(app.MessagesTextView.GetHighlights()) == 0 {
 			app.MessagesTextView.ScrollToEnd()

+ 4 - 1
ui/handlers.go

@@ -150,7 +150,10 @@ func onChannelsTreeViewSelected(app *App, n *tview.TreeNode) {
 
 		for i := len(ms) - 1; i >= 0; i-- {
 			app.SelectedChannel.Messages = append(app.SelectedChannel.Messages, ms[i])
-			app.MessagesTextView.Write(buildMessage(app, ms[i]))
+			_, err = app.MessagesTextView.Write(buildMessage(app, ms[i]))
+			if err != nil {
+				return
+			}
 		}
 
 		app.MessagesTextView.ScrollToEnd()