From b796879c9f6d4f262349a1c267c9453608d06e26 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Thu, 21 Sep 2017 14:58:49 +0100 Subject: [PATCH] Handle options not being passed --- services/real-time/app/coffee/Router.coffee | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/services/real-time/app/coffee/Router.coffee b/services/real-time/app/coffee/Router.coffee index 8821748a35..e6dda566e0 100644 --- a/services/real-time/app/coffee/Router.coffee +++ b/services/real-time/app/coffee/Router.coffee @@ -79,8 +79,22 @@ module.exports = Router = if err? Router._handleError null, err, client, "leaveProject" - + # Variadic. The possible options: + # doc_id, callback + # doc_id, fromVersion, callback + # doc_id, options, callback + # doc_id, options, fromVersion, callback client.on "joinDoc", (doc_id, options, fromVersion, callback) -> + # options is optional + if typeof options == "function" + options = {} + callback = options + fromVersion = -1 + else if typeof options == "number" + options = {} + fromVersion = options + callback = fromVersion + # fromVersion is optional if typeof fromVersion == "function" callback = fromVersion