fix: go to group profile when clicking on custom group name (#53)

* fix: go to group profile when clicking on custom group name

* fix custom group profile

* fix prettier
This commit is contained in:
tsukino
2022-12-08 16:48:43 +08:00
committed by GitHub
parent 69a4fd88cc
commit 124699e6ed
3 changed files with 26 additions and 5 deletions

View File

@@ -40,11 +40,18 @@ export default function ExpandedPost(
const gotoUserProfile = useCallback(
(e: any) => {
if (!user || !post?.creator) return;
e.stopPropagation();
const [protocol, groupAddress] = zkGroup?.split('_') || [];
if (protocol === 'custom') {
history.push(`/${groupAddress}/`);
}
if (!user || post?.type === MessageType._TWEET) return;
history.push(`/${user?.ens || user?.username}/`);
},
[user, post]
[user, post, zkGroup]
);
if (!post) return <></>;

View File

@@ -43,11 +43,18 @@ export default function RegularPost(
const gotoUserProfile = useCallback(
(e: any) => {
if (!user || post?.type === MessageType._TWEET) return;
e.stopPropagation();
const [protocol, groupAddress] = zkGroup?.split('_') || [];
if (protocol === 'custom') {
history.push(`/${groupAddress}/`);
}
if (!user || post?.type === MessageType._TWEET) return;
history.push(`/${user?.ens || user?.username}/`);
},
[user, post?.type]
[user, post?.type, zkGroup]
);
if (!post) return <></>;

View File

@@ -18,6 +18,7 @@ import { useHistory } from 'react-router';
import { useCallback } from 'react';
import { EditorState } from 'draft-js';
import { convertMarkdownToDraft } from '../components/DraftEditor';
import Web3 from 'web3';
enum ActionTypes {
SET_POSTS = 'posts/setPosts',
@@ -554,12 +555,18 @@ export const useMeta = (messageId = '') => {
export const useZKGroupFromPost = (messageId?: string) => {
return useSelector((state: AppRootState): string | undefined => {
if (!messageId) return;
const post = state.posts.meta[messageId];
if (!post?.interepProvider) return undefined;
const { interepProvider, interepGroup } = post;
if (Web3.utils.isAddress(interepProvider)) return `custom_${interepProvider}`;
return post.interepProvider === 'taz'
? 'semaphore_taz_members'
: `interrep_${post.interepProvider}_${post.interepGroup}`;
: `interrep_${interepProvider}_${interepGroup}`;
}, deepEqual);
};