push
This commit is contained in:
parent
4b910d6646
commit
3f2abc4954
|
@ -34,7 +34,6 @@ export const checkAnkiAccess = async (
|
||||||
ankiApiProvider = AnkiDroid.isApiAvailable,
|
ankiApiProvider = AnkiDroid.isApiAvailable,
|
||||||
) => {
|
) => {
|
||||||
const [err, res] = await ankiApiProvider();
|
const [err, res] = await ankiApiProvider();
|
||||||
console.log(res, 'result');
|
|
||||||
return err ? {type: ERROR, err} : {type: CHECK_ANKI_ACCESS, payload: res};
|
return err ? {type: ERROR, err} : {type: CHECK_ANKI_ACCESS, payload: res};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -109,7 +108,6 @@ export const checkAnkiLanModelForExisting = (
|
||||||
try {
|
try {
|
||||||
for (let model of modelList) {
|
for (let model of modelList) {
|
||||||
if (model.name === name) {
|
if (model.name === name) {
|
||||||
console.log('founded');
|
|
||||||
await dispatch(setExistingOfAnkiLanModel(true));
|
await dispatch(setExistingOfAnkiLanModel(true));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,21 +2,21 @@ import fetch from 'node-fetch';
|
||||||
import {SET_YANDEX_DICTIONARY_RESPONSE} from '../../constants/api-constants';
|
import {SET_YANDEX_DICTIONARY_RESPONSE} from '../../constants/api-constants';
|
||||||
const yKey =
|
const yKey =
|
||||||
'dict.1.1.20200313T141325Z.a8dfc0a8b66fb54c.f84fd712f759aa3abd7a7ecac35ac608181e2865';
|
'dict.1.1.20200313T141325Z.a8dfc0a8b66fb54c.f84fd712f759aa3abd7a7ecac35ac608181e2865';
|
||||||
const yDictionary = (
|
const yDictionary = async (
|
||||||
word = String,
|
word = String,
|
||||||
languages = 'en-ru',
|
languages = 'en-ru',
|
||||||
apiKey = yKey,
|
apiKey = yKey,
|
||||||
) => async dispatch => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const res = await fetch(
|
const res = await fetch(
|
||||||
`https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=${apiKey}&lang=${languages}&text=${word}`,
|
`https://dictionary.yandex.net/api/v1/dicservice.json/lookup?key=${apiKey}&lang=${languages}&text=${word}`,
|
||||||
{method: 'GET'},
|
{method: 'GET'},
|
||||||
);
|
);
|
||||||
const json = await res.json();
|
const json = await res.json();
|
||||||
await dispatch(findPartofSpeech(json.def));
|
return findPartofSpeech(json.def);
|
||||||
return json.def;
|
return json.def;
|
||||||
} catch (e) {
|
} 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 {parseDictionary} from './parsing-dictionary';
|
||||||
|
import getAudio from '../api/word-sound';
|
||||||
|
import {compoundWithYDictionary} from './get-translate';
|
||||||
|
|
||||||
export const createDictionary = apiRes => {
|
export const createDictionary = apiRes => {
|
||||||
|
const word = apiRes.word;
|
||||||
const parsedDictionary = parseDictionary(apiRes);
|
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 {connect} from 'react-redux';
|
||||||
import DeckPicker from './view/deck-picker';
|
import DeckPicker from './view/deck-picker';
|
||||||
import {Form, Container, Item} from 'native-base';
|
import {Form, Container, Item} from 'native-base';
|
||||||
import AnkiTemplate from './view/add-main-template';
|
|
||||||
import {checkAnkiLanModelForExisting} from '../actions/anki-get-actions';
|
import {checkAnkiLanModelForExisting} from '../actions/anki-get-actions';
|
||||||
import InputWord from './view/translatable-word';
|
import InputWord from './view/translatable-word';
|
||||||
import SubmitButton from './view/submit-button';
|
import SubmitButton from './view/submit-button';
|
||||||
import yDictionary from '../actions/api/yandex-dictionary';
|
|
||||||
import {wordInfo} from "../actions/api/dictionary";
|
import {wordInfo} from "../actions/api/dictionary";
|
||||||
|
|
||||||
const AnkiForm = props => {
|
const AnkiForm = props => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
props.yDictionary('like');
|
props.wordInfo('like')
|
||||||
props.wordInfo('penis poop')
|
|
||||||
}, []);
|
}, []);
|
||||||
return (
|
return (
|
||||||
<Container style={{padding: 20}}>
|
<Container style={{padding: 20}}>
|
||||||
|
@ -34,7 +31,6 @@ export default connect(
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
checkAnkiLanModelForExisting,
|
checkAnkiLanModelForExisting,
|
||||||
yDictionary,
|
|
||||||
wordInfo
|
wordInfo
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
|
@ -28,7 +28,6 @@ const initialState = {
|
||||||
const ankiReducer = (state = initialState, action) => {
|
const ankiReducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case REQUEST_PERMISSIONS:
|
case REQUEST_PERMISSIONS:
|
||||||
console.log(action.payload);
|
|
||||||
return {...state, appHasAccess: action.payload};
|
return {...state, appHasAccess: action.payload};
|
||||||
case GET_DECK_LIST:
|
case GET_DECK_LIST:
|
||||||
return {...state, deckList: action.payload};
|
return {...state, deckList: action.payload};
|
||||||
|
|
Loading…
Reference in a new issue