feat: message timestamps

* made it easier to styles and prefix messages
* added timestamps to messages
* added prefix and styles to server messages
* append current date to host channel
* fixed some styles issues
This commit is contained in:
2022-02-19 16:24:39 +02:00
parent 6c538cc352
commit f4dd0066c8
11 changed files with 222 additions and 51 deletions
+5 -1
View File
@@ -90,7 +90,11 @@ func (s State) Update(msg tea.Msg) (State, tea.Cmd) {
} else {
if s.Client.ActiveChannel != s.Client.Host {
fullMsg := s.Client.Nickname + ": " + msg.Msg
s.Client.Channels[s.Client.ActiveChannelIndex].History += fullMsg + irc.CRLF
msgOpts := irc.MsgFmtOpts{
WithTimestamp: true,
}
s.Client.Channels[s.Client.ActiveChannelIndex].AppendMsg(msg.Timestamp, fullMsg, msgOpts)
// TODO: make sure to only append the message to the history if server sends back no errors
s.Client.SendCommand(commands.PRIVMSG, s.Client.ActiveChannel, msg.Msg)
s.Viewport.SetContent(s.Client.Channels[s.Client.ActiveChannelIndex].History)
+3 -3
View File
@@ -22,16 +22,16 @@ import (
)
var (
InputboxStyle = lipgloss.NewStyle().
InputboxStyle = ui.DefaultStyle.Copy().
Border(lipgloss.NormalBorder(), true).
Padding(0, 1).
Width(ui.MainStyle.GetWidth()).
BorderForeground(ui.AccentColor)
MessagesStyle = lipgloss.NewStyle().
MessagesStyle = ui.DefaultStyle.Copy().
Border(lipgloss.NormalBorder(), false, true, true, true).
Width(ui.MainStyle.GetWidth() * 8 / 10).
BorderForeground(ui.PrimaryColor)
SidePanelStyle = lipgloss.NewStyle().
SidePanelStyle = ui.DefaultStyle.Copy().
Border(lipgloss.NormalBorder(), true).
Width(ui.MainStyle.GetWidth() * 2 / 10).
BorderForeground(ui.PrimaryColor)