Add colored nicks settings option

This commit is contained in:
Ken-Håvard Lieng 2018-10-15 08:56:17 +02:00
parent ec03db4db6
commit 6c6a9e12cf
27 changed files with 577 additions and 109 deletions

View file

@ -27,6 +27,8 @@ type indexData struct {
Channels []*storage.Channel
HexIP bool
Settings *storage.ClientSettings
// Users in the selected channel
Users *Userlist
@ -54,6 +56,8 @@ func getIndexData(r *http.Request, state *State) *indexData {
return &data
}
data.Settings = state.user.GetClientSettings()
servers, err := state.user.GetServers()
if err != nil {
return nil

View file

@ -99,6 +99,16 @@ func easyjson7e607aefDecodeGithubComKhliengDispatchServer(in *jlexer.Lexer, out
}
case "hexIP":
out.HexIP = bool(in.Bool())
case "settings":
if in.IsNull() {
in.Skip()
out.Settings = nil
} else {
if out.Settings == nil {
out.Settings = new(storage.ClientSettings)
}
easyjson7e607aefDecodeGithubComKhliengDispatchStorage1(in, &*out.Settings)
}
case "users":
if in.IsNull() {
in.Skip()
@ -199,6 +209,16 @@ func easyjson7e607aefEncodeGithubComKhliengDispatchServer(out *jwriter.Writer, i
}
out.Bool(bool(in.HexIP))
}
if in.Settings != nil {
const prefix string = ",\"settings\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
easyjson7e607aefEncodeGithubComKhliengDispatchStorage1(out, *in.Settings)
}
if in.Users != nil {
const prefix string = ",\"users\":"
if first {
@ -245,6 +265,53 @@ func (v *indexData) UnmarshalJSON(data []byte) error {
func (v *indexData) UnmarshalEasyJSON(l *jlexer.Lexer) {
easyjson7e607aefDecodeGithubComKhliengDispatchServer(l, v)
}
func easyjson7e607aefDecodeGithubComKhliengDispatchStorage1(in *jlexer.Lexer, out *storage.ClientSettings) {
isTopLevel := in.IsStart()
if in.IsNull() {
if isTopLevel {
in.Consumed()
}
in.Skip()
return
}
in.Delim('{')
for !in.IsDelim('}') {
key := in.UnsafeString()
in.WantColon()
if in.IsNull() {
in.Skip()
in.WantComma()
continue
}
switch key {
case "coloredNicks":
out.ColoredNicks = bool(in.Bool())
default:
in.SkipRecursive()
}
in.WantComma()
}
in.Delim('}')
if isTopLevel {
in.Consumed()
}
}
func easyjson7e607aefEncodeGithubComKhliengDispatchStorage1(out *jwriter.Writer, in storage.ClientSettings) {
out.RawByte('{')
first := true
_ = first
if in.ColoredNicks {
const prefix string = ",\"coloredNicks\":"
if first {
first = false
out.RawString(prefix[1:])
} else {
out.RawString(prefix)
}
out.Bool(bool(in.ColoredNicks))
}
out.RawByte('}')
}
func easyjson7e607aefDecodeGithubComKhliengDispatchStorage(in *jlexer.Lexer, out *storage.Channel) {
isTopLevel := in.IsStart()
if in.IsNull() {

View file

@ -274,6 +274,13 @@ func (h *wsHandler) setServerName(b []byte) {
}
}
func (h *wsHandler) setSettings(b []byte) {
err := h.state.user.UnmarshalClientSettingsJSON(b)
if err != nil {
log.Println(err)
}
}
func (h *wsHandler) initHandlers() {
h.handlers = map[string]func([]byte){
"connect": h.connect,
@ -293,6 +300,7 @@ func (h *wsHandler) initHandlers() {
"cert": h.cert,
"fetch_messages": h.fetchMessages,
"set_server_name": h.setServerName,
"settings_set": h.setSettings,
}
}