Adjust things in timestamp toggle

This commit is contained in:
Tulir Asokan 2021-09-19 20:59:59 -04:00
parent 57d0c8db5f
commit 2cff2cdc22
3 changed files with 17 additions and 19 deletions

View File

@ -43,7 +43,7 @@ type AuthCache struct {
type UserPreferences struct { type UserPreferences struct {
HideUserList bool `yaml:"hide_user_list"` HideUserList bool `yaml:"hide_user_list"`
HideRoomList bool `yaml:"hide_room_list"` HideRoomList bool `yaml:"hide_room_list"`
HideTimeStamp bool `yaml:"hide_time_stamp"` HideTimestamp bool `yaml:"hide_timestamp"`
BareMessageView bool `yaml:"bare_message_view"` BareMessageView bool `yaml:"bare_message_view"`
DisableImages bool `yaml:"disable_images"` DisableImages bool `yaml:"disable_images"`
DisableTypingNotifs bool `yaml:"disable_typing_notifs"` DisableTypingNotifs bool `yaml:"disable_typing_notifs"`

View File

@ -703,7 +703,7 @@ func (nkm NewlineKeybindMessage) Name() string {
var toggleMsg = map[string]ToggleMessage{ var toggleMsg = map[string]ToggleMessage{
"rooms": HideMessage("Room list sidebar"), "rooms": HideMessage("Room list sidebar"),
"users": HideMessage("User list sidebar"), "users": HideMessage("User list sidebar"),
"timestamp": HideMessage("Message timestamp"), "timestamps": HideMessage("message timestamps"),
"baremessages": SimpleToggleMessage("bare message view"), "baremessages": SimpleToggleMessage("bare message view"),
"images": SimpleToggleMessage("image rendering"), "images": SimpleToggleMessage("image rendering"),
"typingnotif": SimpleToggleMessage("typing notifications"), "typingnotif": SimpleToggleMessage("typing notifications"),
@ -739,8 +739,8 @@ func cmdToggle(cmd *Command) {
val = &cmd.Config.Preferences.HideRoomList val = &cmd.Config.Preferences.HideRoomList
case "users": case "users":
val = &cmd.Config.Preferences.HideUserList val = &cmd.Config.Preferences.HideUserList
case "timestamp": case "timestamps":
val = &cmd.Config.Preferences.HideTimeStamp val = &cmd.Config.Preferences.HideTimestamp
case "baremessages": case "baremessages":
val = &cmd.Config.Preferences.BareMessageView val = &cmd.Config.Preferences.BareMessageView
case "images": case "images":

View File

@ -160,10 +160,9 @@ func (view *MessageView) AddMessage(ifcMessage ifc.Message, direction MessageDir
width := view.width() width := view.width()
bare := view.config.Preferences.BareMessageView bare := view.config.Preferences.BareMessageView
if !bare { if !bare {
if view.config.Preferences.HideTimeStamp { width -= view.widestSender() + SenderMessageGap
width -= TimestampSenderGap + view.widestSender() + SenderMessageGap if !view.config.Preferences.HideTimestamp {
} else { width -= view.TimestampWidth + TimestampSenderGap
width -= view.TimestampWidth + TimestampSenderGap + view.widestSender() + SenderMessageGap
} }
} }
message.CalculateBuffer(view.config.Preferences, width) message.CalculateBuffer(view.config.Preferences, width)
@ -327,10 +326,9 @@ func (view *MessageView) recalculateBuffers() {
if recalculateMessageBuffers || len(view.messages) != view.prevMsgCount { if recalculateMessageBuffers || len(view.messages) != view.prevMsgCount {
width := view.width() width := view.width()
if !prefs.BareMessageView { if !prefs.BareMessageView {
if prefs.HideTimeStamp { width -= view.widestSender() + SenderMessageGap
width -= TimestampSenderGap + view.widestSender() + SenderMessageGap if !prefs.HideTimestamp {
} else { width -= view.TimestampWidth + TimestampSenderGap
width -= view.TimestampWidth + TimestampSenderGap + view.widestSender() + SenderMessageGap
} }
} }
view.msgBuffer = []*messages.UIMessage{} view.msgBuffer = []*messages.UIMessage{}
@ -443,9 +441,9 @@ func (view *MessageView) OnMouseEvent(event mauview.MouseEvent) bool {
} }
view.msgBufferLock.RUnlock() view.msgBufferLock.RUnlock()
usernameX := view.TimestampWidth + TimestampSenderGap usernameX := 0
if !view.config.Preferences.HideTimeStamp { if !view.config.Preferences.HideTimestamp {
usernameX = TimestampSenderGap usernameX += view.TimestampWidth + TimestampSenderGap
} }
messageX := usernameX + view.widestSender() + SenderMessageGap messageX := usernameX + view.widestSender() + SenderMessageGap
@ -612,9 +610,9 @@ func (view *MessageView) Draw(screen mauview.Screen) {
return return
} }
usernameX := view.TimestampWidth + TimestampSenderGap usernameX := 0
if view.config.Preferences.HideTimeStamp { if !view.config.Preferences.HideTimestamp {
usernameX = TimestampSenderGap usernameX += view.TimestampWidth + TimestampSenderGap
} }
messageX := usernameX + view.widestSender() + SenderMessageGap messageX := usernameX + view.widestSender() + SenderMessageGap
@ -657,7 +655,7 @@ func (view *MessageView) Draw(screen mauview.Screen) {
continue continue
} }
if len(msg.FormatTime()) > 0 && !view.config.Preferences.HideTimeStamp { if len(msg.FormatTime()) > 0 && !view.config.Preferences.HideTimestamp {
widget.WriteLineSimpleColor(screen, msg.FormatTime(), 0, line, msg.TimestampColor()) widget.WriteLineSimpleColor(screen, msg.FormatTime(), 0, line, msg.TimestampColor())
} }
// TODO hiding senders might not be that nice after all, maybe an option? (disabled for now) // TODO hiding senders might not be that nice after all, maybe an option? (disabled for now)