Fixed timezone bug and timestamp bug

This commit is contained in:
diamondburned (Forefront) 2020-06-28 19:55:13 -07:00
parent 5ac2567610
commit 0d2c1d5e8f
7 changed files with 16 additions and 8 deletions

4
go.mod
View File

@ -4,13 +4,11 @@ go 1.14
replace github.com/gotk3/gotk3 => github.com/diamondburned/gotk3 v0.0.0-20200619213419-0533bcce0dd6
replace github.com/diamondburned/cchat-discord => ../cchat-discord/
require (
github.com/Xuanwo/go-locale v0.2.0
github.com/alecthomas/chroma v0.7.3
github.com/diamondburned/cchat v0.0.35
github.com/diamondburned/cchat-discord v0.0.0-20200619222738-e5babcbb42e3
github.com/diamondburned/cchat-discord v0.0.0-20200629023132-0a66a65fcf27
github.com/diamondburned/cchat-mock v0.0.0-20200628063912-3155c1b6d6a9
github.com/diamondburned/imgutil v0.0.0-20200611215339-650ac7cfaf64
github.com/goodsign/monday v1.0.0

2
go.sum
View File

@ -53,6 +53,8 @@ github.com/diamondburned/cchat v0.0.35 h1:WiMGl8BQJgbP9E4xRxgLGlqUsHpTcJgDKDt8/6
github.com/diamondburned/cchat v0.0.35/go.mod h1:+zXktogE45A0om4fT6B/z6Ii7FXNafjxsNspI0rlhbU=
github.com/diamondburned/cchat-discord v0.0.0-20200619222738-e5babcbb42e3 h1:8RCcaY3gtA+8NG2mwkcC/PIFK+eS8XnGyeVaUbCXbF0=
github.com/diamondburned/cchat-discord v0.0.0-20200619222738-e5babcbb42e3/go.mod h1:4q0jHEl1gJEzkS92oacwcSf9+3fFcNPukOpURDJpV/A=
github.com/diamondburned/cchat-discord v0.0.0-20200629023132-0a66a65fcf27 h1:MAWs83jAZKxkU04RAoaewc1xUrLKlB6F5X1ViFRkWdw=
github.com/diamondburned/cchat-discord v0.0.0-20200629023132-0a66a65fcf27/go.mod h1:af673uNyL2NSjYqJ54DotPV/iNY+OvBcQfDqHefbap4=
github.com/diamondburned/cchat-mock v0.0.0-20200615015702-8cac8b16378d h1:LkzARyvdGRvAsaKEPTV3XcqMHENH6J+KRAI+3sq41Qs=
github.com/diamondburned/cchat-mock v0.0.0-20200615015702-8cac8b16378d/go.mod h1:SVTt5je4G+re8aSVJAFk/x8vvbRzXdpKgSKmVGoM1tg=
github.com/diamondburned/cchat-mock v0.0.0-20200620231423-b286a0301190 h1:mHbA/xhL584IToD38m3QkeU1cRWIPzBZCDFi1Wv0Bz4=

View File

@ -39,14 +39,16 @@ func TimeAgoLong(t time.Time) string {
}
func TimeAgoShort(t time.Time) string {
t = t.Local()
return monday.Format(t, "15:04", Locale)
}
func timeAgo(t time.Time, truncs []truncator) string {
t = t.Local()
ensureLocale()
trunc := t
now := time.Now()
now := time.Now().Local()
for _, truncator := range truncs {
trunc = trunc.Truncate(truncator.d)

View File

@ -4,6 +4,7 @@ import (
"github.com/diamondburned/cchat-gtk/internal/gts"
"github.com/diamondburned/cchat-gtk/internal/log"
"github.com/diamondburned/cchat-gtk/internal/ui/config"
"github.com/diamondburned/cchat-gtk/internal/ui/primitives"
"github.com/gotk3/gotk3/gtk"
"github.com/pkg/errors"
)
@ -64,6 +65,9 @@ func Section(entries []config.Entry) *gtk.Grid {
grid.SetRowSpacing(4)
grid.SetColumnSpacing(8)
grid.Show()
primitives.AddClass(grid, "config")
return grid
}

View File

@ -21,7 +21,6 @@ type CollapsedMessage struct {
func NewCollapsedMessage(msg cchat.MessageCreate) *CollapsedMessage {
msgc := WrapCollapsedMessage(message.NewContainer(msg))
msgc.Timestamp.SetXAlign(0.5) // middle align
message.FillContainer(msgc, msg)
return msgc
}
@ -30,6 +29,7 @@ func WrapCollapsedMessage(gc *message.GenericContainer) *CollapsedMessage {
// Set Timestamp's padding accordingly to Avatar's.
gc.Timestamp.SetSizeRequest(AvatarSize, -1)
gc.Timestamp.SetVAlign(gtk.ALIGN_START)
gc.Timestamp.SetXAlign(0.5) // middle align
gc.Timestamp.SetMarginStart(container.ColumnSpacing * 2)
// Set Content's padding accordingly to FullMessage's main box.
@ -61,15 +61,15 @@ func (c *CollapsedMessage) Attach(grid *gtk.Grid, row int) {
}
type CollapsedSendingMessage struct {
*CollapsedMessage
message.PresendContainer
CollapsedMessage
}
func NewCollapsedSendingMessage(msg input.PresendMessage) *CollapsedSendingMessage {
var msgc = message.NewPresendContainer(msg)
return &CollapsedSendingMessage{
CollapsedMessage: WrapCollapsedMessage(msgc.GenericContainer),
PresendContainer: msgc,
CollapsedMessage: *WrapCollapsedMessage(msgc.GenericContainer),
}
}

View File

@ -56,7 +56,7 @@ func (f *Field) sendInput() {
}
f.SendMessage(SendMessageData{
time: time.Now(),
time: time.Now().UTC(),
content: text,
author: f.username.GetLabel(),
authorID: f.UserID,

View File

@ -75,6 +75,8 @@ func newContainer(conf map[string]string, apply func() error) *container {
grid.SetColumnSpacing(8)
grid.Show()
primitives.AddClass(grid, "config")
return cc
}