Dev #2

Merged
Horhik merged 5 commits from dev into master 2020-03-19 20:16:31 +00:00
6 changed files with 34 additions and 12 deletions
Showing only changes of commit 3f2abc4954 - Show all commits

View file

@ -34,7 +34,6 @@ export const checkAnkiAccess = async (
ankiApiProvider = AnkiDroid.isApiAvailable,
) => {
const [err, res] = await ankiApiProvider();
console.log(res, 'result');
return err ? {type: ERROR, err} : {type: CHECK_ANKI_ACCESS, payload: res};
};
@ -109,7 +108,6 @@ export const checkAnkiLanModelForExisting = (
try {
for (let model of modelList) {
if (model.name === name) {
console.log('founded');
await dispatch(setExistingOfAnkiLanModel(true));
return true;
}

View file

@ -2,21 +2,21 @@ import fetch from 'node-fetch';
import {SET_YANDEX_DICTIONARY_RESPONSE} from '../../constants/api-constants';
const yKey =
'dict.1.1.20200313T141325Z.a8dfc0a8b66fb54c.f84fd712f759aa3abd7a7ecac35ac608181e2865';
const yDictionary = (
const yDictionary = async (
word = String,
languages = 'en-ru',
apiKey = yKey,
) => async dispatch => {
) => {
try {
const res = await fetch(
`https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=${apiKey}&lang=${languages}&text=${word}`,
{method: 'GET'},
);
const json = await res.json();
await dispatch(findPartofSpeech(json.def));
return findPartofSpeech(json.def);
return json.def;
} catch (e) {
console.warn('err in yandex-dictionary.js: ', e);
console.log('err in yandex-dictionary.js: ', e);
}
};

View file

@ -1,5 +1,10 @@
import {parseDictionary} from './parsing-dictionary';
import getAudio from '../api/word-sound';
import {compoundWithYDictionary} from './get-translate';
export const createDictionary = apiRes => {
const word = apiRes.word;
const parsedDictionary = parseDictionary(apiRes);
const audio = getAudio(word);
compoundWithYDictionary(parsedDictionary, word);
};

View file

@ -0,0 +1,24 @@
import yDictionary from '../api/yandex-dictionary';
export const compoundWithYDictionary = (definitionList, word) => {
const translations = (async () => {
const res = await yDictionary(word);
return await res;
})();
console.log(translations);
};
/*
import yDictionary from '../api/yandex-dictionary';
let smallStore = {};
export const compoundWithYDictionary = async (definitionList, word) => {
let properDefinitions = [];
const translations = (() => {
yDictionary(word).then(res => {
smallStore.res = res;
});
})();
const yDictionaryRes = smallStore.res.payload;
alert('foo');
console.log(yDictionaryRes, definitionList);
};*/

View file

@ -2,17 +2,14 @@ import React, {useEffect} from 'react';
import {connect} from 'react-redux';
import DeckPicker from './view/deck-picker';
import {Form, Container, Item} from 'native-base';
import AnkiTemplate from './view/add-main-template';
import {checkAnkiLanModelForExisting} from '../actions/anki-get-actions';
import InputWord from './view/translatable-word';
import SubmitButton from './view/submit-button';
import yDictionary from '../actions/api/yandex-dictionary';
import {wordInfo} from "../actions/api/dictionary";
const AnkiForm = props => {
useEffect(() => {
props.yDictionary('like');
props.wordInfo('penis poop')
props.wordInfo('like')
}, []);
return (
<Container style={{padding: 20}}>
@ -34,7 +31,6 @@ export default connect(
}),
{
checkAnkiLanModelForExisting,
yDictionary,
wordInfo
},

View file

@ -28,7 +28,6 @@ const initialState = {
const ankiReducer = (state = initialState, action) => {
switch (action.type) {
case REQUEST_PERMISSIONS:
console.log(action.payload);
return {...state, appHasAccess: action.payload};
case GET_DECK_LIST:
return {...state, deckList: action.payload};