support for injecting image ratios in wave/comment jsonmetadata

This commit is contained in:
Nouman Tahir 2023-09-21 14:59:03 +05:00
parent 7a67e4a3d9
commit 334ad9bd1a
3 changed files with 14 additions and 7 deletions

View File

@ -1,7 +1,7 @@
import { useDispatch } from "react-redux";
import { useAppSelector } from "../../hooks";
import { postComment } from "../../providers/hive/dhive";
import { generateReplyPermlink, makeJsonMetadataReply } from "../../utils/editor";
import { extractMetadata, generateReplyPermlink, makeJsonMetadata } from "../../utils/editor";
import { Alert } from "react-native";
import { updateCommentCache } from "../../redux/actions/cacheActions";
import { toastNotification } from "../../redux/actions/uiAction";
@ -46,6 +46,13 @@ export const usePostSubmitter = () => {
const category = parentPost.category || '';
const url = `/${category}/@${parentAuthor}/${parentPermlink}#@${author}/${permlink}`;
//adding jsonmeta with image ratios here....
const meta = await extractMetadata({
body:commentBody,
fetchRatios:true
})
const jsonMetadata = makeJsonMetadata(meta, parentTags || ['ecency'])
console.log(
currentAccount,
pinCode,
@ -53,7 +60,7 @@ export const usePostSubmitter = () => {
parentPermlink,
permlink,
commentBody,
parentTags,
jsonMetadata
);
@ -65,7 +72,8 @@ export const usePostSubmitter = () => {
parentPermlink,
permlink,
commentBody,
parentTags,
[],
jsonMetadata
)
userActivityMutation.mutate({
@ -90,7 +98,7 @@ export const usePostSubmitter = () => {
parent_author: parentAuthor,
parent_permlink: parentPermlink,
markdownBody: commentBody,
json_metadata: makeJsonMetadataReply(parentTags || ['ecency'])
json_metadata: jsonMetadata
}
dispatch(

View File

@ -1510,7 +1510,7 @@ export const postComment = (
permlink,
body,
parentTags,
isEdit = false,
jsonMetadata = null,
) =>
_postContent(
account,
@ -1520,7 +1520,7 @@ export const postComment = (
permlink,
'',
body,
makeJsonMetadataReply(parentTags || ['ecency']),
jsonMetadata ? jsonMetadata : makeJsonMetadataReply(parentTags || ['ecency']),
null,
null,
)

View File

@ -18,7 +18,6 @@ import {
DELETE_CLAIM_CACHE_ENTRY,
} from '../constants/constants';
import {
ClaimCache,
Comment,
CacheStatus,
Draft,