Skip to content

Commit

Permalink
fix: display correct feed fee when no wallet is connected (#799)
Browse files Browse the repository at this point in the history
Signed-off-by: Norman Meier <[email protected]>
  • Loading branch information
n0izn0iz authored Dec 5, 2023
1 parent 9232574 commit abb5d9f
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 7 deletions.
2 changes: 2 additions & 0 deletions packages/components/music/UploadMusicModal/UploadTrack.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export const UploadTrack: React.FC<Props> = ({ onUploadDone }) => {
const userId = selectedWallet?.userId;
const [isNotEnoughFundModal, setNotEnoughFundModal] = useState(false);
const { makePost, canPayForPost, isProcessing } = useFeedPosting(
selectedNetwork?.id,
userId,
PostCategory.MusicAudio,
onUploadDone,
Expand Down Expand Up @@ -205,6 +206,7 @@ export const UploadTrack: React.FC<Props> = ({ onUploadDone }) => {
<View style={divideLineStyle} />

<FeedFeeText
networkId={selectedNetwork?.id}
userId={selectedWallet?.userId}
category={PostCategory.MusicAudio}
style={{ marginTop: layout.spacing_x2 }}
Expand Down
5 changes: 3 additions & 2 deletions packages/components/socialFeed/FeedFeeText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@ import { fontSemibold14 } from "../../utils/style/fonts";
import { BrandText } from "../BrandText";

export const FeedFeeText: React.FC<{
networkId: string | undefined;
userId: string | undefined;
category: PostCategory;
style?: StyleProp<ViewStyle>;
}> = ({ userId, category, style }) => {
}> = ({ networkId, userId, category, style }) => {
const theme = useTheme();
const { canPayForPost, prettyPublishingFee, prettyFeeBalance } =
useFeedPosting(userId, category);
useFeedPosting(networkId, userId, category);
const balanceColor = canPayForPost ? theme.textColor : errorColor;
return (
<View
Expand Down
11 changes: 8 additions & 3 deletions packages/components/socialFeed/NewsFeed/NewsFeedInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,14 @@ export const NewsFeedInput = React.forwardRef<
isProcessing,
prettyPublishingFee,
freePostCount,
} = useFeedPosting(userId, getPostCategory(formValues), () => {
onPostCreationSuccess();
});
} = useFeedPosting(
selectedNetwork?.id,
userId,
getPostCategory(formValues),
() => {
onPostCreationSuccess();
},
);
const userIPFSKey = useSelector(selectNFTStorageAPI);

const processSubmit = async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/components/video/UploadVideoModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export const UploadVideoModal: FC<{
const [isNotEnoughFundModal, setNotEnoughFundModal] = useState(false);

const { makePost, canPayForPost, isProcessing } = useFeedPosting(
selectedNetwork?.id,
userId,
PostCategory.Video,
);
Expand Down Expand Up @@ -315,6 +316,7 @@ export const UploadVideoModal: FC<{
<View style={divideLineStyle} />

<FeedFeeText
networkId={selectedNetwork?.id}
userId={selectedWallet?.userId}
category={PostCategory.Video}
style={{ marginTop: layout.spacing_x2 }}
Expand Down
5 changes: 4 additions & 1 deletion packages/hooks/feed/useFeedPosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ import { useDAOMakeProposal } from "../dao/useDAOMakeProposal";
import { useBalances } from "../useBalances";

export const useFeedPosting = (
networkId: string | undefined,
userId: string | undefined,
category: PostCategory,
onSuccess?: () => void,
) => {
const [network, userAddress] = parseUserId(userId);
const networkId = network?.id;
if (network) {
networkId = network.id;
}

const balances = useBalances(networkId, userAddress);
const { postFee } = useFeedPostFee(networkId, category);
Expand Down
2 changes: 1 addition & 1 deletion packages/screens/FeedNewArticle/FeedNewArticleScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export const FeedNewArticleScreen: ScreenFC<"FeedNewArticle"> = () => {
const [loading, setLoading] = useState(false);
const userIPFSKey = useSelector(selectNFTStorageAPI);
const { canPayForPost, freePostCount, publishingFee, prettyPublishingFee } =
useFeedPosting(userId, PostCategory.Article);
useFeedPosting(selectedNetworkId, userId, PostCategory.Article);

const { setToastSuccess, setToastError } = useFeedbacks();
const navigation = useAppNavigation();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export const FeedPostVideoView: FC<{
);

const { makePost, canPayForPost, isProcessing } = useFeedPosting(
networkId,
wallet?.userId,
PostCategory.Comment,
() => {
Expand Down

0 comments on commit abb5d9f

Please sign in to comment.