mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-25 04:54:07 +00:00
Refactor syncback process and improve code readability
- Reformatted the `SYNCBACK_SERVICES` list for better readability by aligning entries vertically. - Simplified the `performSyncback` function by removing unnecessary Promise wrapping, enhancing clarity and maintainability. - Updated the `NotConnectedPage` component to improve the structure of button elements and their associated tooltips. - Refactored the `hydrate` and `matching` modules to streamline function calls and improve code organization. These changes enhance the overall readability and maintainability of the syncback process and related components.
This commit is contained in:
parent
372a422b3d
commit
93ea0bdef6
16 changed files with 546 additions and 375 deletions
|
|
@ -33,6 +33,12 @@ pub struct MatchingSession {
|
|||
cost_cache: RefCell<HashMap<(Ref, Ref), u32>>,
|
||||
}
|
||||
|
||||
impl Default for MatchingSession {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl MatchingSession {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
|
@ -116,7 +122,14 @@ pub fn match_forward(
|
|||
let snap_remaining = snap_matched.iter().filter(|&&m| !m).count();
|
||||
let tree_remaining = tree_available.iter().filter(|&&a| a).count();
|
||||
if snap_remaining == 0 || tree_remaining == 0 {
|
||||
return build_result(snap_available, tree_children, &tree_available, matched, tree, session);
|
||||
return build_result(
|
||||
snap_available,
|
||||
tree_children,
|
||||
&tree_available,
|
||||
matched,
|
||||
tree,
|
||||
session,
|
||||
);
|
||||
}
|
||||
|
||||
// ================================================================
|
||||
|
|
@ -186,7 +199,14 @@ pub fn match_forward(
|
|||
}
|
||||
}
|
||||
|
||||
build_result(snap_available, tree_children, &tree_available, matched, tree, session)
|
||||
build_result(
|
||||
snap_available,
|
||||
tree_children,
|
||||
&tree_available,
|
||||
matched,
|
||||
tree,
|
||||
session,
|
||||
)
|
||||
}
|
||||
|
||||
/// Build the final result, consuming the snapshot children.
|
||||
|
|
@ -1139,7 +1159,12 @@ mod tests {
|
|||
make_snapshot_with_props("Wall", "Part", tree_props_b),
|
||||
make_snapshot_with_props("Wall", "Part", tree_props_a),
|
||||
]);
|
||||
let result = match_forward(vec![snap_a, snap_b], &tree_refs, &tree, &MatchingSession::new());
|
||||
let result = match_forward(
|
||||
vec![snap_a, snap_b],
|
||||
&tree_refs,
|
||||
&tree,
|
||||
&MatchingSession::new(),
|
||||
);
|
||||
|
||||
assert_eq!(result.matched.len(), 2, "Both should match");
|
||||
|
||||
|
|
|
|||
|
|
@ -235,7 +235,14 @@ fn compute_children_patches(
|
|||
|
||||
// Matched pairs: recursively compute patches.
|
||||
for (snapshot_child, tree_child_id) in match_result.matched {
|
||||
compute_patch_set_internal(context, snapshot_child, tree, tree_child_id, patch_set, session);
|
||||
compute_patch_set_internal(
|
||||
context,
|
||||
snapshot_child,
|
||||
tree,
|
||||
tree_child_id,
|
||||
patch_set,
|
||||
session,
|
||||
);
|
||||
}
|
||||
|
||||
// Unmatched snapshots: new instances to be added.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue