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 (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common"
|
||||
"gitea.kleinsense.nl/DariusKlein/kleinTodo/common/jwt"
|
||||
@ -33,6 +34,9 @@ func SyncHandler(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
for _, clientTodo := range todoList.Todos {
|
||||
if clientTodo.LastModified.IsZero() {
|
||||
clientTodo.LastModified = time.Now().UTC()
|
||||
}
|
||||
serverTodo, exists := serverTodos[clientTodo.Id]
|
||||
|
||||
if !exists {
|
||||
@ -66,6 +70,7 @@ func SyncHandler(w http.ResponseWriter, r *http.Request) {
|
||||
ServerTodo: serverTodo,
|
||||
LocalTodo: clientTodo,
|
||||
})
|
||||
delete(serverTodos, clientTodo.Id)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user