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:
@ -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 {
|
||||
|
Reference in New Issue
Block a user