Feat: roomlist update
This commit is contained in:
		| @@ -3,6 +3,7 @@ package handlers | ||||
| import ( | ||||
| 	"golias/broker" | ||||
| 	"golias/config" | ||||
| 	"golias/models" | ||||
| 	"golias/pkg/cache" | ||||
| 	"html/template" | ||||
| 	"log/slog" | ||||
| @@ -93,11 +94,20 @@ func HandleExit(w http.ResponseWriter, r *http.Request) { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	var creatorLeft bool | ||||
| 	if fi.Room.CreatorName == fi.State.Username { | ||||
| 		creatorLeft = true | ||||
| 	} | ||||
| 	exitedRoom := fi.ExitRoom() | ||||
| 	if err := saveRoom(exitedRoom); err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
| 	} | ||||
| 	if len(exitedRoom.PlayerList) == 0 || creatorLeft { | ||||
| 		removeRoom(exitedRoom.ID) | ||||
| 		// TODO: notify users if creator left | ||||
| 		notify(models.NotifyRoomListUpdate, "") | ||||
| 	} | ||||
| 	if err := saveState(fi.State.Username, fi.State); err != nil { | ||||
| 		abortWithError(w, err.Error()) | ||||
| 		return | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder