@electerm/electerm-react 1.51.3 → 1.51.18

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.
Files changed (86) hide show
  1. package/client/common/constants.js +15 -1
  2. package/client/common/db.js +10 -9
  3. package/client/common/default-setting.js +0 -1
  4. package/client/common/is-color-dark.js +15 -11
  5. package/client/common/new-terminal.js +2 -5
  6. package/client/common/reverse-color.js +12 -0
  7. package/client/common/ws.js +4 -1
  8. package/client/components/batch-op/batch-op.jsx +16 -5
  9. package/client/components/bookmark-form/index.jsx +1 -1
  10. package/client/components/bookmark-form/render-connection-hopping.jsx +25 -2
  11. package/client/components/bookmark-form/ssh-form.jsx +4 -25
  12. package/client/components/bookmark-form/tree-delete.jsx +5 -10
  13. package/client/components/bookmark-form/use-submit.jsx +6 -15
  14. package/client/components/bookmark-form/use-ui.jsx +1 -2
  15. package/client/components/common/connection-hopping-warning-text.jsx +36 -0
  16. package/client/components/common/drag-handle.jsx +60 -0
  17. package/client/components/common/drag-handle.styl +12 -0
  18. package/client/components/context-menu/context-menu.styl +5 -5
  19. package/client/components/context-menu/history.jsx +2 -11
  20. package/client/components/context-menu/sub-tab-menu.jsx +1 -1
  21. package/client/components/footer/footer-entry.jsx +1 -6
  22. package/client/components/layout/layout-item.jsx +2 -2
  23. package/client/components/layout/layout.jsx +3 -2
  24. package/client/components/main/connection-hopping-warnning.jsx +45 -0
  25. package/client/components/main/error-wrapper.jsx +120 -5
  26. package/client/components/main/main.jsx +32 -8
  27. package/client/components/main/upgrade.jsx +4 -9
  28. package/client/components/main/wrapper.styl +2 -1
  29. package/client/components/profile/profile-form-ssh.jsx +1 -1
  30. package/client/components/rdp/resolution-edit.jsx +3 -5
  31. package/client/components/session/session.jsx +22 -3
  32. package/client/components/session/session.styl +3 -2
  33. package/client/components/setting-panel/list.styl +0 -1
  34. package/client/components/setting-panel/on-tree-drop.js +5 -5
  35. package/client/components/setting-panel/setting-common.jsx +28 -7
  36. package/client/components/setting-panel/setting-modal.jsx +0 -12
  37. package/client/components/setting-panel/setting-terminal.jsx +7 -4
  38. package/client/components/sftp/confirm-modal-store.jsx +3 -11
  39. package/client/components/sftp/file-mode-modal.jsx +2 -2
  40. package/client/components/sftp/sftp-entry.jsx +4 -7
  41. package/client/components/sftp/transfer-conflict-store.jsx +70 -69
  42. package/client/components/sftp/transport-action-store.jsx +42 -49
  43. package/client/components/sftp/transports-action-store.jsx +15 -15
  44. package/client/components/sftp/transports-ui-store.jsx +9 -5
  45. package/client/components/side-panel-r/side-panel-r.jsx +13 -40
  46. package/client/components/sidebar/bookmark-select.jsx +1 -4
  47. package/client/components/sidebar/bookmark.jsx +4 -63
  48. package/client/components/sidebar/history-item.jsx +34 -0
  49. package/client/components/sidebar/history.jsx +17 -52
  50. package/client/components/sidebar/index.jsx +5 -40
  51. package/client/components/sidebar/side-panel.jsx +27 -51
  52. package/client/components/sidebar/sidebar-panel.jsx +107 -0
  53. package/client/components/sidebar/sidebar.styl +14 -9
  54. package/client/components/sidebar/transfer-list-control.jsx +1 -0
  55. package/client/components/sidebar/transfer.styl +1 -1
  56. package/client/components/sidebar/transport-ui.jsx +179 -37
  57. package/client/components/ssh-config/load-ssh-configs.jsx +106 -0
  58. package/client/components/ssh-config/ssh-config-item.jsx +26 -0
  59. package/client/components/ssh-config/ssh-config-load-notify.jsx +60 -0
  60. package/client/components/tabs/index.jsx +4 -4
  61. package/client/components/tabs/tab.jsx +28 -20
  62. package/client/components/tabs/tabs.styl +6 -1
  63. package/client/components/terminal/index.jsx +4 -18
  64. package/client/components/tree-list/bookmark-toolbar.jsx +203 -0
  65. package/client/components/tree-list/bookmark-transport.jsx +2 -0
  66. package/client/components/tree-list/tree-list.jsx +33 -42
  67. package/client/entry/worker.js +5 -3
  68. package/client/store/bookmark-group.js +5 -18
  69. package/client/store/bookmark.js +43 -1
  70. package/client/store/common.js +13 -9
  71. package/client/store/db-upgrade.js +0 -2
  72. package/client/store/index.js +45 -53
  73. package/client/store/init-state.js +20 -23
  74. package/client/store/item.js +0 -19
  75. package/client/store/load-data.js +7 -10
  76. package/client/store/setting.js +10 -66
  77. package/client/store/sidebar.js +7 -8
  78. package/client/store/sync.js +7 -8
  79. package/client/store/tab.js +93 -14
  80. package/client/store/terminal-theme.js +1 -1
  81. package/client/store/transfer-history.js +3 -9
  82. package/client/store/transfer-list.js +67 -75
  83. package/client/store/ui-theme.js +0 -9
  84. package/client/store/watch.js +17 -9
  85. package/package.json +1 -1
  86. package/client/components/setting-panel/tab-history.jsx +0 -43
@@ -11,6 +11,7 @@ import { FolderOutlined, FileOutlined } from '@ant-design/icons'
11
11
  import {
12
12
  fileActions
13
13
  } from '../../common/constants'
14
+ import deepCopy from 'json-deep-copy'
14
15
  import postMessage from '../../common/post-msg'
15
16
 
16
17
  const e = window.translate
@@ -25,9 +26,7 @@ function formatTimeAuto (strOrDigit) {
25
26
  export default function ConfirmModalStore (props) {
26
27
  function act (action) {
27
28
  const { transferToConfirm } = props
28
- window.store.setState(
29
- 'transferToConfirm', {}
30
- )
29
+ window.store.transferToConfirm = {}
31
30
  const {
32
31
  fromFile: {
33
32
  id: fileId
@@ -39,7 +38,7 @@ export default function ConfirmModalStore (props) {
39
38
  transferGroupId,
40
39
  fileId,
41
40
  id,
42
- transfer: transferToConfirm,
41
+ transfer: deepCopy(transferToConfirm),
43
42
  action
44
43
  })
45
44
  }
@@ -129,13 +128,6 @@ export default function ConfirmModalStore (props) {
129
128
  >
130
129
  {e('skip')}
131
130
  </Button>
132
- <Button
133
- type='dashed'
134
- className='mg1l'
135
- onClick={() => act(fileActions.skipAll)}
136
- >
137
- {e('skipAll')}
138
- </Button>
139
131
  <Button
140
132
  danger
141
133
  className='mg1l'
@@ -6,7 +6,7 @@ import React from 'react'
6
6
  import { Modal, Button } from 'antd'
7
7
  import resolve from '../../common/resolve'
8
8
  import time from '../../common/time'
9
- import { findIndex, update } from 'lodash-es'
9
+ import { update } from 'lodash-es'
10
10
  import { mode2permission, permission2mode } from '../../common/mode2permission'
11
11
  import { commonActions } from '../../common/constants'
12
12
  import renderPermission from './permission-render'
@@ -65,7 +65,7 @@ export default class FileMode extends React.PureComponent {
65
65
  onChangePermission = (name, permName) => {
66
66
  const { file } = this.state
67
67
  const perms = mode2permission(file.mode)
68
- const i = findIndex(perms, p => p.name === name)
68
+ const i = perms.findIndex(p => p.name === name)
69
69
  update(
70
70
  perms,
71
71
  `[${i}].permission.${permName}`,
@@ -2,7 +2,7 @@ import { Component } from 'react'
2
2
  import generate from '../../common/uid'
3
3
  import runIdle from '../../common/run-idle'
4
4
  import { Spin, Modal, notification } from 'antd'
5
- import { find, isString, findIndex, isEqual, last, isNumber, some, isArray, pick, uniq, debounce } from 'lodash-es'
5
+ import { find, isString, isEqual, last, isNumber, some, isArray, pick, uniq, debounce } from 'lodash-es'
6
6
  import FileSection from './file-item'
7
7
  import resolve from '../../common/resolve'
8
8
  import wait from '../../common/wait'
@@ -14,7 +14,6 @@ import {
14
14
  typeMap, maxSftpHistory, paneMap,
15
15
  eventTypes,
16
16
  fileTypeMap,
17
- terminalSshConfigType,
18
17
  terminalSerialType,
19
18
  unexpectedPacketErrorDesc,
20
19
  sftpRetryInterval,
@@ -207,7 +206,7 @@ export default class Sftp extends Component {
207
206
  action === commonActions.sftpList &&
208
207
  sessionId === this.props.sessionId
209
208
  ) {
210
- this[type + 'List']()
209
+ this[type + 'ListDebounce']()
211
210
  }
212
211
  }
213
212
 
@@ -264,7 +263,7 @@ export default class Sftp extends Component {
264
263
 
265
264
  getIndex = (file) => {
266
265
  const { type } = file
267
- return findIndex(this.getFileList(type), f => f.id === file.id)
266
+ return this.getFileList(type).findIndex(f => f.id === file.id)
268
267
  }
269
268
 
270
269
  onResizeDragEnd = () => {
@@ -482,9 +481,7 @@ export default class Sftp extends Component {
482
481
 
483
482
  shouldRenderRemote = () => {
484
483
  const { props } = this
485
- return props.tab?.host &&
486
- props.tab?.type !== terminalSshConfigType &&
487
- props.tab?.type !== terminalSerialType
484
+ return props.tab?.host && props.tab?.type !== terminalSerialType
488
485
  }
489
486
 
490
487
  initLocalAll = () => {
@@ -12,9 +12,11 @@ import {
12
12
  getFileExt,
13
13
  checkFolderSize
14
14
  } from './file-read'
15
- import { findIndex, find } from 'lodash-es'
16
15
  import generate from '../../common/uid'
17
16
  import resolve from '../../common/resolve'
17
+ import deepCopy from 'json-deep-copy'
18
+
19
+ const { assign } = Object
18
20
 
19
21
  export default class TransferConflictStore extends PureComponent {
20
22
  state = {
@@ -27,7 +29,7 @@ export default class TransferConflictStore extends PureComponent {
27
29
 
28
30
  componentDidUpdate (prevProps) {
29
31
  if (
30
- prevProps._fileTransfers !== this.props._fileTransfers
32
+ prevProps.fileTransferChanged !== this.props.fileTransferChanged
31
33
  ) {
32
34
  this.watchFile()
33
35
  }
@@ -56,17 +58,16 @@ export default class TransferConflictStore extends PureComponent {
56
58
  const newName = ext
57
59
  ? `${base}(rename-${renameId}).${ext}`
58
60
  : `${base}(rename-${renameId})`
59
- const res = {
60
- ...tr,
61
+ assign(tr, {
61
62
  renameId,
62
63
  newName,
63
64
  oldName: base,
64
65
  toPath: resolve(path, newName)
65
- }
66
+ })
66
67
  if (action) {
67
- res.action = action
68
+ tr.action = action
68
69
  }
69
- return res
70
+ return tr
70
71
  }
71
72
 
72
73
  updateTransferAction = (data) => {
@@ -79,65 +80,55 @@ export default class TransferConflictStore extends PureComponent {
79
80
  fromFile
80
81
  } = transfer
81
82
  this.clear()
82
- let { fileTransfers } = this.props
83
+
83
84
  const { store } = window
84
- const index = findIndex(fileTransfers, d => d.id === id)
85
+ const { fileTransfers } = store
86
+ const index = fileTransfers.findIndex(d => d.id === id)
85
87
  if (index < 0) {
86
- return store.setFileTransfers(fileTransfers)
88
+ return
87
89
  }
88
- fileTransfers[index].fromFile = fromFile
89
- fileTransfers[index].action = action
90
+ const tr = fileTransfers[index]
91
+ tr.fromFile = deepCopy(fromFile)
92
+ tr.action = action
93
+ tr.r = Math.random()
90
94
  if (action === 'skip') {
91
- fileTransfers.splice(index, 1)
95
+ return fileTransfers.splice(index, 1)
92
96
  } else if (action === 'cancel') {
93
- fileTransfers = fileTransfers.slice(0, index)
97
+ return store.skipAllTransfersSinceIndex(index)
94
98
  }
95
99
  if (action.includes('All')) {
96
- fileTransfers = fileTransfers.map((t, i) => {
97
- if (i < index) {
98
- return t
99
- }
100
- return {
101
- ...t,
102
- action: action.replace('All', '')
103
- }
100
+ return store.updateTransfersFromIndex(index, {
101
+ action: action.replace('All', '')
104
102
  })
105
103
  }
106
104
  if (action.includes('rename')) {
107
- fileTransfers[index] = this.rename(fileTransfers[index])
108
- } else if (action === 'skipAll') {
109
- fileTransfers.splice(index, 1)
105
+ return this.rename(tr)
110
106
  }
111
- store.setFileTransfers(fileTransfers)
112
107
  }
113
108
 
114
109
  tagTransferError = (id, errorMsg) => {
115
- const { fileTransfers } = this.props
116
- const tr = find(fileTransfers, d => d.id === id)
117
- if (!tr) {
110
+ this.clear()
111
+ const { store } = window
112
+ const { fileTransfers } = store
113
+ const index = fileTransfers.findIndex(d => d.id === id)
114
+ if (index < 0) {
118
115
  return
119
116
  }
120
- const { store } = window
121
- store.addTransferHistory({
122
- ...tr,
117
+
118
+ const [tr] = fileTransfers.splice(index, 1)
119
+ assign(tr, {
123
120
  host: tr.host,
124
121
  error: errorMsg,
125
122
  finishTime: Date.now()
126
123
  })
127
- const index = findIndex(fileTransfers, d => d.id === id)
128
- if (index >= 0) {
129
- fileTransfers.splice(index, 1)
130
- }
131
- store.setFileTransfers(fileTransfers)
124
+ store.addTransferHistory(tr)
132
125
  }
133
126
 
134
127
  setConflict (tr) {
135
128
  if (this.props.transferToConfirm.id) {
136
129
  return
137
130
  }
138
- window.store.setState(
139
- 'transferToConfirm', tr
140
- )
131
+ window.store.transferToConfirm = tr
141
132
  }
142
133
 
143
134
  onDecision = (event) => {
@@ -157,6 +148,18 @@ export default class TransferConflictStore extends PureComponent {
157
148
  window.addEventListener('message', this.onDecision)
158
149
  }
159
150
 
151
+ updateData = () => {
152
+ const {
153
+ store
154
+ } = window
155
+ const {
156
+ fileTransfers
157
+ } = store
158
+ if (fileTransfers.length > 0) {
159
+ fileTransfers[0].r = Math.random()
160
+ }
161
+ }
162
+
160
163
  setCanTransfer = (fromFile, tr) => {
161
164
  this.clear()
162
165
  const {
@@ -164,20 +167,20 @@ export default class TransferConflictStore extends PureComponent {
164
167
  } = window
165
168
  const {
166
169
  fileTransfers
167
- } = this.props
168
- const index = findIndex(fileTransfers, t => {
170
+ } = store
171
+ const index = fileTransfers.findIndex(t => {
169
172
  return t.id === tr.id
170
173
  })
171
- if (index >= 0) {
172
- const up = {
173
- action: 'transfer',
174
- fromFile
175
- }
176
- Object.assign(fileTransfers[index], up)
177
- } else if (fileTransfers[0]) {
178
- fileTransfers[0].r = Math.random()
174
+ if (index < 0) {
175
+ setTimeout(this.updateData, 0)
176
+ return
179
177
  }
180
- store.setFileTransfers(fileTransfers)
178
+ const up = {
179
+ action: 'transfer',
180
+ fromFile
181
+ }
182
+ assign(fileTransfers[index], up)
183
+ // may have issue
181
184
  }
182
185
 
183
186
  clear = () => {
@@ -188,25 +191,24 @@ export default class TransferConflictStore extends PureComponent {
188
191
  const { store } = window
189
192
  const {
190
193
  fileTransfers
191
- } = this.props
192
- if (!fileTransfers.length && this.currentId) {
194
+ } = store
195
+ if (!fileTransfers.length) {
193
196
  return this.clear()
194
197
  }
195
198
  const tr = fileTransfers
196
- .filter(t => {
199
+ .find(t => {
197
200
  return (
198
201
  !t.action ||
199
202
  !t.fromFile ||
200
203
  t.fromFile.isDirectory
201
204
  )
202
- })[0]
205
+ })
203
206
  if (!tr) {
204
207
  this.onConfirm = false
205
208
  return this.clear()
206
209
  }
207
210
  if (this.currentId) {
208
- // fileTransfers[0].r = Math.random()
209
- return store.setFileTransfers(fileTransfers)
211
+ return
210
212
  }
211
213
  this.currentId = tr.id
212
214
  const {
@@ -225,7 +227,6 @@ export default class TransferConflictStore extends PureComponent {
225
227
  ? tr.fromFile
226
228
  : await this.checkExist(typeFrom, fromPath, sessionId)
227
229
  if (!fromFile) {
228
- this.currentId = ''
229
230
  return this.tagTransferError(id, 'file not exist')
230
231
  }
231
232
  let toFile = false
@@ -249,33 +250,33 @@ export default class TransferConflictStore extends PureComponent {
249
250
  tr.skipExpand = true
250
251
  }
251
252
  if (fromPath === toPath && typeFrom === typeTo) {
253
+ assign(tr, {
254
+ operation: 'cp',
255
+ fromFile
256
+ })
252
257
  return this.updateTransferAction({
253
258
  id,
254
259
  action: 'rename',
255
- transfer: {
256
- ...tr,
257
- operation: 'cp',
258
- fromFile
259
- }
260
+ transfer: tr
260
261
  })
261
262
  } else if (toFile && !action && !skipConfirm) {
262
263
  this.waitForSignal(id)
263
264
  if (!this.onConfirm) {
264
265
  this.onConfirm = true
265
- return this.setConflict({
266
- ...tr,
266
+ assign(tr, {
267
267
  fromFile,
268
268
  toFile
269
269
  })
270
+ return this.setConflict(tr)
270
271
  }
271
272
  } else if (toFile && !tr.fromFile && action) {
273
+ assign(tr, {
274
+ fromFile
275
+ })
272
276
  return this.updateTransferAction({
273
277
  id,
274
278
  action,
275
- transfer: {
276
- ...tr,
277
- fromFile
278
- }
279
+ transfer: tr
279
280
  })
280
281
  }
281
282
  this.setCanTransfer(fromFile, tr)
@@ -1,11 +1,13 @@
1
1
  import { Component } from 'react'
2
2
  import copy from 'json-deep-copy'
3
- import { findIndex, isFunction } from 'lodash-es'
3
+ import { isFunction } from 'lodash-es'
4
4
  import generate from '../../common/uid'
5
5
  import { typeMap, transferTypeMap, commonActions } from '../../common/constants'
6
6
  import fs from '../../common/fs'
7
7
  import format, { computeLeftTime, computePassedTime } from './transfer-speed-format'
8
- import { getFolderFromFilePath } from './file-read'
8
+ import {
9
+ getFolderFromFilePath
10
+ } from './file-read'
9
11
  import resolve from '../../common/resolve'
10
12
  import delay from '../../common/wait'
11
13
  import postMsg from '../../common/post-msg'
@@ -35,15 +37,9 @@ export default class TransportAction extends Component {
35
37
  this.initTransfer()
36
38
  }
37
39
  if (
38
- this.props.cancel === true &&
39
- prevProps.cancel !== true
40
+ this.props.pausing !== prevProps.pausing
40
41
  ) {
41
- this.cancel()
42
- }
43
- if (
44
- this.props.pause !== prevProps.pause
45
- ) {
46
- if (this.props.pause) {
42
+ if (this.props.pausing) {
47
43
  this.pause()
48
44
  } else {
49
45
  this.resume()
@@ -54,32 +50,24 @@ export default class TransportAction extends Component {
54
50
  componentWillUnmount () {
55
51
  this.transport && this.transport.destroy()
56
52
  this.transport = null
57
- clearTimeout(this.timer)
58
- this.timer = null
53
+ this.inst = null
59
54
  }
60
55
 
61
56
  update = (up) => {
62
- const { fileTransfers, transfer } = this.props
57
+ const { transfer } = this.props
63
58
  const {
64
59
  store
65
60
  } = window
66
- const index = findIndex(fileTransfers, t => t.id === transfer.id)
67
- if (index < 0) {
68
- return store.setFileTransfers(fileTransfers)
69
- }
70
- store.editTransfer(
71
- fileTransfers[index].id,
61
+ store.updateTransfer(
62
+ transfer.id,
72
63
  up
73
64
  )
74
- Object.assign(fileTransfers[index], up)
75
- store.setFileTransfers(fileTransfers)
76
65
  }
77
66
 
78
67
  insert = (insts) => {
79
- const { fileTransfers, transfer } = this.props
80
- const index = findIndex(fileTransfers, t => t.id === transfer.id)
68
+ const { fileTransfers } = window.store
69
+ const { index } = this.props
81
70
  fileTransfers.splice(index, 1, ...insts)
82
- window.store.setFileTransfers(fileTransfers)
83
71
  }
84
72
 
85
73
  remoteList = () => {
@@ -110,23 +98,38 @@ export default class TransportAction extends Component {
110
98
  typeTo,
111
99
  next
112
100
  } = transfer
113
- const cb = this[typeTo + 'List']
114
101
  const finishTime = Date.now()
115
102
  if (!config.disableTransferHistory) {
103
+ const r = copy(transfer)
104
+ delete transfer.next
105
+ Object.assign(r, update, {
106
+ finishTime,
107
+ startTime: this.startTime,
108
+ size: transfer.fromFile.size,
109
+ next: null,
110
+ speed: format(transfer.fromFile.size, this?.startTime)
111
+ })
116
112
  window.store.addTransferHistory(
117
- {
118
- ...transfer,
119
- ...update,
120
- finishTime,
121
- startTime: this.startTime,
122
- size: transfer.fromFile.size,
123
- next: null,
124
- speed: format(transfer.fromFile.size, this?.startTime)
125
- }
113
+ r
126
114
  )
127
115
  }
116
+ const cbs = [
117
+ this[typeTo + 'List']
118
+ ]
128
119
  if (next) {
129
- this.insert([copy(next)])
120
+ cbs.push(() => {
121
+ setTimeout(
122
+ () => {
123
+ window.store.fileTransfers.splice(
124
+ this.props.index, 0, copy(next)
125
+ )
126
+ },
127
+ 100
128
+ )
129
+ })
130
+ }
131
+ const cb = () => {
132
+ cbs.forEach(cb => cb())
130
133
  }
131
134
  this.cancel(cb)
132
135
  }
@@ -160,21 +163,11 @@ export default class TransportAction extends Component {
160
163
  return
161
164
  }
162
165
  this.onCancel = true
163
- const {
164
- transfer
165
- } = this.props
166
- let {
167
- fileTransfers
168
- } = this.props
169
- const { id } = transfer
170
166
  this.transport && this.transport.destroy()
171
167
  this.transport = null
172
- fileTransfers = fileTransfers.filter(t => {
173
- return t.id !== id
174
- })
175
- this.timer = setTimeout(() => {
176
- window.store.setFileTransfers(fileTransfers)
177
- }, 100)
168
+ window.store.fileTransfers.splice(
169
+ this.props.index, 1
170
+ )
178
171
  if (isFunction(callback)) {
179
172
  callback()
180
173
  }
@@ -247,9 +240,9 @@ export default class TransportAction extends Component {
247
240
  originalId: transfer.id,
248
241
  id: generate()
249
242
  }
250
- delete newTrans1.fromFile
251
243
  delete newTrans1.inited
252
244
  delete newTrans1.zip
245
+ delete newTrans1.fromFile
253
246
  const newTrans2 = copy(newTrans1)
254
247
  newTrans2.unzip = true
255
248
  newTrans2.id = generate()
@@ -14,7 +14,7 @@ export default class TransportsActionStore extends Component {
14
14
 
15
15
  componentDidUpdate (prevProps) {
16
16
  if (
17
- prevProps._fileTransfers !== this.props._fileTransfers
17
+ prevProps.fileTransferChanged !== this.props.fileTransferChanged
18
18
  ) {
19
19
  this.control()
20
20
  }
@@ -22,11 +22,11 @@ export default class TransportsActionStore extends Component {
22
22
 
23
23
  control = async () => {
24
24
  const { store } = window
25
- let {
25
+ const {
26
26
  fileTransfers
27
- } = this.props
27
+ } = store
28
28
 
29
- fileTransfers = fileTransfers.map(t => {
29
+ fileTransfers.forEach(t => {
30
30
  const {
31
31
  typeTo,
32
32
  typeFrom,
@@ -37,7 +37,6 @@ export default class TransportsActionStore extends Component {
37
37
  if (typeTo === typeFrom && ready && !inited) {
38
38
  t.inited = true
39
39
  }
40
- return t
41
40
  })
42
41
  // if (pauseAllTransfer) {
43
42
  // return store.setFileTransfers(fileTransfers)
@@ -46,15 +45,16 @@ export default class TransportsActionStore extends Component {
46
45
  const {
47
46
  typeTo,
48
47
  typeFrom,
49
- inited
48
+ inited,
49
+ pausing
50
50
  } = t
51
- return typeTo !== typeFrom && inited
51
+ return typeTo !== typeFrom && inited && pausing !== true
52
52
  }).length
53
53
  if (count >= maxTransport) {
54
- return store.setFileTransfers(fileTransfers)
54
+ return
55
55
  }
56
56
  const len = fileTransfers.length
57
- const ids = []
57
+ // const ids = []
58
58
  for (let i = 0; i < len; i++) {
59
59
  const tr = fileTransfers[i]
60
60
  const {
@@ -62,13 +62,11 @@ export default class TransportsActionStore extends Component {
62
62
  typeFrom,
63
63
  inited,
64
64
  fromFile,
65
- error,
66
- id,
67
65
  action
68
66
  } = tr
69
- if (!error) {
70
- ids.push(id)
71
- }
67
+ // if (!error) {
68
+ // ids.push(id)
69
+ // }
72
70
  const isTransfer = typeTo !== typeFrom
73
71
  const ready = (
74
72
  action && fromFile
@@ -90,8 +88,10 @@ export default class TransportsActionStore extends Component {
90
88
  count++
91
89
  tr.inited = true
92
90
  }
91
+ if (count >= maxTransport) {
92
+ break
93
+ }
93
94
  }
94
- store.setFileTransfers(fileTransfers)
95
95
  }
96
96
 
97
97
  render () {
@@ -11,13 +11,17 @@ export default function TransportsUI (props) {
11
11
  }
12
12
  return fileTransfers.map((t, i) => {
13
13
  const { id } = t
14
+ const trProps = {
15
+ transfer: t,
16
+ index: i,
17
+ inited: t.inited,
18
+ cancel: t.cancel,
19
+ pausing: t.pausing,
20
+ config: props.config
21
+ }
14
22
  return (
15
23
  <Transport
16
- {...props}
17
- transfer={t}
18
- inited={t.inited}
19
- cancel={t.cancel}
20
- pause={t.pausing}
24
+ {...trProps}
21
25
  key={id + ':tr:' + i}
22
26
  />
23
27
  )