Enha: use of db methods
This commit is contained in:
		| @@ -42,17 +42,20 @@ func HandleCreateRoom(w http.ResponseWriter, r *http.Request) { | ||||
| 	} | ||||
| 	fi.State.RoomID = room.ID | ||||
| 	fi.Room = room | ||||
| 	fi.Room.IsPublic = true // hardcode for local test; move to form | ||||
| 	if err := repo.CreateRoom(r.Context(), room); err != nil { | ||||
| 	if err := repo.RoomCreate(r.Context(), room); err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	if err := saveFullInfo(fi); err != nil { | ||||
| 		msg := "failed to set current room to session" | ||||
| 		log.Error(msg, "error", err) | ||||
| 		abortWithError(w, msg) | ||||
| 	if err := repo.PlayerSetRoomID(fi.State.Username, room.ID); err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	// if err := saveFullInfo(fi); err != nil { | ||||
| 	// 	msg := "failed to set current room to session" | ||||
| 	// 	log.Error(msg, "error", err) | ||||
| 	// 	abortWithError(w, msg) | ||||
| 	// 	return | ||||
| 	// } | ||||
| 	notify(models.NotifyRoomListUpdate, "") | ||||
| 	tmpl, err := template.ParseGlob("components/*.html") | ||||
| 	if err != nil { | ||||
| @@ -198,7 +201,7 @@ func HandleStartGame(w http.ResponseWriter, r *http.Request) { | ||||
|  | ||||
| func HandleJoinRoom(w http.ResponseWriter, r *http.Request) { | ||||
| 	roomID := r.URL.Query().Get("id") | ||||
| 	room, err := getRoomByID(roomID) | ||||
| 	room, err := repo.RoomGetByID(r.Context(), roomID) | ||||
| 	if err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder