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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
import types from '../../types'
const samplernnInitialState = {
loading: false,
error: null,
folder: {},
folders: [],
files: [],
results: [],
upload: {
loading: false,
status: '',
},
}
const samplernnReducer = (state = samplernnInitialState, action) => {
console.log(action)
switch(action.type) {
case types.socket.connect:
return {
...state,
}
case types.task.task_begin:
return {
...state,
}
case types.task.task_finish:
return {
...state,
}
case types.folder.index:
return {
...state,
folders: action.data,
folder: action.data[0],
}
case types.folder.update:
return state
case types.file.index:
return {
...state,
files: action.data
}
case types.folder.upload_loading:
return {
...state,
upload: {
loading: true,
status: 'Loading...',
},
}
case types.folder.upload_error:
return {
...state,
upload: {
loading: false,
status: 'Error uploading :(',
},
}
case types.folder.upload_progress:
console.log(action)
return {
...state,
upload: {
loading: true,
status: 'Upload progress ' + action.percent + '%',
},
}
case types.folder.upload_waiting:
console.log(action)
return {
...state,
upload: {
loading: true,
status: 'Waiting for server to finish processing...',
},
}
case types.file.create_loading:
return {
...state,
upload: {
loading: true,
status: 'Creating file...'
}
}
case types.file.create:
console.log('booo')
if (state.folder.id === action.data.folder_id) {
return {
...state,
files: [action.data].concat(state.files),
upload: {
loading: false,
status: 'File created',
},
}
} else {
return {
...state,
upload: {
loading: false,
status: 'created',
},
}
}
case types.folder.upload_complete:
console.log(action)
if (state.folder.id === action.folder) {
return {
...state,
files: [action.files].concat(state.files),
upload: {
loading: false,
status: 'Upload complete',
},
}
} else {
return {
...state,
upload: {
loading: false,
status: 'Upload complete',
},
}
}
case types.socket.status:
return samplernnSocket(state, action.data)
default:
return state
}
}
const samplernnSocket = (state, action) => {
console.log(action)
switch (action.key) {
default:
return state
}
}
export default samplernnReducer
|