mirror of https://github.com/xwiki-labs/cryptpad
set uid in cursor object in outer scope
rather than within each app that uses cursors
This commit is contained in:
parent
1e1890dbe4
commit
c416303e1d
|
@ -388,9 +388,7 @@ define([
|
|||
var andThen2 = function (editor, CodeMirror, framework, isPresentMode) {
|
||||
|
||||
var common = framework._.sfCommon;
|
||||
var metadataMgr = common.getMetadataMgr();
|
||||
var privateData = metadataMgr.getPrivateData();
|
||||
CodeMirror.uid = metadataMgr.getUserData().uid;
|
||||
var privateData = common.getMetadataMgr().getPrivateData();
|
||||
|
||||
var previewPane = mkPreviewPane(editor, CodeMirror, framework, isPresentMode);
|
||||
var markdownTb = mkMarkdownTb(editor, framework);
|
||||
|
|
|
@ -4,7 +4,8 @@ define([
|
|||
'/customize/messages.js',
|
||||
'/bower_components/chainpad/chainpad.dist.js',
|
||||
'/common/inner/common-mediatag.js',
|
||||
], function (Util, SFCodeMirror, Messages, ChainPad, MT) {
|
||||
'/common/common-interface.js',
|
||||
], function (Util, SFCodeMirror, Messages, ChainPad, MT, UI) {
|
||||
var Markers = {};
|
||||
|
||||
/* TODO Known Issues
|
||||
|
@ -39,7 +40,7 @@ define([
|
|||
});
|
||||
}
|
||||
uid = Number(uid);
|
||||
var name = Util.fixHTML((author.name || "").trim());
|
||||
var name = Util.fixHTML(UI.getDisplayName(author.name));
|
||||
var animal;
|
||||
if ((!name || name === Messages.anonymous) && typeof(author.uid) === 'string') {
|
||||
animal = MT.getPseudorandomAnimal(author.uid);
|
||||
|
|
|
@ -187,6 +187,7 @@ define([
|
|||
data.color = Util.find(proxy, ['settings', 'general', 'cursor', 'color']);
|
||||
data.name = proxy[Constants.displayNameKey] || ctx.store.noDriveName || Messages.anonymous;
|
||||
data.avatar = Util.find(proxy, ['profile', 'avatar']);
|
||||
data.uid = Util.find(proxy, ['uid']) || ctx.store.noDriveUid;
|
||||
c.cursor = data;
|
||||
sendMyCursor(ctx, client);
|
||||
cb();
|
||||
|
|
|
@ -509,7 +509,6 @@ 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;
|
||||
};
|
||||
|
||||
|
|
|
@ -1272,9 +1272,7 @@ define([
|
|||
|
||||
var myCursor = {};
|
||||
onCursorUpdate.reg(function (data) {
|
||||
console.log('onCursorUpdate', data);
|
||||
myCursor = data;
|
||||
myCursor.uid = myData.uid;
|
||||
framework.updateCursor();
|
||||
});
|
||||
framework.onCursorUpdate(function (data) {
|
||||
|
|
|
@ -37,7 +37,7 @@ define([
|
|||
$(el).remove();
|
||||
};
|
||||
|
||||
Cursor.create = function (inner, hjsonToDom, cursorModule, uid) {
|
||||
Cursor.create = function (inner, hjsonToDom, cursorModule) {
|
||||
var exp = {};
|
||||
|
||||
var cursors = {};
|
||||
|
@ -147,12 +147,6 @@ define([
|
|||
var cursorObj = data.cursor;
|
||||
|
||||
if (!cursorObj.selectionStart) { return; }
|
||||
if (cursorObj.name === Messages.anonymous) {
|
||||
// save a little bit of data from going over the wire...
|
||||
// remote clients will interpret this as Messages.anonymous (in their UI language)
|
||||
cursorObj.name = '';
|
||||
cursorObj.uid = uid;
|
||||
}
|
||||
|
||||
// 1. Transform the cursor to get the offset relative to our doc
|
||||
// 2. Turn it into a range
|
||||
|
|
|
@ -678,7 +678,6 @@ define([
|
|||
|
||||
var metadataMgr = framework._.sfCommon.getMetadataMgr();
|
||||
var privateData = metadataMgr.getPrivateData();
|
||||
var myData = metadataMgr.getUserData();
|
||||
var common = framework._.sfCommon;
|
||||
var APP = window.APP;
|
||||
|
||||
|
@ -705,7 +704,7 @@ define([
|
|||
var cursor = module.cursor = Cursor(inner);
|
||||
|
||||
// Display other users cursor
|
||||
var cursors = Cursors.create(inner, hjsonToDom, cursor, myData.uid);
|
||||
var cursors = Cursors.create(inner, hjsonToDom, cursor);
|
||||
|
||||
var openLink = function(e) {
|
||||
var el = e.currentTarget;
|
||||
|
|
|
@ -459,9 +459,7 @@ define([
|
|||
var andThen2 = function (editor, CodeMirror, framework, isPresentMode) {
|
||||
|
||||
var common = framework._.sfCommon;
|
||||
var metadataMgr = common.getMetadataMgr();
|
||||
var privateData = metadataMgr.getPrivateData();
|
||||
CodeMirror.uid = metadataMgr.getUserData().uid;
|
||||
var privateData = common.getMetadataMgr().getPrivateData();
|
||||
|
||||
var $contentContainer = $('#cp-app-slide-editor');
|
||||
var $modal = $('#cp-app-slide-modal');
|
||||
|
@ -513,7 +511,7 @@ define([
|
|||
framework.updateCursor();
|
||||
}, 500); // 500ms to make sure it is sent after chainpad sync
|
||||
};
|
||||
framework.onCursorUpdate(CodeMirror.setRemoteCursor); // XXX
|
||||
framework.onCursorUpdate(CodeMirror.setRemoteCursor);
|
||||
framework.setCursorGetter(CodeMirror.getCursor);
|
||||
editor.on('cursorActivity', updateCursor);
|
||||
|
||||
|
|
Loading…
Reference in New Issue