diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-12-21 16:35:01 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-12-21 16:35:01 -0500 |
commit | ba6e370ca71abacaa30234cb164427d27c86df13 (patch) | |
tree | 2379b6dab897deef1226f66772b8f05e0bb08f9c /model/channel_view.go | |
parent | 139cb52c99ac525f44a280803447bbbd88369f23 (diff) | |
download | chat-ba6e370ca71abacaa30234cb164427d27c86df13.tar.gz chat-ba6e370ca71abacaa30234cb164427d27c86df13.tar.bz2 chat-ba6e370ca71abacaa30234cb164427d27c86df13.zip |
PLT-5012 Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API (#4840)
* Combine updateLastViewedAt, setLastViewedAt and setActiveChannel into a single API
* Remove preference DB writes
Diffstat (limited to 'model/channel_view.go')
-rw-r--r-- | model/channel_view.go | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/model/channel_view.go b/model/channel_view.go new file mode 100644 index 000000000..9803c4bbc --- /dev/null +++ b/model/channel_view.go @@ -0,0 +1,35 @@ +// Copyright (c) 2016 Mattermost, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "encoding/json" + "io" +) + +type ChannelView struct { + ChannelId string `json:"channel_id"` + PrevChannelId string `json:"prev_channel_id"` + Time int64 `json:"time"` +} + +func (o *ChannelView) ToJson() string { + b, err := json.Marshal(o) + if err != nil { + return "" + } else { + return string(b) + } +} + +func ChannelViewFromJson(data io.Reader) *ChannelView { + decoder := json.NewDecoder(data) + var o ChannelView + err := decoder.Decode(&o) + if err == nil { + return &o + } else { + return nil + } +} |