Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
1d755b32
Commit
1d755b32
authored
Sep 22, 2017
by
konovalovsergey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
for bug 32236. send all participants instead of user in/out
parent
4862014a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
36 deletions
+55
-36
common/docscoapi.js
common/docscoapi.js
+55
-36
No files found.
common/docscoapi.js
View file @
1d755b32
...
@@ -574,6 +574,7 @@
...
@@ -574,6 +574,7 @@
this
.
_state
=
ConnectionState
.
None
;
this
.
_state
=
ConnectionState
.
None
;
// Online-пользователи в документе
// Online-пользователи в документе
this
.
_participants
=
{};
this
.
_participants
=
{};
this
.
_participantsTimestamp
;
this
.
_countEditUsers
=
0
;
this
.
_countEditUsers
=
0
;
this
.
_countUsers
=
0
;
this
.
_countUsers
=
0
;
...
@@ -1146,12 +1147,16 @@
...
@@ -1146,12 +1147,16 @@
}
}
};
};
DocsCoApi
.
prototype
.
_onStartCoAuthoring
=
function
(
isStartEvent
)
{
DocsCoApi
.
prototype
.
_onStartCoAuthoring
=
function
(
isStartEvent
,
isWaitAuth
)
{
if
(
false
===
this
.
isCoAuthoring
)
{
if
(
false
===
this
.
isCoAuthoring
)
{
this
.
isCoAuthoring
=
true
;
this
.
isCoAuthoring
=
true
;
if
(
this
.
onStartCoAuthoring
)
{
if
(
this
.
onStartCoAuthoring
)
{
this
.
onStartCoAuthoring
(
isStartEvent
);
this
.
onStartCoAuthoring
(
isStartEvent
);
}
}
}
else
if
(
isWaitAuth
)
{
//it is a stub for unexpected situation(no direct reproduce scenery)
//isCoAuthoring is true when more then one editor, but isWaitAuth mean than server has one editor
this
.
unLockDocument
(
false
,
true
);
}
}
};
};
...
@@ -1285,22 +1290,51 @@
...
@@ -1285,22 +1290,51 @@
}
}
};
};
DocsCoApi
.
prototype
.
_onParticipantsChanged
=
function
(
participants
,
needChanged
)
{
var
participantsNew
=
{};
var
countEditUsersNew
=
0
;
var
countUsersNew
=
0
;
var
tmpUser
;
var
i
;
var
usersStateChanged
=
[];
if
(
participants
)
{
for
(
i
=
0
;
i
<
participants
.
length
;
++
i
)
{
tmpUser
=
new
AscCommon
.
asc_CUser
(
participants
[
i
]);
participantsNew
[
tmpUser
.
asc_getId
()]
=
tmpUser
;
if
(
!
tmpUser
.
asc_getView
())
{
++
countEditUsersNew
;
}
++
countUsersNew
;
}
}
if
(
needChanged
)
{
for
(
i
in
participantsNew
)
{
if
(
!
this
.
_participants
[
i
])
{
tmpUser
=
participantsNew
[
i
];
tmpUser
.
setState
(
true
);
usersStateChanged
.
push
(
tmpUser
);
}
}
for
(
i
in
this
.
_participants
)
{
if
(
!
participantsNew
[
i
])
{
tmpUser
=
this
.
_participants
[
i
];
tmpUser
.
setState
(
false
);
usersStateChanged
.
push
(
tmpUser
);
}
}
}
this
.
_participants
=
participantsNew
;
this
.
_countEditUsers
=
countEditUsersNew
;
this
.
_countUsers
=
countUsersNew
;
return
usersStateChanged
;
};
DocsCoApi
.
prototype
.
_onAuthParticipantsChanged
=
function
(
participants
)
{
DocsCoApi
.
prototype
.
_onAuthParticipantsChanged
=
function
(
participants
)
{
this
.
_participants
=
{};
this
.
_participants
=
{};
this
.
_countEditUsers
=
0
;
this
.
_countEditUsers
=
0
;
this
.
_countUsers
=
0
;
this
.
_countUsers
=
0
;
if
(
participants
)
{
if
(
participants
)
{
var
tmpUser
;
this
.
_onParticipantsChanged
(
participants
);
for
(
var
i
=
0
;
i
<
participants
.
length
;
++
i
)
{
tmpUser
=
new
AscCommon
.
asc_CUser
(
participants
[
i
]);
this
.
_participants
[
tmpUser
.
asc_getId
()]
=
tmpUser
;
// Считаем только число редакторов
if
(
!
tmpUser
.
asc_getView
())
{
++
this
.
_countEditUsers
;
}
++
this
.
_countUsers
;
}
if
(
this
.
onAuthParticipantsChanged
)
{
if
(
this
.
onAuthParticipantsChanged
)
{
this
.
onAuthParticipantsChanged
(
this
.
_participants
,
this
.
_countUsers
);
this
.
onAuthParticipantsChanged
(
this
.
_participants
,
this
.
_countUsers
);
...
@@ -1323,39 +1357,24 @@
...
@@ -1323,39 +1357,24 @@
});
});
return
;
return
;
}
}
var
userStateChanged
=
null
,
userId
,
stateChanged
=
false
,
isEditUser
=
true
;
var
isWaitAuth
=
data
[
'
waitAuth
'
];
if
(
this
.
onConnectionStateChanged
)
{
var
usersStateChanged
;
userStateChanged
=
new
AscCommon
.
asc_CUser
(
data
[
'
user
'
]);
if
(
this
.
onConnectionStateChanged
&&
(
!
this
.
_participantsTimestamp
||
this
.
_participantsTimestamp
<=
data
[
'
participantsTimestamp
'
]))
{
userStateChanged
.
setState
(
data
[
"
state
"
]);
this
.
_participantsTimestamp
=
data
[
'
participantsTimestamp
'
];
usersStateChanged
=
this
.
_onParticipantsChanged
(
data
[
'
participants
'
],
true
);
userId
=
userStateChanged
.
asc_getId
();
isEditUser
=
!
userStateChanged
.
asc_getView
();
if
(
userStateChanged
.
asc_getState
()
&&
!
this
.
_participants
.
hasOwnProperty
(
userId
))
{
this
.
_participants
[
userId
]
=
userStateChanged
;
++
this
.
_countUsers
;
if
(
isEditUser
)
{
++
this
.
_countEditUsers
;
}
stateChanged
=
true
;
}
else
if
(
!
userStateChanged
.
asc_getState
()
&&
this
.
_participants
.
hasOwnProperty
(
userId
))
{
delete
this
.
_participants
[
userId
];
--
this
.
_countUsers
;
if
(
isEditUser
)
{
--
this
.
_countEditUsers
;
}
stateChanged
=
true
;
}
if
(
stateChanged
)
{
if
(
usersStateChanged
.
length
>
0
)
{
// Посылаем эвент о совместном редактировании
// Посылаем эвент о совместном редактировании
if
(
1
<
this
.
_countEditUsers
)
{
if
(
1
<
this
.
_countEditUsers
)
{
this
.
_onStartCoAuthoring
(
/*isStartEvent*/
false
);
this
.
_onStartCoAuthoring
(
/*isStartEvent*/
false
,
isWaitAuth
);
}
else
{
}
else
{
this
.
_onEndCoAuthoring
(
/*isStartEvent*/
false
);
this
.
_onEndCoAuthoring
(
/*isStartEvent*/
false
);
}
}
this
.
onParticipantsChanged
(
this
.
_participants
,
this
.
_countUsers
);
this
.
onParticipantsChanged
(
this
.
_participants
,
this
.
_countUsers
);
this
.
onConnectionStateChanged
(
userStateChanged
);
for
(
var
i
=
0
;
i
<
usersStateChanged
.
length
;
++
i
)
{
this
.
onConnectionStateChanged
(
usersStateChanged
[
i
]);
}
}
}
}
}
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment