Make sure indexUser is the same everywhere
https://github.com/cryptpad/cryptpad/issues/1446
This commit is contained in:
parent
82daeb98aa
commit
cabe1b879b
2 changed files with 21 additions and 13 deletions
|
@ -7,6 +7,7 @@ www/components/
|
|||
www/bower_components/
|
||||
www/common/onlyoffice/dist
|
||||
www/common/onlyoffice/x2t
|
||||
onlyoffice-dist/
|
||||
|
||||
www/scratch
|
||||
www/accounts
|
||||
|
|
|
@ -179,15 +179,11 @@ define([
|
|||
});
|
||||
};
|
||||
|
||||
var getUserIndex = function () {
|
||||
var i = 1;
|
||||
var ids = content.ids || {};
|
||||
Object.keys(ids).forEach(function (k) {
|
||||
if (ids[k] && ids[k].index && ids[k].index >= i) {
|
||||
i = ids[k].index + 1;
|
||||
}
|
||||
});
|
||||
return i;
|
||||
const getNewUserIndex = function () {
|
||||
const ids = content.ids || {};
|
||||
const indexes = Object.values(ids).map((user) => user.index);
|
||||
const maxIndex = Math.max(...indexes);
|
||||
return maxIndex === -Infinity ? 1 : maxIndex+1;
|
||||
};
|
||||
|
||||
var setMyId = function () {
|
||||
|
@ -207,7 +203,7 @@ define([
|
|||
var myId = getId();
|
||||
ids[myId] = {
|
||||
ooid: myOOId,
|
||||
index: getUserIndex(),
|
||||
index: getNewUserIndex(),
|
||||
netflux: metadataMgr.getNetfluxId()
|
||||
};
|
||||
oldIds = JSON.parse(JSON.stringify(ids));
|
||||
|
@ -912,6 +908,15 @@ define([
|
|||
});
|
||||
};
|
||||
|
||||
const findUserByOOId = function(ooId) {
|
||||
return Object.values(content.ids)
|
||||
.find((user) => user.ooid === ooId);
|
||||
};
|
||||
|
||||
const myOOIndex = function() {
|
||||
return findUserByOOId(myOOId).index;
|
||||
};
|
||||
|
||||
var getParticipants = function () {
|
||||
var users = metadataMgr.getMetadata().users;
|
||||
var i = 1;
|
||||
|
@ -944,18 +949,19 @@ define([
|
|||
view: false
|
||||
});
|
||||
i++;
|
||||
if (!myUniqueOOId) { myUniqueOOId = String(myOOId) + i; }
|
||||
if (!myUniqueOOId) { myUniqueOOId = String(myOOId) + myOOIndex(); }
|
||||
console.log('XXX send userdata to OO', {i, myOOIndex: myOOIndex()});
|
||||
p.push({
|
||||
id: myUniqueOOId,
|
||||
idOriginal: String(myOOId),
|
||||
username: metadataMgr.getUserData().name || Messages.anonymous,
|
||||
indexUser: i,
|
||||
indexUser: myOOIndex(),
|
||||
connectionId: metadataMgr.getNetfluxId() || Hash.createChannelId(),
|
||||
isCloseCoAuthoring:false,
|
||||
view: false
|
||||
});
|
||||
return {
|
||||
index: i,
|
||||
index: myOOIndex(),
|
||||
list: p.filter(Boolean)
|
||||
};
|
||||
};
|
||||
|
@ -1136,6 +1142,7 @@ define([
|
|||
}
|
||||
var type = common.getMetadataMgr().getPrivateData().ooType;
|
||||
var b = obj.block && obj.block[0];
|
||||
console.log('XXX new lock', {myUniqueOOId, myOOIndex: myOOIndex()});
|
||||
var msg = {
|
||||
time: now(),
|
||||
user: myUniqueOOId,
|
||||
|
|
Loading…
Reference in a new issue