Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function* renameFile(action) {
// Redux state 'files'
let state = yield select(state => state.files)
let newFileName = yield call(preprocessFileName, action.payload.newName)
let isFileNameValid = yield call(validateFileName, action.payload.newName)
if (!isFileNameValid) {
// Invalid filename
console.log(
'%cFile renaming failed: New filename ' +
'(' + action.payload.file.module + ')' +
' is invalid', 'color: red'
)
yield put(fileNameInvalid(action.payload.file.module))
return
}
let oldFile = Object.assign({}, action.payload.file)
// Extract Parent's Path
let parentPath = yield call(extractParentsPath, action.payload.file)
export function* loginFlow(): Generator<*, void, *> {
while (true) {
try {
const { payload }: LoginRequestAction = yield take(types.LOGIN_REQUEST);
yield call(infoLog, 'loginFlow started', payload);
const host = yield select(getHost);
if (!payload.host || (!(payload.host instanceof URL) && host instanceof URL)) {
// $FlowFixMe
payload.host = host;
}
yield call(clearLoginError);
yield put(profileActions.setLoginFetching(true));
const chronosBackendLoginSuccess: boolean = yield call(chronosBackendLogin, payload);
if (chronosBackendLoginSuccess) {
const jiraLoginSuccess: boolean = yield call(jiraLogin, payload);
if (jiraLoginSuccess) {
yield call(setToStorage, 'jira_credentials', { username: payload.username, password: '', host: payload.host.origin });
yield call((): void => { ipcRenderer.sendSync('store-credentials', payload); });
yield call(afterLogin);
}
}
yield put(profileActions.setLoginFetching(false));
it('should select getStaticNodeFromId', () => {
expect(gen.next(true).value).toEqual(select(selectors.getStaticNodeFromId, payload));
});
function* loadBalances(data) {
yield put(balanceActions.fetchLoadBalance.request());
try {
const web3 = yield select(state => state.web3Store.get("web3"));
const balances = yield call(balanceService.loadBalances, web3);
yield put(balanceActions.fetchLoadBalance.success(balances));
} catch (error) {
yield put(balanceActions.fetchLoadBalance.failure({error}));
}
}
export function* updateCurrencySaga() {
const base = yield select(getBaseCurrency);
const secondary = yield select(getSecondaryCurrency);
const used = yield select(getAccountsCurrencyList);
try {
const exchangeRate = yield call(
fetchExchangeRates,
base,
union(secondary, used)
);
yield put(updateExchangeRateSuccess(exchangeRate));
yield call(SettingsStorage.save, {
currency: { base, secondary },
exchangeRate
});
} catch (error) {
yield put(updateExchangeRateFailure(error));
}
}
export function * canSignFor (address) {
const settings = yield select(networkSettingsForAddress, address)
if (yield select(isHD, address)) {
const idIndex = yield select(hdIdentityIndex, address)
const actIndex = yield select(hdAccountIndex, address)
const r = yield call(addressFor, idIndex, actIndex)
return r.address === (settings.deviceAddress || settings.hexaddress)
} else {
const addresses = yield call(RNUportSigner.allAddresses)
return addresses.includes(settings.deviceAddress || settings.hexaddress)
}
}
function* deleteData() {
try {
const currentModelName = yield select(makeSelectModelName());
const record = yield select(makeSelectRecord());
const id = record.id || record._id;
const source = yield select(makeSelectSource());
const requestUrl = `/content-manager/explorer/${currentModelName}/${id}`;
yield call(request, requestUrl, { method: 'DELETE', params: { source } });
strapi.notification.success('content-manager.success.record.delete');
yield new Promise(resolve => {
setTimeout(() => {
resolve();
}, 300);
});
yield put(submitSuccess());
} catch(err) {
strapi.notification.error('content-manager.error.record.delete');
}
}
function* loadMedia(action) {
const token = yield select(makeSelectToken());
let query = '';
if (action.payload) {
Object.keys(action.payload).map(each => {
query = `${query}&${each}=${action.payload[each]}`;
return null;
});
}
yield call(
Api.get(
`media?${query}`,
actions.loadMediaSuccess,
actions.loadMediaFailure,
token,
),
);
}