|
@@ 247-261 (lines=15) @@
|
| 244 |
|
result.session_selected_link = frozenset([x for x in result.session_selected_link if str(x) not in [str(y) for y in item_link]]) |
| 245 |
|
count_after = len(new_item.links) |
| 246 |
|
if count_before != count_after: |
| 247 |
|
result.session_pending_change = True |
| 248 |
|
elif isinstance(action, Action_ChangeItemAddLink): |
| 249 |
|
new_link = action.new_link |
| 250 |
|
if "" != new_link: |
| 251 |
|
|
| 252 |
|
project_tree = state.project_tree |
| 253 |
|
old_item = project_tree.find_item(action.item_uid) if project_tree else None |
| 254 |
|
|
| 255 |
|
if old_item: |
| 256 |
|
if new_link not in old_item.links: |
| 257 |
|
result = copy.deepcopy(result) |
| 258 |
|
project_tree = result.project_tree |
| 259 |
|
if project_tree: |
| 260 |
|
new_item = project_tree.find_item(action.item_uid) |
| 261 |
|
links = new_item.links |
| 262 |
|
links.append(UID(new_link)) |
| 263 |
|
new_item.links = links |
| 264 |
|
result.session_pending_change = True |
|
@@ 145-158 (lines=14) @@
|
| 142 |
|
return result |
| 143 |
|
|
| 144 |
|
|
| 145 |
|
class Reducer_Edit(Reducer): |
| 146 |
|
def reduce(self, state: State, action: Action) -> State: |
| 147 |
|
result = state |
| 148 |
|
if isinstance(action, Action_ChangeItemText): |
| 149 |
|
project_tree = state.project_tree |
| 150 |
|
old_item = project_tree.find_item(action.item_uid) if project_tree else None |
| 151 |
|
|
| 152 |
|
if old_item: |
| 153 |
|
old_item_text = old_item.text |
| 154 |
|
new_item_text = action.item_new_text |
| 155 |
|
if old_item_text != new_item_text: |
| 156 |
|
result = copy.deepcopy(result) |
| 157 |
|
project_tree = result.project_tree |
| 158 |
|
if project_tree: |
| 159 |
|
new_item = project_tree.find_item(action.item_uid) |
| 160 |
|
new_item.text = new_item_text |
| 161 |
|
result.session_pending_change = True |