forked from rojo-rbx/rojo
Use real Rojo metadata for live sync
This commit is contained in:
@@ -111,16 +111,15 @@ impl ApiService {
|
||||
let message_cursor = message_queue.cursor();
|
||||
|
||||
let tree = self.serve_session.tree();
|
||||
let inner_tree = tree.inner();
|
||||
|
||||
let mut instances = HashMap::new();
|
||||
|
||||
for id in requested_ids {
|
||||
if let Some(instance) = inner_tree.get_instance(id) {
|
||||
instances.insert(id, Instance::from_rbx_instance(instance));
|
||||
if let Some(instance) = tree.get_instance(id) {
|
||||
instances.insert(id, Instance::from_rojo_instance(instance));
|
||||
|
||||
for descendant in inner_tree.descendants(id) {
|
||||
instances.insert(descendant.get_id(), Instance::from_rbx_instance(descendant));
|
||||
for descendant in tree.descendants(id) {
|
||||
instances.insert(descendant.id(), Instance::from_rojo_instance(descendant));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ use std::{
|
||||
use rbx_dom_weak::{RbxId, RbxInstance, RbxValue};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::session_id::SessionId;
|
||||
use crate::{session_id::SessionId, snapshot::InstanceWithMeta};
|
||||
|
||||
/// Server version to report over the API, not exposed outside this crate.
|
||||
pub(crate) const SERVER_VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
@@ -37,22 +37,15 @@ pub struct Instance<'a> {
|
||||
}
|
||||
|
||||
impl<'a> Instance<'a> {
|
||||
pub fn from_rbx_instance(source: &RbxInstance) -> Instance<'_> {
|
||||
// TODO: This is a hack!
|
||||
let metadata = if source.class_name == "DataModel" {
|
||||
Some(InstanceMetadata {
|
||||
ignore_unknown_instances: true,
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
pub fn from_rojo_instance<'b>(source: InstanceWithMeta<'b>) -> Instance<'b> {
|
||||
Instance {
|
||||
name: Cow::Borrowed(&source.name),
|
||||
class_name: Cow::Borrowed(&source.class_name),
|
||||
properties: Cow::Borrowed(&source.properties),
|
||||
children: Cow::Borrowed(source.get_children_ids()),
|
||||
metadata,
|
||||
name: Cow::Borrowed(source.name()),
|
||||
class_name: Cow::Borrowed(source.class_name()),
|
||||
properties: Cow::Borrowed(source.properties()),
|
||||
children: Cow::Borrowed(source.children()),
|
||||
metadata: Some(InstanceMetadata {
|
||||
ignore_unknown_instances: source.metadata().ignore_unknown_instances,
|
||||
}),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user