1- import axiosInstance from "../utils/API/API" ;
21import {
3- ADD_LAYOUT_CONTAINER ,
4- CHANGE_ACTIVE_REMOTE_CONTAINER ,
5- CHANGE_DISTRACTION_FREE_MODE ,
6- CHANGE_LAYOUT_COLS ,
7- GET_CONFIG_FOR_REMOTE ,
8- GET_FILES_LIST ,
9- GET_REMOTE_LIST ,
10- REMOVE_LAYOUT_CONTAINER ,
11- REQUEST_ERROR ,
12- REQUEST_SUCCESS
2+ ADD_LAYOUT_CONTAINER ,
3+ CHANGE_ACTIVE_REMOTE_CONTAINER ,
4+ CHANGE_DISTRACTION_FREE_MODE ,
5+ CHANGE_LAYOUT_COLS ,
6+ GET_CONFIG_FOR_REMOTE ,
7+ GET_FILES_LIST ,
8+ GET_REMOTE_LIST ,
9+ REMOVE_LAYOUT_CONTAINER ,
10+ REQUEST_ERROR ,
11+ REQUEST_SUCCESS
1312} from "./types" ;
14- import { addColonAtLast , isLocalRemoteName , makeUniqueID } from "../utils/Tools" ;
13+ import { makeUniqueID } from "../utils/Tools" ;
1514import { createPath , removePath } from "./explorerStateActions" ;
16- import urls from "../utils/API/endpoint" ;
15+ import { getAllRemoteNames , getFilesList , getRemoteInfo } from "rclone-api"
1716
1817/**
1918 * Gets the information regarding features, hashes from the rclone backend. Stores into redux store.
2019 * @param remoteName {string} The name of the remote
2120 * @returns {Function }
2221 */
2322export const getFsInfo = ( remoteName ) => dispatch => {
24-
25- let sentRemoteName ;
26- let setRemoteName ;
27-
28- if ( isLocalRemoteName ( remoteName ) ) {
29- sentRemoteName = setRemoteName = "/" ;
30-
31- } else {
32- setRemoteName = remoteName . split ( ':' ) [ 0 ] ;
33- sentRemoteName = addColonAtLast ( setRemoteName ) ;
34- }
3523 // console.log("Actual: ", sentRemoteName);
36- axiosInstance . post ( urls . getFsInfo , { fs : sentRemoteName } )
37- . then ( ( res ) => {
38- dispatch ( {
39- type : GET_CONFIG_FOR_REMOTE ,
40- status : REQUEST_SUCCESS ,
41- payload : { [ setRemoteName ] : res . data } ,
42-
43- } )
44- } ,
45- error => dispatch ( {
24+ getRemoteInfo ( remoteName ) . then ( ( res ) => {
25+ dispatch ( {
4626 type : GET_CONFIG_FOR_REMOTE ,
47- status : REQUEST_ERROR ,
48- payload : error
49- } ) )
27+ status : REQUEST_SUCCESS ,
28+ payload : { [ remoteName . split ( ':' ) [ 0 ] ] : res } ,
29+
30+ } )
31+ } ,
32+ error => dispatch ( {
33+ type : GET_CONFIG_FOR_REMOTE ,
34+ status : REQUEST_ERROR ,
35+ payload : error
36+ } ) )
5037
5138} ;
5239
@@ -61,10 +48,10 @@ export const getRemoteNames = () => {
6148 // console.log(state);
6249 if ( ! state . remote . remotes || state . remote . remotes . length < 1 ) {
6350
64- axiosInstance . post ( urls . listRemotes ) . then ( res => dispatch ( {
51+ getAllRemoteNames ( ) . then ( res => dispatch ( {
6552 type : GET_REMOTE_LIST ,
6653 status : REQUEST_SUCCESS ,
67- payload : res . data . remotes
54+ payload : res . remotes
6855 } ) , error => dispatch ( {
6956 type : GET_REMOTE_LIST ,
7057 status : REQUEST_ERROR ,
@@ -81,25 +68,12 @@ export const getRemoteNames = () => {
8168 * @returns {Function }
8269 */
8370export const getFiles = ( remoteName , remotePath ) => dispatch => {
84- let newRemoteName = "" ;
8571 if ( remoteName !== "" ) {
86- if ( remoteName . indexOf ( '/' ) !== 0 ) { /*The name starts with a /: local Name*/
87- newRemoteName = addColonAtLast ( remoteName ) ;
88- } else {
89- newRemoteName = remoteName ;
90- }
91-
92-
93- let data = {
94- fs : newRemoteName ,
95- remote : remotePath
96- } ;
97-
9872 const path = `${ remoteName } -${ remotePath } ` ;
99- axiosInstance . post ( urls . getFilesList , data ) . then ( res => dispatch ( {
73+ getFilesList ( remoteName , remotePath ) . then ( res => dispatch ( {
10074 type : GET_FILES_LIST ,
10175 status : REQUEST_SUCCESS ,
102- payload : { path : path , filesList : res . data . list }
76+ payload : { path : path , filesList : res . list }
10377 } ) ,
10478 error => dispatch ( {
10579 type : GET_FILES_LIST ,
@@ -159,7 +133,7 @@ export const addRemoteContainer = (paneID) => (dispatch) => {
159133 * @returns {Function }
160134 */
161135export const removeRemoteContainer = ( containerID , paneID ) => ( dispatch ) => {
162- dispatch ( removePath ( containerID ) ) ;
136+ dispatch ( removePath ( containerID ) ) ;
163137 // console.log("Removing : " + containerID);
164138 dispatch ( {
165139 type : REMOVE_LAYOUT_CONTAINER ,
0 commit comments