Update names in subscribe portion of sync protocol

This commit is contained in:
Lucien Greathouse
2019-11-11 17:52:09 -08:00
parent 94e1501329
commit 47614c3102
7 changed files with 23 additions and 32 deletions

View File

@@ -103,15 +103,7 @@ function ServeSession:__mainSyncLoop()
return self.__apiContext:retrieveMessages()
:andThen(function(messages)
for _, message in ipairs(messages) do
-- TODO: Update server to return patches in correct format so
-- that we don't have to transform them for the reconciler.
local asPatch = {
removed = message.removedInstances,
updated = message.updatedInstances,
added = message.addedInstances,
}
self.__reconciler:applyPatch(asPatch)
self.__reconciler:applyPatch(message)
end
if self.__status ~= Status.Disconnected then

View File

@@ -4,7 +4,7 @@ expression: "subscribe_response.intern_and_redact(&mut redactions, ())"
---
messageCursor: 1
messages:
- addedInstances:
- added:
id-3:
Children: []
ClassName: Folder
@@ -14,6 +14,6 @@ messages:
Name: my-new-folder
Parent: id-2
Properties: {}
removedInstances: []
updatedInstances: []
removed: []
updated: []
sessionId: id-1

View File

@@ -4,7 +4,7 @@ expression: "subscribe_response.intern_and_redact(&mut redactions, ())"
---
messageCursor: 1
messages:
- addedInstances:
- added:
id-10:
Children: []
ClassName: StringValue
@@ -144,6 +144,6 @@ messages:
Value:
Type: String
Value: "File #5"
removedInstances: []
updatedInstances: []
removed: []
updated: []
sessionId: id-1

View File

@@ -4,9 +4,9 @@ expression: "subscribe_response.intern_and_redact(&mut redactions, ())"
---
messageCursor: 1
messages:
- addedInstances: {}
removedInstances: []
updatedInstances:
- added: {}
removed: []
updated:
- changedClassName: ~
changedMetadata: ~
changedName: ~

View File

@@ -61,8 +61,8 @@ impl<'a> Internable<&'a HashMap<RbxId, Instance<'_>>> for Instance<'a> {
impl Internable<()> for SubscribeResponse<'_> {
fn intern(&self, redactions: &mut RedactionMap, _extra: ()) {
for message in &self.messages {
intern_instance_updates(redactions, &message.updated_instances);
intern_instance_additions(redactions, &message.added_instances);
intern_instance_updates(redactions, &message.updated);
intern_instance_additions(redactions, &message.added);
}
}
}

View File

@@ -93,20 +93,19 @@ impl<F: VfsFetcher> ApiService<F> {
let api_messages = messages
.into_iter()
.map(|message| {
let removed_instances = message.removed;
let removed = message.removed;
let mut added_instances = HashMap::new();
let mut added = HashMap::new();
for id in message.added {
let instance = tree.get_instance(id).unwrap();
added_instances.insert(id, Instance::from_rojo_instance(instance));
added.insert(id, Instance::from_rojo_instance(instance));
for instance in tree.descendants(id) {
added_instances
.insert(instance.id(), Instance::from_rojo_instance(instance));
added.insert(instance.id(), Instance::from_rojo_instance(instance));
}
}
let updated_instances = message
let updated = message
.updated
.into_iter()
.map(|update| {
@@ -126,9 +125,9 @@ impl<F: VfsFetcher> ApiService<F> {
.collect();
SubscribeMessage {
removed_instances,
added_instances,
updated_instances,
removed,
added,
updated,
}
})
.collect();

View File

@@ -23,9 +23,9 @@ pub const PROTOCOL_VERSION: u64 = 3;
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct SubscribeMessage<'a> {
pub removed_instances: Vec<RbxId>,
pub added_instances: HashMap<RbxId, Instance<'a>>,
pub updated_instances: Vec<InstanceUpdate>,
pub removed: Vec<RbxId>,
pub added: HashMap<RbxId, Instance<'a>>,
pub updated: Vec<InstanceUpdate>,
}
#[derive(Debug, Serialize, Deserialize)]