fix(ui/chat): display names of all attached files (#706)
This commit is contained in:
parent
eebe22e939
commit
8723e87682
2 changed files with 23 additions and 1 deletions
|
|
@ -658,5 +658,10 @@ func (mi *messageInput) openFilePicker() {
|
|||
|
||||
func (mi *messageInput) attach(name string, reader io.Reader) {
|
||||
mi.sendMessageData.Files = append(mi.sendMessageData.Files, sendpart.File{Name: name, Reader: reader})
|
||||
mi.SetFooter("Attached " + name)
|
||||
|
||||
var names []string
|
||||
for _, file := range mi.sendMessageData.Files {
|
||||
names = append(names, file.Name)
|
||||
}
|
||||
mi.SetFooter("Attached " + humanJoin(names))
|
||||
}
|
||||
|
|
|
|||
17
internal/ui/chat/util.go
Normal file
17
internal/ui/chat/util.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package chat
|
||||
|
||||
import "strings"
|
||||
|
||||
func humanJoin(items []string) string {
|
||||
count := len(items)
|
||||
switch count {
|
||||
case 0:
|
||||
return ""
|
||||
case 1:
|
||||
return items[0]
|
||||
case 2:
|
||||
return items[0] + " and " + items[1]
|
||||
default:
|
||||
return strings.Join(items[:count-1], ", ") + ", and " + items[count-1]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue