Dev #2
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
24
src/actions/dictionary/get-translate.js
Normal file
24
src/actions/dictionary/get-translate.js
Normal 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);
|
||||
};*/
|
|
@ -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
|
||||
|
||||
},
|
||||
|
|
|
@ -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};
|
||||
|
|
Loading…
Reference in a new issue