fixed bugs in sync logic
All checks were successful
build and deploy kleinTodo / build (push) Successful in 17s
All checks were successful
build and deploy kleinTodo / build (push) Successful in 17s
This commit is contained in:
parent
8393ec9973
commit
deb43b98aa
@ -3,6 +3,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common"
|
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common"
|
||||||
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common/jwt"
|
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common/jwt"
|
||||||
@ -33,6 +34,9 @@ func SyncHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, clientTodo := range todoList.Todos {
|
for _, clientTodo := range todoList.Todos {
|
||||||
|
if clientTodo.LastModified.IsZero() {
|
||||||
|
clientTodo.LastModified = time.Now().UTC()
|
||||||
|
}
|
||||||
serverTodo, exists := serverTodos[clientTodo.Id]
|
serverTodo, exists := serverTodos[clientTodo.Id]
|
||||||
|
|
||||||
if !exists {
|
if !exists {
|
||||||
@ -66,6 +70,7 @@ func SyncHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
ServerTodo: serverTodo,
|
ServerTodo: serverTodo,
|
||||||
LocalTodo: clientTodo,
|
LocalTodo: clientTodo,
|
||||||
})
|
})
|
||||||
|
delete(serverTodos, clientTodo.Id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user