Image URL support
This commit is contained in:
parent
5743e4b703
commit
9a80647750
2 changed files with 6 additions and 7 deletions
|
|
@ -8,7 +8,7 @@ export default function HomeScreen() {
|
||||||
const [isApiCallInProgress, setIsApiCallInProgress] = useState(false);
|
const [isApiCallInProgress, setIsApiCallInProgress] = useState(false);
|
||||||
|
|
||||||
// Function to call the fact-check API
|
// Function to call the fact-check API
|
||||||
const checkFacts = async (caption) => {
|
const checkFacts = async (caption, imageUrl) => {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
const response = await fetch('https://factcheck.planpostai.com/check-facts', {
|
const response = await fetch('https://factcheck.planpostai.com/check-facts', {
|
||||||
|
|
@ -17,7 +17,7 @@ export default function HomeScreen() {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ query: caption }),
|
body: JSON.stringify({ query: caption, url:imageUrl }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const responseText = await response.text();
|
const responseText = await response.text();
|
||||||
|
|
@ -32,7 +32,7 @@ export default function HomeScreen() {
|
||||||
// Send the result back to WebView to show toast
|
// Send the result back to WebView to show toast
|
||||||
webviewRef.current?.injectJavaScript(`
|
webviewRef.current?.injectJavaScript(`
|
||||||
(function() {
|
(function() {
|
||||||
showToast('${result.evidence.replace(/'/g, "\\'")}');
|
showToast('${result.evidence.replace(/'/g, "\\'")}', 10000);
|
||||||
return true;
|
return true;
|
||||||
})();
|
})();
|
||||||
`);
|
`);
|
||||||
|
|
@ -60,7 +60,6 @@ export default function HomeScreen() {
|
||||||
const handleMessage = async (event) => {
|
const handleMessage = async (event) => {
|
||||||
try {
|
try {
|
||||||
const data = JSON.parse(event.nativeEvent.data);
|
const data = JSON.parse(event.nativeEvent.data);
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
case 'postData':
|
case 'postData':
|
||||||
setPostData(prevData => [...prevData, {
|
setPostData(prevData => [...prevData, {
|
||||||
|
|
@ -76,7 +75,7 @@ export default function HomeScreen() {
|
||||||
setIsApiCallInProgress(true);
|
setIsApiCallInProgress(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await checkFacts(data.caption);
|
const result = await checkFacts(data.caption, data.imageUrls[0]);
|
||||||
|
|
||||||
setIsApiCallInProgress(false);
|
setIsApiCallInProgress(false);
|
||||||
webviewRef.current?.injectJavaScript(`
|
webviewRef.current?.injectJavaScript(`
|
||||||
|
|
|
||||||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "fake-check-bd",
|
"name": "fact-checker",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "fake-check-bd",
|
"name": "fact-checker",
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/vector-icons": "^14.0.2",
|
"@expo/vector-icons": "^14.0.2",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue