From 68efd549177bb5041dabce9170fc0bf8463182ee Mon Sep 17 00:00:00 2001 From: ansuz Date: Wed, 25 Aug 2021 16:18:09 +0530 Subject: [PATCH] include uid in cursor data for animal avatars --- www/code/inner.js | 4 +++- www/common/inner/common-mediatag.js | 9 +++++++-- www/common/sframe-common-codemirror.js | 1 + www/slide/inner.js | 4 +++- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/www/code/inner.js b/www/code/inner.js index 4f6c0308e..4328f0d8f 100644 --- a/www/code/inner.js +++ b/www/code/inner.js @@ -388,7 +388,9 @@ define([ var andThen2 = function (editor, CodeMirror, framework, isPresentMode) { var common = framework._.sfCommon; - var privateData = common.getMetadataMgr().getPrivateData(); + var metadataMgr = common.getMetadataMgr(); + var privateData = metadataMgr.getPrivateData(); + CodeMirror.uid = metadataMgr.getUserData().uid; var previewPane = mkPreviewPane(editor, CodeMirror, framework, isPresentMode); var markdownTb = mkMarkdownTb(editor, framework); diff --git a/www/common/inner/common-mediatag.js b/www/common/inner/common-mediatag.js index 54b20784a..5e091a83c 100644 --- a/www/common/inner/common-mediatag.js +++ b/www/common/inner/common-mediatag.js @@ -43,9 +43,15 @@ define([ }); }; + var animal_avatars = {}; MT.getCursorAvatar = function (cursor) { + var uid = cursor.uid; var html = ''; - html += (cursor.avatar && avatars[cursor.avatar]) || ''; + if (cursor.avatar && avatars[cursor.avatar]) { + html += (cursor.avatar && avatars[cursor.avatar]) || ''; + } else if (animal_avatars[uid]) { + html += animal_avatars[uid] + ' '; + } html += Util.fixHTML(cursor.name) + ''; return html; }; @@ -109,7 +115,6 @@ define([ return text; }; - var animal_avatars = {}; MT.displayAvatar = function (common, $container, href, name, _cb, uid) { var cb = Util.once(Util.mkAsync(_cb || function () {})); var displayDefault = function () { diff --git a/www/common/sframe-common-codemirror.js b/www/common/sframe-common-codemirror.js index 58475bbed..4e490288d 100644 --- a/www/common/sframe-common-codemirror.js +++ b/www/common/sframe-common-codemirror.js @@ -509,6 +509,7 @@ define([ var cursor = {}; cursor.selectionStart = cursorToPos(editor.getCursor('from'), doc); cursor.selectionEnd = cursorToPos(editor.getCursor('to'), doc); + cursor.uid = exp.uid; // FIXME this is inefficient for the network but it's unlikely to trigger errors return cursor; }; diff --git a/www/slide/inner.js b/www/slide/inner.js index 143165176..9bbfc6e4d 100644 --- a/www/slide/inner.js +++ b/www/slide/inner.js @@ -459,7 +459,9 @@ define([ var andThen2 = function (editor, CodeMirror, framework, isPresentMode) { var common = framework._.sfCommon; - var privateData = common.getMetadataMgr().getPrivateData(); + var metadataMgr = common.getMetadataMgr(); + var privateData = metadataMgr.getPrivateData(); + CodeMirror.uid = metadataMgr.getUserData().uid; var $contentContainer = $('#cp-app-slide-editor'); var $modal = $('#cp-app-slide-modal');