-
Notifications
You must be signed in to change notification settings - Fork 0
/
Util.js
62 lines (55 loc) · 1.42 KB
/
Util.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
//@flow
export function getUploadData(state, upload) {
const uploadObj = state.upload.get(upload)
return uploadObj
}
export function getUploadedCount(state, upload) {
const uploadObj = getUploadData(state, upload)
if(uploadObj) {
return uploadObj.uploadedQueue.size
}
return 0
}
export function getWattingCount(state, upload) {
const uploadObj = getUploadData(state, upload)
if(uploadObj) {
return uploadObj.wattingQueue.size
}
return 0
}
export function getFailedCount(state, upload) {
const uploadObj = getUploadData(state, upload)
if(uploadObj) {
return uploadObj.failedQueue.size
}
return 0
}
export function hasAllsccess(state, upload) {
if(getWattingCount(state, upload) == 0 && getFailedCount(state, upload) == 0) {
return true
}
return false
}
export function getUpdateItemID(uploadObj, name) {
let id = ''
if(uploadObj) {
const uploadedQueue = uploadObj.get('uploadedQueue')
uploadedQueue.forEach((value) => {
if(value.get('name') === name) {
id = value.get('id')
return
}
})
}
return id
}
export function getUpdatedIDs(uploadObj) {
let ids = []
if(uploadObj) {
const uploadedQueue = uploadObj.get('uploadedQueue')
uploadedQueue.forEach((value) => {
ids.push(value.get('id'))
})
}
return ids
}