huskies: merge 946
This commit is contained in:
@@ -41,12 +41,15 @@ pub fn set_depends_on(story_id: &str, deps: &[u32]) -> bool {
|
||||
|
||||
/// Set the `item_type` CRDT register for a pipeline item (sub-story 933).
|
||||
///
|
||||
/// `Some(t)` writes the type string (e.g. `"story"`, `"epic"`, `"bug"`).
|
||||
/// `Some(t)` writes the canonical type string (e.g. `"story"`, `"epic"`, `"bug"`).
|
||||
/// `None` clears the register to an empty string, which means "use the
|
||||
/// id-prefix heuristic" (see `item_type_from_id`).
|
||||
///
|
||||
/// Returns `true` if the item was found and the op was applied, `false` otherwise.
|
||||
pub fn set_item_type(story_id: &str, item_type: Option<&str>) -> bool {
|
||||
pub fn set_item_type(
|
||||
story_id: &str,
|
||||
item_type: Option<crate::io::story_metadata::ItemType>,
|
||||
) -> bool {
|
||||
let Some(state_mutex) = get_crdt() else {
|
||||
return false;
|
||||
};
|
||||
@@ -56,18 +59,21 @@ pub fn set_item_type(story_id: &str, item_type: Option<&str>) -> bool {
|
||||
let Some(&idx) = state.index.get(story_id) else {
|
||||
return false;
|
||||
};
|
||||
let value = item_type.unwrap_or("").to_string();
|
||||
let value = item_type
|
||||
.map(|t| t.as_str().to_string())
|
||||
.unwrap_or_default();
|
||||
apply_and_persist(&mut state, |s| s.crdt.doc.items[idx].item_type.set(value));
|
||||
true
|
||||
}
|
||||
|
||||
/// Set the `epic` CRDT register for a pipeline item (sub-story 933).
|
||||
///
|
||||
/// `Some(epic_id)` links the item to its parent epic.
|
||||
/// `Some(id)` links the item to its parent epic (stored as the numeric string,
|
||||
/// e.g. `"9990"` for `EpicId(9990)`).
|
||||
/// `None` clears the register to an empty string (no epic membership).
|
||||
///
|
||||
/// Returns `true` if the item was found and the op was applied, `false` otherwise.
|
||||
pub fn set_epic(story_id: &str, epic_id: Option<&str>) -> bool {
|
||||
pub fn set_epic(story_id: &str, epic_id: Option<crate::crdt_state::types::EpicId>) -> bool {
|
||||
let Some(state_mutex) = get_crdt() else {
|
||||
return false;
|
||||
};
|
||||
@@ -77,7 +83,7 @@ pub fn set_epic(story_id: &str, epic_id: Option<&str>) -> bool {
|
||||
let Some(&idx) = state.index.get(story_id) else {
|
||||
return false;
|
||||
};
|
||||
let value = epic_id.unwrap_or("").to_string();
|
||||
let value = epic_id.map(|e| e.to_string()).unwrap_or_default();
|
||||
apply_and_persist(&mut state, |s| s.crdt.doc.items[idx].epic.set(value));
|
||||
true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user