re-added reverted content

This commit is contained in:
Nouman Tahir 2023-09-25 19:07:47 +05:00
parent 494018c8ff
commit d026f8c31f
3 changed files with 21 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import { useDispatch } from "react-redux";
import { useAppSelector } from "../../hooks";
import { postComment } from "../../providers/hive/dhive";
import { extractMetadata, generateReplyPermlink, makeJsonMetadata } from "../../utils/editor";
import { extractMetadata, generateUniquePermlink, makeJsonMetadata } from "../../utils/editor";
import { Alert } from "react-native";
import { updateCommentCache } from "../../redux/actions/cacheActions";
import { toastNotification } from "../../redux/actions/uiAction";
@ -39,7 +39,11 @@ export const usePostSubmitter = () => {
if (currentAccount) {
setIsSending(true);
const permlink = generateReplyPermlink(parentPost.author);
const _prefix = postType === PostTypes.WAVE
? postType
: `re-${parentPost.author.replace(/\./g, '')}`
const permlink = generateUniquePermlink(_prefix);
const author = currentAccount.name;
const parentAuthor = parentPost.author;
const parentPermlink = parentPost.permlink;
@ -50,7 +54,8 @@ export const usePostSubmitter = () => {
//adding jsonmeta with image ratios here....
const meta = await extractMetadata({
body: commentBody,
fetchRatios:true
fetchRatios: true,
postType
})
const jsonMetadata = makeJsonMetadata(meta, parentTags || ['ecency'])
@ -144,7 +149,7 @@ export const usePostSubmitter = () => {
const _wavesHost = 'ecency.waves' //TODO: make waves host selection dynamic
const latestWavesPost = await wavesQueries.fetchLatestWavesContainer(_wavesHost);
const _cacheCommentData = await _submitReply(body, latestWavesPost)
const _cacheCommentData = await _submitReply(body, latestWavesPost, PostTypes.WAVE)
if (_cacheCommentData) {
pusblishWaveMutation.mutate(_cacheCommentData)

View File

@ -26,7 +26,7 @@ import { default as ROUTES } from '../../../constants/routeNames';
// Utilities
import {
generatePermlink,
generateReplyPermlink,
generateUniquePermlink,
makeJsonMetadata,
makeOptions,
extractMetadata,
@ -707,7 +707,9 @@ class EditorContainer extends Component<EditorContainerProps, any> {
});
const { post } = this.state;
const permlink = generateReplyPermlink(post.author);
const _prefix = `re-${post.author.replace(/\./g, '')}`
const permlink = generateUniquePermlink(_prefix);
const parentAuthor = post.author;
const parentPermlink = post.permlink;

View File

@ -215,10 +215,12 @@ export const extractMetadata = async ({
body,
thumbUrl,
fetchRatios,
postType,
}: {
body: string;
thumbUrl?: string;
fetchRatios?: boolean;
postType?: PostTypes;
}) => {
// NOTE: keepting regex to extract usernames as reference for later usage if any
// const userReg = /(^|\s)(@[a-z][-.a-z\d]+[a-z\d])/gim;