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() return self.__apiContext:retrieveMessages()
:andThen(function(messages) :andThen(function(messages)
for _, message in ipairs(messages) do for _, message in ipairs(messages) do
-- TODO: Update server to return patches in correct format so self.__reconciler:applyPatch(message)
-- 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)
end end
if self.__status ~= Status.Disconnected then if self.__status ~= Status.Disconnected then

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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