dependabot did something
This commit is contained in:
commit
56f4aadfcd
|
@ -1,8 +1,5 @@
|
||||||
module.exports = {
|
{
|
||||||
root: true,
|
"root": true,
|
||||||
extends: '@react-native-community',
|
"extends": "@react-native-community",
|
||||||
plugins: [
|
"plugins": ["react", "react-native", "@react-native-community"]
|
||||||
react,
|
}
|
||||||
react-native
|
|
||||||
]
|
|
||||||
};
|
|
||||||
|
|
3
App.jsx
3
App.jsx
|
@ -3,9 +3,6 @@ import {Provider} from 'react-redux';
|
||||||
import StartScreen from './src/components/add-anklan-model';
|
import StartScreen from './src/components/add-anklan-model';
|
||||||
import store from './src/store';
|
import store from './src/store';
|
||||||
const App = props => {
|
const App = props => {
|
||||||
useEffect(() => {
|
|
||||||
alert("heeey")
|
|
||||||
})
|
|
||||||
return (
|
return (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<StartScreen />
|
<StartScreen />
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
getSourceExts: () => ['jsx', 'js'],
|
|
||||||
resolver: {
|
resolver: {
|
||||||
sourceExts: ['jsx', 'js'],
|
sourceExts: ['jsx', 'js'],
|
||||||
},
|
},
|
||||||
|
|
45
package.json
45
package.json
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
"name": "ankilan",
|
"name": "ankilan",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
@ -36,4 +37,48 @@
|
||||||
"jest": {
|
"jest": {
|
||||||
"preset": "react-native"
|
"preset": "react-native"
|
||||||
}
|
}
|
||||||
|
=======
|
||||||
|
"name": "ankilan",
|
||||||
|
"version": "0.0.1",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"android": "react-native run-android",
|
||||||
|
"ios": "react-native run-ios",
|
||||||
|
"start": "react-native start",
|
||||||
|
"test": "jest",
|
||||||
|
"lint": "eslint ."
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.19.2",
|
||||||
|
"babel-preset-react-native": "^4.0.1",
|
||||||
|
"native-base": "^2.13.8",
|
||||||
|
"node-fetch": "^2.6.0",
|
||||||
|
"react": "16.13.0",
|
||||||
|
"react-native": "^0.61.5",
|
||||||
|
"react-native-ankidroid": "^0.4.0",
|
||||||
|
"react-native-material-textfield": "^0.16.1",
|
||||||
|
"react-redux": "^7.2.0",
|
||||||
|
"redux": "^4.0.5",
|
||||||
|
"redux-devtools-extension": "^2.13.8",
|
||||||
|
"redux-thunk": "^2.3.0",
|
||||||
|
"remote-redux-devtools": "^0.5.16",
|
||||||
|
"unirest": "^0.6.0",
|
||||||
|
"urban-dictionary": "^2.2.1",
|
||||||
|
"urban-dictionary-client": "^3.0.1"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@babel/core": "^7.8.7",
|
||||||
|
"@babel/runtime": "^7.8.7",
|
||||||
|
"@react-native-community/eslint-config": "^0.0.7",
|
||||||
|
"babel-jest": "^25.1.0",
|
||||||
|
"eslint": "^6.8.0",
|
||||||
|
"jest": "^25.1.0",
|
||||||
|
"metro-react-native-babel-preset": "^0.58.0",
|
||||||
|
"react-test-renderer": "16.13.0",
|
||||||
|
"remotedev-rn-debugger": "^0.8.4"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"preset": "react-native"
|
||||||
|
}
|
||||||
|
>>>>>>> master
|
||||||
}
|
}
|
||||||
|
|
57
src/actions/api/dictionary.js
Normal file
57
src/actions/api/dictionary.js
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
import {search} from 'urban-dictionary-client';
|
||||||
|
import {SET_AVAILABLE_API} from '../../constants/api-constants';
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
async function getResFromWordsAPI(word) {
|
||||||
|
const req = await fetch(`https://wordsapiv1.p.rapidapi.com/words/${word}`, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'x-rapidapi-host': 'wordsapiv1.p.rapidapi.com',
|
||||||
|
'x-rapidapi-key': 'e08b0f617cmsh74abbf9a3b01eb0p164f22jsnabea29750b15',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
const json = await req.json();
|
||||||
|
const res = {...json, source: 'wordsAPI'};
|
||||||
|
if (res.success === false) {
|
||||||
|
// throw new Error(res.message);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Promise.resolve(res);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getResFromUrbanDictionary(word) {
|
||||||
|
const res = await search(word);
|
||||||
|
if (res.list.length === 0) {
|
||||||
|
// throw new Error('nothing was found');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Promise.resolve({...res, word, source: 'urbanDictionary'});
|
||||||
|
}
|
||||||
|
|
||||||
|
const getAvailableApi = (apiArray = []) => {
|
||||||
|
for (const api of apiArray) {
|
||||||
|
if (api) {
|
||||||
|
return api;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|
||||||
|
const setAvailableApi = api => ({
|
||||||
|
type: SET_AVAILABLE_API,
|
||||||
|
payload: api,
|
||||||
|
});
|
||||||
|
export const wordInfo = word => async dispatch => {
|
||||||
|
try {
|
||||||
|
const api1 = await getResFromWordsAPI(word);
|
||||||
|
const api2 = await getResFromUrbanDictionary(word);
|
||||||
|
const availableApi = getAvailableApi([api1, api2]);
|
||||||
|
console.log(availableApi);
|
||||||
|
if (availableApi === false) {
|
||||||
|
throw new Error('word not found');
|
||||||
|
}
|
||||||
|
await dispatch(setAvailableApi(availableApi));
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e);
|
||||||
|
}
|
||||||
|
};
|
0
src/actions/api/urban-dictionary.js
Normal file
0
src/actions/api/urban-dictionary.js
Normal file
13
src/actions/api/word-sound.js
Normal file
13
src/actions/api/word-sound.js
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
const getAudio = async url => {
|
||||||
|
const site = await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {'Content-Type': 'text/html'},
|
||||||
|
});
|
||||||
|
const html = await site.text();
|
||||||
|
const getSrc = new RegExp('<audio.+?src="(.+?)".+?/?>');
|
||||||
|
const src = html.match(getSrc)[1];
|
||||||
|
console.log(src);
|
||||||
|
|
||||||
|
return src;
|
||||||
|
};
|
||||||
|
export default getAudio;
|
0
src/actions/api/words-api.js
Normal file
0
src/actions/api/words-api.js
Normal file
39
src/actions/api/yandex-dictionary.js
Normal file
39
src/actions/api/yandex-dictionary.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import fetch from 'node-fetch';
|
||||||
|
import {SET_YANDEX_DICTIONARY_RESPONSE} from '../../constants/api-constants';
|
||||||
|
const yKey =
|
||||||
|
'dict.1.1.20200313T141325Z.a8dfc0a8b66fb54c.f84fd712f759aa3abd7a7ecac35ac608181e2865';
|
||||||
|
const yDictionary = (
|
||||||
|
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 json.def;
|
||||||
|
} catch (e) {
|
||||||
|
console.warn('err in yandex-dictionary.js: ', e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const translateTemplate = (pos, tr) => ({
|
||||||
|
pos,
|
||||||
|
tr,
|
||||||
|
});
|
||||||
|
|
||||||
|
export const findPartofSpeech = dictionary => {
|
||||||
|
return {
|
||||||
|
type: SET_YANDEX_DICTIONARY_RESPONSE,
|
||||||
|
payload: [
|
||||||
|
// TODO create flexible field selector, by poses count
|
||||||
|
translateTemplate(dictionary[0].pos, dictionary[0].tr[0].text),
|
||||||
|
translateTemplate(dictionary[1].pos, dictionary[1].tr[0].text),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export default yDictionary;
|
|
@ -7,9 +7,13 @@ import DeckPicker from './view/deck-picker';
|
||||||
import AddWordForm from './anki-form';
|
import AddWordForm from './anki-form';
|
||||||
import AnkiTemplate from './view/add-main-template';
|
import AnkiTemplate from './view/add-main-template';
|
||||||
import {Grid, Row} from 'native-base';
|
import {Grid, Row} from 'native-base';
|
||||||
import {checkAnkiLanModelForExisting} from '../actions/anki-get-actions';
|
import {checkAnkiLanModelForExisting, getDeckList, getModelList} from '../actions/anki-get-actions';
|
||||||
|
|
||||||
const StartScreen = props => {
|
const StartScreen = props => {
|
||||||
|
useEffect(() => {
|
||||||
|
props.getDeckList();
|
||||||
|
props.getModelList();
|
||||||
|
}, [])
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
props.checkAnkiLanModelForExisting(props.modelName, props.modelList);
|
props.checkAnkiLanModelForExisting(props.modelName, props.modelList);
|
||||||
});
|
});
|
||||||
|
@ -38,4 +42,6 @@ export default connect(
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
checkAnkiLanModelForExisting,
|
checkAnkiLanModelForExisting,
|
||||||
|
getDeckList,
|
||||||
|
getModelList
|
||||||
})(StartScreen);
|
})(StartScreen);
|
||||||
|
|
|
@ -6,8 +6,14 @@ 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";
|
||||||
|
|
||||||
const AnkiForm = props => {
|
const AnkiForm = props => {
|
||||||
|
useEffect(() => {
|
||||||
|
props.yDictionary('wealth');
|
||||||
|
props.wordInfo('suck')
|
||||||
|
}, []);
|
||||||
return (
|
return (
|
||||||
<Container style={{padding: 20}}>
|
<Container style={{padding: 20}}>
|
||||||
<Form onSubmit={() => alert('hell')}>
|
<Form onSubmit={() => alert('hell')}>
|
||||||
|
@ -28,5 +34,8 @@ export default connect(
|
||||||
}),
|
}),
|
||||||
{
|
{
|
||||||
checkAnkiLanModelForExisting,
|
checkAnkiLanModelForExisting,
|
||||||
|
yDictionary,
|
||||||
|
wordInfo
|
||||||
|
|
||||||
},
|
},
|
||||||
)(AnkiForm);
|
)(AnkiForm);
|
||||||
|
|
|
@ -2,6 +2,7 @@ import React, {useState, useEffect} from 'react';
|
||||||
import {Text, Button, Grid} from 'native-base';
|
import {Text, Button, Grid} from 'native-base';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import {requestAnkiPermission} from '../actions/anki-get-actions';
|
import {requestAnkiPermission} from '../actions/anki-get-actions';
|
||||||
|
|
||||||
const Permissions = props => {
|
const Permissions = props => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
props.requestAnkiPermission();
|
props.requestAnkiPermission();
|
||||||
|
|
|
@ -3,9 +3,7 @@ import {connect} from 'react-redux';
|
||||||
import {TextField} from 'react-native-material-textfield';
|
import {TextField} from 'react-native-material-textfield';
|
||||||
|
|
||||||
const InputWord = props => {
|
const InputWord = props => {
|
||||||
const submit = () => {
|
const submit = () => {};
|
||||||
console.log('he');
|
|
||||||
};
|
|
||||||
return <TextField label={'Your word'} onChange={submit} />;
|
return <TextField label={'Your word'} onChange={submit} />;
|
||||||
};
|
};
|
||||||
export default connect(state => ({}), {})(InputWord);
|
export default connect(state => ({}), {})(InputWord);
|
||||||
|
|
3
src/constants/api-constants.js
Normal file
3
src/constants/api-constants.js
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
// export const c = 'c'
|
||||||
|
export const SET_YANDEX_DICTIONARY_RESPONSE = 'SET_YANDEX_DICTIONARY_RESPONSE';
|
||||||
|
export const SET_AVAILABLE_API = 'SET_AVAILABLE_API';
|
|
@ -1,7 +1,30 @@
|
||||||
const initialState = {};
|
import {
|
||||||
|
SET_AVAILABLE_API,
|
||||||
|
SET_YANDEX_DICTIONARY_RESPONSE,
|
||||||
|
} from '../constants/api-constants';
|
||||||
|
|
||||||
|
const initialState = {
|
||||||
|
word: '',
|
||||||
|
translatedObject: {},
|
||||||
|
wordSoundLink: '',
|
||||||
|
availableApi: {},
|
||||||
|
availableApiName: '',
|
||||||
|
yandexDictionaryInfo: [],
|
||||||
|
};
|
||||||
|
|
||||||
const apiReducer = (state = initialState, action) => {
|
const apiReducer = (state = initialState, action) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
case SET_YANDEX_DICTIONARY_RESPONSE:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
yandexDictionaryInfo: action.payload,
|
||||||
|
};
|
||||||
|
case SET_AVAILABLE_API:
|
||||||
|
return {
|
||||||
|
...state,
|
||||||
|
availableApi: action.payload,
|
||||||
|
availableApiName: action.payload.source,
|
||||||
|
};
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
5
tools-start.sh
Executable file
5
tools-start.sh
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
watchman watch-del-all
|
||||||
|
watchman shutdown-server
|
||||||
|
react-native run-android
|
||||||
|
react-native-debugger &
|
||||||
|
scrcpy &
|
Loading…
Reference in a new issue