1
0
mirror of https://github.com/schollz/cowyo.git synced 2023-08-10 21:13:00 +03:00

Storing DIffs now...might not be compatible?

This commit is contained in:
Zack Scholl
2016-02-07 18:31:47 -05:00
parent 2134f25d3a
commit 965989530c
7 changed files with 80 additions and 31 deletions

View File

@ -4,7 +4,6 @@ import (
"encoding/json"
"fmt"
"net/http"
"strings"
"github.com/gorilla/websocket"
)
@ -40,21 +39,24 @@ func wshandler(w http.ResponseWriter, r *http.Request) {
panic(err)
}
var p CowyoData
err = p.load(m.Title)
fmt.Println("LOADED")
fmt.Println(p)
if err != nil {
panic(err)
}
if m.UpdateServer {
p := CowyoData{strings.ToLower(m.Title), m.TextData}
err := p.save()
err := p.save(m.TextData)
fmt.Println("SAVED")
fmt.Println(p)
if err != nil {
panic(err)
}
}
if m.UpdateClient {
p := CowyoData{strings.ToLower(m.Title), ""}
err := p.load()
if err != nil {
panic(err)
}
m.UpdateClient = len(m.TextData) != len(p.Text)
m.TextData = p.Text
m.UpdateClient = len(m.TextData) != len(p.CurrentText)
m.TextData = p.CurrentText
}
newMsg, err := json.Marshal(m)
if err != nil {