From a3aa473146922f806148c75d743ce35e0203d16c Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Fri, 22 Sep 2023 17:40:57 +0500 Subject: [PATCH 1/3] Revert "separating permlink prefix for comments and waves" This reverts commit 16982b1ab03ca4974591b342fea26f99730b9120. --- src/components/quickReplyModal/usePostSubmitter.ts | 8 ++------ src/screens/editor/container/editorContainer.tsx | 6 ++---- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/components/quickReplyModal/usePostSubmitter.ts b/src/components/quickReplyModal/usePostSubmitter.ts index d63a639ed..093e5869c 100644 --- a/src/components/quickReplyModal/usePostSubmitter.ts +++ b/src/components/quickReplyModal/usePostSubmitter.ts @@ -1,7 +1,7 @@ import { useDispatch } from "react-redux"; import { useAppSelector } from "../../hooks"; import { postComment } from "../../providers/hive/dhive"; -import { extractMetadata, generateUniquePermlink, makeJsonMetadata } 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"; @@ -10,7 +10,6 @@ import { useState } from "react"; import { useUserActivityMutation, wavesQueries } from "../../providers/queries"; import { PointActivityIds } from "../../providers/ecency/ecency.types"; import { usePublishWaveMutation } from "../../providers/queries/postQueries/wavesQueries"; -import { PostTypes } from "../../constants/postTypes"; export const usePostSubmitter = () => { @@ -39,10 +38,7 @@ export const usePostSubmitter = () => { if (currentAccount) { setIsSending(true); - const _prefix = postType === PostTypes.WAVE - ? postType - : `re-${parentPost.author.replace(/\./g, '')}` - const permlink = generateUniquePermlink(_prefix); + const permlink = generateReplyPermlink(parentPost.author); const author = currentAccount.name; const parentAuthor = parentPost.author; const parentPermlink = parentPost.permlink; diff --git a/src/screens/editor/container/editorContainer.tsx b/src/screens/editor/container/editorContainer.tsx index 75ecd0ff2..a0b340c74 100644 --- a/src/screens/editor/container/editorContainer.tsx +++ b/src/screens/editor/container/editorContainer.tsx @@ -26,12 +26,12 @@ import { default as ROUTES } from '../../../constants/routeNames'; // Utilities import { generatePermlink, + generateReplyPermlink, makeJsonMetadata, makeOptions, extractMetadata, makeJsonMetadataForUpdate, createPatch, - generateUniquePermlink, } from '../../../utils/editor'; // import { generateSignature } from '../../../utils/image'; @@ -707,9 +707,7 @@ class EditorContainer extends Component { }); const { post } = this.state; - - const _prefix = `re-${post.author.replace(/\./g, '')}` - const permlink = generateUniquePermlink(_prefix); + const permlink = generateReplyPermlink(post.author); const parentAuthor = post.author; const parentPermlink = post.permlink; From 16545d86786530a8ff09a8647a1466c5314b00de Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Fri, 22 Sep 2023 17:41:05 +0500 Subject: [PATCH 2/3] Revert "adding post type to json_metadata" This reverts commit d190ecd3d253143c53bbb69061780fb8a095caea. --- src/components/quickReplyModal/usePostSubmitter.ts | 7 +++---- src/utils/editor.ts | 7 ------- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/src/components/quickReplyModal/usePostSubmitter.ts b/src/components/quickReplyModal/usePostSubmitter.ts index 093e5869c..9b016584b 100644 --- a/src/components/quickReplyModal/usePostSubmitter.ts +++ b/src/components/quickReplyModal/usePostSubmitter.ts @@ -27,7 +27,7 @@ export const usePostSubmitter = () => { // handle submit reply - const _submitReply = async (commentBody: string, parentPost: any, postType: PostTypes) => { + const _submitReply = async (commentBody: string, parentPost: any) => { if (!commentBody) { return false ; } @@ -49,8 +49,7 @@ export const usePostSubmitter = () => { //adding jsonmeta with image ratios here.... const meta = await extractMetadata({ body:commentBody, - fetchRatios:true, - postType + fetchRatios:true }) const jsonMetadata = makeJsonMetadata(meta, parentTags || ['ecency']) @@ -144,7 +143,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, PostTypes.WAVE) + const _cacheCommentData = await _submitReply(body, latestWavesPost) if(_cacheCommentData){ pusblishWaveMutation.mutate(_cacheCommentData) diff --git a/src/utils/editor.ts b/src/utils/editor.ts index 7e39084b6..0edd1ebcc 100644 --- a/src/utils/editor.ts +++ b/src/utils/editor.ts @@ -3,7 +3,6 @@ import { Image } from 'react-native'; import { diff_match_patch as diffMatchPatch } from 'diff-match-patch'; import VersionNumber from 'react-native-version-number'; import MimeTypes from 'mime-types'; -import { PostTypes } from '../constants/postTypes'; export const getWordsCount = (text) => text && typeof text === 'string' ? text.replace(/^\s+|\s+$/g, '').split(/\s+/).length : 0; @@ -215,12 +214,10 @@ 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; @@ -257,10 +254,6 @@ export const extractMetadata = async ({ ); } - if(postType){ - out.type = postType - } - return out; }; From 1167022a2fa893d6c87dc588a410735f2731450a Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Fri, 22 Sep 2023 19:05:33 +0500 Subject: [PATCH 3/3] update current user data on drawer open --- ...MenuContainer.js => sideMenuContainer.tsx} | 38 ++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) rename src/components/sideMenu/container/{sideMenuContainer.js => sideMenuContainer.tsx} (59%) diff --git a/src/components/sideMenu/container/sideMenuContainer.js b/src/components/sideMenu/container/sideMenuContainer.tsx similarity index 59% rename from src/components/sideMenu/container/sideMenuContainer.js rename to src/components/sideMenu/container/sideMenuContainer.tsx index 92fec2a23..f6e4c9961 100644 --- a/src/components/sideMenu/container/sideMenuContainer.js +++ b/src/components/sideMenu/container/sideMenuContainer.tsx @@ -1,4 +1,5 @@ -import React from 'react'; +import React, { useEffect } from 'react'; +import { Alert } from 'react-native' import { useDispatch, useSelector } from 'react-redux'; // Actions @@ -7,9 +8,16 @@ import { setInitPosts, setFeedPosts } from '../../../redux/actions/postsAction'; // Component import SideMenuView from '../view/sideMenuView'; +import { useDrawerStatus } from '@react-navigation/drawer'; +import { updateCurrentAccount } from '../../../redux/actions/accountAction'; +import { getUser } from '../../../providers/hive/dhive'; +import bugsnapInstance from '../../../config/bugsnag'; const SideMenuContainer = ({ navigation }) => { const dispatch = useDispatch(); + const drawerStatus = useDrawerStatus(); + + const isLoggedIn = useSelector((state) => state.application.isLoggedIn); const currentAccount = useSelector((state) => state.account.currentAccount); @@ -17,6 +25,34 @@ const SideMenuContainer = ({ navigation }) => { (state) => state.ui.isVisibleAccountsBottomSheet, ); + + useEffect(()=>{ + if(drawerStatus === 'open'){ + //update profile on drawer open + _updateUserData(); + } + + }, [drawerStatus]) + + + //fetches and update user data + const _updateUserData = async () => { + try{ + if(currentAccount?.username){ + let accountData = await getUser(currentAccount.username); + if(accountData){ + dispatch(updateCurrentAccount({...currentAccount, ...accountData})) + } + } + + } catch(err){ + console.warn("failed to update user data") + bugsnapInstance.notify(err); + } + + } + + const _navigateToRoute = (route = null) => { if (route) { navigation.navigate(route);