@seafile/sdoc-editor 0.1.11 → 0.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -63,10 +63,10 @@ var SocketClient = /*#__PURE__*/_createClass(function SocketClient(config) {
63
63
  var socketManager = SocketManager.getInstance();
64
64
  socketManager.dispatchConnectState('connect_error');
65
65
  };
66
- this.onJoinRoom = function (username) {
67
- debug('%s joined room success.', username);
66
+ this.onJoinRoom = function (userInfo) {
67
+ debug('%s joined room success.', userInfo.username);
68
68
  var socketManager = SocketManager.getInstance();
69
- socketManager.dispatchConnectState('join-room', username);
69
+ socketManager.dispatchConnectState('join-room', userInfo);
70
70
  };
71
71
  this.onLeaveRoom = function (username) {
72
72
  debug('%s leaved room success.', username);
@@ -6,7 +6,6 @@ import React, { Fragment } from 'react';
6
6
  import { EventBus } from '../../../basic-sdk';
7
7
  import context from '../../../context';
8
8
  import CollaboratorsPopover from './collaborators-popover';
9
- var URL = 'https://tupian.qqw21.com/article/UploadPic/2020-8/20208522181570993.jpg';
10
9
  var CollaboratorsOperation = /*#__PURE__*/function (_React$PureComponent) {
11
10
  _inherits(CollaboratorsOperation, _React$PureComponent);
12
11
  var _super = _createSuper(CollaboratorsOperation);
@@ -14,21 +13,13 @@ var CollaboratorsOperation = /*#__PURE__*/function (_React$PureComponent) {
14
13
  var _this;
15
14
  _classCallCheck(this, CollaboratorsOperation);
16
15
  _this = _super.call(this, props);
17
- _this.getUserInfo = function (username) {
18
- return {
19
- name: username,
20
- username: username,
21
- avatar_url: URL
22
- };
23
- };
24
- _this.onUserJoinRoom = function (username) {
16
+ _this.onUserJoinRoom = function (userInfo) {
25
17
  var collaborators = _this.state.collaborators;
26
18
  var newCollaborators = collaborators.slice();
27
19
  if (!newCollaborators.find(function (user) {
28
- return user.username === username;
20
+ return user.username === userInfo.username;
29
21
  })) {
30
- var newUser = _this.getUserInfo(username);
31
- newCollaborators.push(newUser);
22
+ newCollaborators.push(userInfo);
32
23
  _this.setState({
33
24
  collaborators: newCollaborators
34
25
  });
@@ -49,11 +40,11 @@ var CollaboratorsOperation = /*#__PURE__*/function (_React$PureComponent) {
49
40
  });
50
41
  }
51
42
  };
52
- var _username = context.getSetting('username');
53
- _this.currentUser = _this.getUserInfo(_username);
43
+ var _userInfo = context.getUserInfo();
54
44
  _this.state = {
55
- collaborators: [_this.currentUser]
45
+ collaborators: [_userInfo]
56
46
  };
47
+ _this.currentUser = _userInfo;
57
48
  return _this;
58
49
  }
59
50
  _createClass(CollaboratorsOperation, [{
@@ -62,19 +53,17 @@ var CollaboratorsOperation = /*#__PURE__*/function (_React$PureComponent) {
62
53
  var _this2 = this;
63
54
  context.getCollaborators().then(function (res) {
64
55
  var collaborators = res.data.collaborators;
65
- var newCollaborators = collaborators.map(function (item) {
66
- return _this2.getUserInfo(item);
67
- });
56
+
68
57
  // delete current user and push it at first one
69
- var currentUserIndex = newCollaborators.findIndex(function (user) {
58
+ var currentUserIndex = collaborators.findIndex(function (user) {
70
59
  return user.username === _this2.currentUser.username;
71
60
  });
72
61
  if (currentUserIndex > -1) {
73
- newCollaborators.splice(currentUserIndex, 1);
62
+ collaborators.splice(currentUserIndex, 1);
74
63
  }
75
- newCollaborators.unshift(_this2.currentUser);
64
+ collaborators.unshift(_this2.currentUser);
76
65
  _this2.setState({
77
- collaborators: newCollaborators
66
+ collaborators: collaborators
78
67
  });
79
68
  });
80
69
  var eventBus = EventBus.getInstance();
@@ -20,12 +20,15 @@ var TipMessage = /*#__PURE__*/function (_React$Component) {
20
20
  });
21
21
  };
22
22
  _this.onDocumentSaved = function () {
23
- _this.setState({
24
- isSaving: false,
25
- isSaved: true
26
- });
27
23
  if (_this.saveTimer) clearTimeout(_this.saveTimer);
24
+ if (_this.resetTimer) clearTimeout(_this.resetTimer);
28
25
  _this.saveTimer = setTimeout(function () {
26
+ _this.setState({
27
+ isSaving: false,
28
+ isSaved: true
29
+ });
30
+ }, 1000);
31
+ _this.resetTimer = setTimeout(function () {
29
32
  _this.setState({
30
33
  isSaving: false,
31
34
  isSaved: false
package/dist/context.js CHANGED
@@ -150,6 +150,18 @@ var Context = /*#__PURE__*/function () {
150
150
  value: function getCollaborators() {
151
151
  return this.sdocServerApi.getCollaborators();
152
152
  }
153
+ }, {
154
+ key: "getUserInfo",
155
+ value: function getUserInfo() {
156
+ var name = this.getSetting('name');
157
+ var username = this.getSetting('username');
158
+ var avatarURL = this.getSetting('avatarURL');
159
+ return {
160
+ name: name,
161
+ username: username,
162
+ avatar_url: avatarURL
163
+ };
164
+ }
153
165
  }]);
154
166
  return Context;
155
167
  }();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seafile/sdoc-editor",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "private": false,
5
5
  "description": "This is a sdoc editor",
6
6
  "main": "dist/index.js",