From fee376102192dc6f24297a7b11324636ace3a07d Mon Sep 17 00:00:00 2001 From: historia <[not public]> Date: Tue, 30 Jun 2026 19:27:37 -0400 Subject: feat: admin gui object CRUD is much nicer --- internal/admin/api_rooms.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'internal/admin/api_rooms.go') diff --git a/internal/admin/api_rooms.go b/internal/admin/api_rooms.go index a477cc3..f615d9d 100644 --- a/internal/admin/api_rooms.go +++ b/internal/admin/api_rooms.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io" + "log" "net/http" "os" "path/filepath" @@ -229,6 +230,7 @@ func (s *AdminServer) handleRoomByID(w http.ResponseWriter, r *http.Request) { s.world.ClearRoomState(id) allIDs, _ := listRoomIDs(s.dataDir) + var extraFiles []ExtraFile var exitCleaned int for _, otherID := range allIDs { if otherID == id { @@ -250,7 +252,16 @@ func (s *AdminServer) handleRoomByID(w http.ResponseWriter, r *http.Request) { if changed { otherPath, pathOk := s.world.GetRoomPath(otherID) if pathOk { - writeYAMLFile(otherPath, otherRoom) + oldExtra, _ := snapshotFile(otherPath) + newContent, writeErr := writeYAMLFile(otherPath, otherRoom) + if writeErr != nil { + continue + } + extraFiles = append(extraFiles, ExtraFile{ + FilePath: otherPath, + OldContent: oldExtra, + NewContent: newContent, + }) exitCleaned++ } } @@ -261,6 +272,7 @@ func (s *AdminServer) handleRoomByID(w http.ResponseWriter, r *http.Request) { FilePath: path, OldContent: oldContent, IsDelete: true, + ExtraFiles: extraFiles, }) writeJSON(w, map[string]any{"ok": true}) @@ -352,6 +364,7 @@ func (s *AdminServer) handleRoomLink(w http.ResponseWriter, r *http.Request) { grid := world.BuildGrid(s.cfg.StartingRoom, func(id int) (*world.Room, bool) { room, err := s.world.LoadRoom(id) if err != nil { + log.Printf("link: BuildGrid failed to load room %d: %v", id, err) return nil, false } return room, true @@ -402,6 +415,7 @@ func (s *AdminServer) handleRoomLink(w http.ResponseWriter, r *http.Request) { testGrid := world.BuildGrid(s.cfg.StartingRoom, func(id int) (*world.Room, bool) { room, err := s.world.LoadRoom(id) if err != nil { + log.Printf("link: conflict test BuildGrid failed to load room %d: %v", id, err) return nil, false } roomCopy := *room -- cgit v1.2.3