feat(collections): the rules-Apply path seeds the reversed default too
The creation seed (d56031f3) covered born-smart collections; a STATIC
collection that becomes smart through the rules editor's Apply landed
without any curated order — its dropdown stayed "Feed order" while
every other podcast smart collection opened reversed. Same decision,
same guardrails (2026-11-01 user approved closing this gap): a PUT
carrying an episodes-scope tree seeds chain_order=reverse only when
neither the request NOR the stored view_settings names one — a
deliberate native (client-sent or saved) is never clobbered, and
books-scope trees seed nothing.
Pins: apply-seeds-when-unordered, respects-stored-native,
respects-client-native (TestSmartCollectionBornReversed now covers
both seed paths); changelogged in contract_pins.
This commit is contained in:
1 parent
96a40f7d88
commit
57bc0e9dd4
3 files changed
+69
No files matched your search
@@ -607,6 +607,27 @@ func (h *CollectionHandler) UpdateCollection(c *echo.Context) error {
|
||||
if treeErr != nil {
|
||||
return c.JSON(http.StatusBadRequest, map[string]string{"error": treeErr.Error()})
|
||||
}
|
||||
// Applying a tree to a collection with NO curated listening order
|
||||
// seeds the reversed default (2026-11-01 — the creation seed's twin):
|
||||
// a static collection becoming smart lands with the same default a
|
||||
// born-smart one gets. Triple-guarded: the client's explicit
|
||||
// chain_order wins, a STORED chain_order is never clobbered, and
|
||||
// only episodes-scope trees seed (books have no episode chain).
|
||||
if treeJSON != nil && (req.ViewSettings == nil || req.ViewSettings["chain_order"] == nil) {
|
||||
if t, perr := services.ParseFilterTree(string(treeJSON)); perr == nil &&
|
||||
t.FilterScope() == services.ScopeEpisodes {
|
||||
if existing, gerr := h.collectionService.GetCollection(c.Request().Context(), collectionID); gerr == nil {
|
||||
var stored map[string]interface{}
|
||||
_ = json.Unmarshal(existing.ViewSettings, &stored)
|
||||
if stored == nil || stored["chain_order"] == nil {
|
||||
if req.ViewSettings == nil {
|
||||
req.ViewSettings = map[string]interface{}{}
|
||||
}
|
||||
req.ViewSettings["chain_order"] = "reverse"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
collection, err := h.collectionService.UpdateCollection(
|
||||
c.Request().Context(),
|
||||
collectionID,
|
||||
|
||||
Reference in new issue
Block a user