Skip to content

Commit

Permalink
Merge pull request #42 from ecency/bugfix/user-issues
Browse files Browse the repository at this point in the history
bugfix/user-issues
  • Loading branch information
feruzm authored Sep 29, 2024
2 parents 723688c + 50e901d commit a000dfe
Show file tree
Hide file tree
Showing 13 changed files with 84 additions and 56 deletions.
Binary file added public/og.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 2 additions & 8 deletions src/api/operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -417,13 +417,7 @@ export const transferPointKc = (from: string, to: string, amount: string, memo:
memo
});

return keychain.customJson(
from,
"ecency_point_transfer",
"Active",
json,
"Point Transfer"
);
return keychain.customJson(from, "ecency_point_transfer", "Active", json, "Point Transfer");
};

export const transferToSavings = (
Expand Down Expand Up @@ -501,7 +495,7 @@ export const limitOrderCreate = (
? formatNumber(amount_to_sell, 3)
: formatNumber(mini_to_receive, 3)
} ${orderType === BuySellHiveTransactionType.Buy ? "HBD" : "HIVE"}`,
mini_to_receive: `${
min_to_receive: `${
orderType === BuySellHiveTransactionType.Buy
? formatNumber(mini_to_receive, 3)
: formatNumber(amount_to_sell, 3)
Expand Down
9 changes: 8 additions & 1 deletion src/api/queries/get-posts-ranked-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ export const getPostsRankedQuery = (

if (response) {
const data = await Promise.all(response.map((item) => resolvePost(item, observer)));
return data.sort((a, b) => new Date(b.created).getTime() - new Date(a.created).getTime());
const sorted =
sort === "hot"
? data
: data.sort((a, b) => new Date(b.created).getTime() - new Date(a.created).getTime());
return [
sorted.find((s) => s.stats.is_pinned),
...sorted.filter((s) => !s.stats.is_pinned)
].filter((s) => !!s) as Entry[];
}

return [];
Expand Down
3 changes: 2 additions & 1 deletion src/app/(dynamicPages)/community/[community]/[tag]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getCommunityCache } from "@/core/caches";
import { notFound, redirect } from "next/navigation";
import { notFound } from "next/navigation";
import { prefetchGetPostsFeedQuery } from "@/api/queries";
import { EntryListContent, LinearProgress } from "@/features/shared";
import { CommunityContentSearch } from "@/app/(dynamicPages)/community/[community]/_components/community-content-search";
Expand Down Expand Up @@ -44,6 +44,7 @@ export default async function CommunityPostsPage({ params: { community, tag } }:
{/*{(!query || query?.length === 0) && (*/}
<ProfileEntriesLayout section={tag} username={community}>
<EntryListContent
community={communityData}
username={community}
isPromoted={false}
entries={data.pages.reduce<Entry[]>((acc, page) => [...acc, ...(page as Entry[])], [])}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function ProfileReferrals({ account }: Props) {
);

return (
<div className="app-content witnesses-page mt-0 mx-0">
<div className="flex flex-col">
<ProfileReferralHeader account={account} />
{isLoading && <LinearProgress />}
<div className="w-full overflow-x-auto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Tsx } from "@/features/i18n/helper";
import { success } from "@/features/shared";
import { Account } from "@/entities";
import { getReferralsStatsQuery } from "@/api/queries";
import { Badge } from "@ui/badge";

interface Props {
account: Account;
Expand Down Expand Up @@ -34,29 +35,30 @@ export function ProfileReferralHeader({ account }: Props) {
}, []);

return (
<div className="page-header mt-2 mb-2">
<div className="header-title !text-left">{i18next.t("referral.page-title")}</div>
<div className="my-4 flex flex-col items-start">
<div className="flex items-center justify-between flex-wrap gap-4">
<div className="text-2xl font-bold">{i18next.t("referral.page-title")}</div>
<Button
size="sm"
icon={shareVariantSvg}
onClick={() => copyToClipboard(`https://ecency.com/signup?referral=${account.name}`)}
>
{i18next.t("entry.address-copy")}
</Button>
</div>

<div className="flex mt-2">
<div>
<h5 className="header-title !text-left">{earnedPoints}</h5>
<h6 className=" text-left">{i18next.t("referral.earned-reward")}</h6>
</div>
<div>
<h5 className="header-title !text-left ml-3">{unearnedPoints}</h5>
<h6 className=" text-left ml-3">{i18next.t("referral.pending-reward")}</h6>
<div className="grid w-full sm:w-auto sm:grid-cols-2 gap-4 my-4">
<div className="w-full sm:min-w-[240px] border border-[--border-color] rounded-2xl p-4">
<div className="font-semibold mb-2">{i18next.t("referral.earned-reward")}</div>
<Badge className="!text-lg">{earnedPoints}</Badge>
</div>
<div className="ml-5">
<Button
icon={shareVariantSvg}
onClick={() => copyToClipboard(`https://ecency.com/signup?referral=${account.name}`)}
>
{i18next.t("entry.address-copy")}
</Button>
<div className="w-full sm:min-w-[240px] border border-[--border-color] rounded-2xl p-4">
<div className="font-semibold mb-2">{i18next.t("referral.pending-reward")}</div>
<Badge className="!text-lg">{unearnedPoints}</Badge>
</div>
</div>
<Tsx k="referral.page-description-long">
<div className="header-description !text-left" />
<div className="mt-4" />
</Tsx>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ export function ProfileReferralsTable({ account, pageSize, page }: Props) {
<Table>
<thead>
<Tr>
<Th className="border p-3 col-rank">{i18next.t("referral.created")}</Th>
<Th className="p-3 col-rank">{i18next.t("referral.created")}</Th>
<Th>{i18next.t("referral.list-referral")}</Th>
<Th className="border p-3 col-version">{i18next.t("referral.rewarded")}</Th>
<Th className="border p-3 col-version" />
<Th className="p-3 col-version">{i18next.t("referral.rewarded")}</Th>
<Th className="p-3 col-version" />
</Tr>
</thead>
<tbody>
Expand Down
10 changes: 9 additions & 1 deletion src/app/communities/_components/communities-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,22 @@ import { CommunitiesListSearch } from "@/app/communities/_components/communities
import { CommunitiesListSortSelector } from "@/app/communities/_components/communities-list-sort-selector";
import { CommunityListItemAnimatedLayout } from "@/app/communities/_components/community-list-item-animated-layout";
import { SafeAnimatePresence } from "@/features/framer-motion";
import { getCommunityCache } from "@/core/caches";

interface Props {
sort: string;
query: string;
}

export async function CommunitiesList({ sort, query }: Props) {
const list = getCommunitiesQuery(sort, query).getData();
let list = getCommunitiesQuery(sort, query).getData();
const ecencyCommunity =
list?.find((x) => x.name === "hive-125125") ??
(await getCommunityCache("hive-125125").prefetch());

if (ecencyCommunity) {
list = [ecencyCommunity, ...(list?.filter((x) => x.name !== "hive-125125") ?? [])];
}

return (
<>
Expand Down
28 changes: 19 additions & 9 deletions src/app/proposals/_page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use client";
import React, { Fragment, useMemo, useState } from "react";
import React, { Fragment, useMemo, useRef, useState } from "react";
import numeral from "numeral";
import defaults from "@/defaults.json";
import { setProxyBase } from "@ecency/render-helper";
Expand All @@ -11,8 +11,9 @@ import { ProposalListItem } from "@/app/proposals/_components";
import { getAccountFullQuery, getProposalsQuery } from "@/api/queries";
import { parseAsset } from "@/utils";
import { Proposal } from "@/entities";
import { Button } from "@ui/button";
import { AnimatePresence, motion } from "framer-motion";
import { useInViewport } from "react-in-viewport";
import { useDebounce } from "react-use";

setProxyBase(defaults.imageServer);

Expand All @@ -24,6 +25,8 @@ enum Filter {
}

export function ProposalsPage() {
const infiniteLoadingAnchorRef = useRef<HTMLDivElement>(null);

const { data: proposals, isLoading } = getProposalsQuery().useClientQuery();
const { data: fund } = getAccountFullQuery("hive.fund").useClientQuery();
const [page, setPage] = useState(1);
Expand Down Expand Up @@ -94,6 +97,18 @@ export function ProposalsPage() {
};
}, [dailyBudget, proposals]);

const { inViewport } = useInViewport(infiniteLoadingAnchorRef);

useDebounce(
() => {
if (inViewport) {
setPage((page) => page + 1);
}
},
1000,
[inViewport]
);

return (
<>
<ScrollToTop />
Expand Down Expand Up @@ -172,13 +187,8 @@ export function ProposalsPage() {
</motion.div>
))}
</AnimatePresence>
</div>
)}
{page * 5 < (filteredProposals?.length ?? 0) && (
<div className="flex items-center justify-center mb-4">
<Button className="capitalize" onClick={() => setPage(page + 1)}>
{i18next.t("search-comment.show-more")}
</Button>

<div ref={infiniteLoadingAnchorRef} />
</div>
)}
</div>
Expand Down
15 changes: 8 additions & 7 deletions src/features/shared/comment/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import "./_index.scss";
import { Spinner } from "@ui/spinner";
import { Button } from "@ui/button";
import defaults from "@/defaults.json";
import { LoginRequired } from "@/features/shared";
import { AvailableCredits, LoginRequired } from "@/features/shared";
import { CommentPreview } from "@/features/shared/comment/comment-preview";
import { useGlobalStore } from "@/core/global-store";
import i18next from "i18next";
Expand All @@ -15,9 +15,10 @@ import { Entry } from "@/entities";
import { useDebounce, useMount } from "react-use";
import useUnmount from "react-use/lib/useUnmount";
import { detectEvent, EditorToolbar, toolbarEventListener } from "@/features/shared/editor-toolbar";
import { AvailableCredits } from "@/features/shared";
import { TextareaAutocomplete } from "@/features/shared/textarea-autocomplete";
import usePrevious from "react-use/lib/usePrevious";
import useLocalStorage from "react-use/lib/useLocalStorage";
import { PREFIX } from "@/utils/local-storage";

setProxyBase(defaults.imageServer);

Expand Down Expand Up @@ -51,7 +52,7 @@ export function Comment({
const commentBodyRef = useRef<HTMLDivElement>(null);
const activeUser = useGlobalStore((s) => s.activeUser);

const [text, setText] = useState("");
const [text, setText] = useLocalStorage(PREFIX + "_c_t", "");
const [inputHeight, setInputHeight] = useState(0);
const [preview, setPreview] = useState("");
const [showEmoji, setShowEmoji] = useState(false);
Expand All @@ -60,11 +61,11 @@ export function Comment({
const previousDefText = usePrevious(defText);
const previousIsCommented = usePrevious(isCommented);

const rows = useMemo(() => text.split(/\r\n|\r|\n|<br>/).length, [text]);
const rows = useMemo(() => text!.split(/\r\n|\r|\n|<br>/).length, [text]);

useDebounce(
() => {
setPreview(text);
setPreview(text!);
},
50,
[text]
Expand Down Expand Up @@ -104,7 +105,7 @@ export function Comment({
}, []);

const submit = useCallback(async () => {
await onSubmit(text);
await onSubmit(text!);
setText("");
}, [text, onSubmit]);

Expand Down Expand Up @@ -178,7 +179,7 @@ export function Comment({
<EditorToolbar comment={true} sm={true} />
<div className="comment-body" onKeyDown={handleShortcuts} ref={commentBodyRef}>
<TextareaAutocomplete
className={`the-editor accepts-emoji ${text?.length > 20 ? "expanded" : ""}`}
className={`the-editor accepts-emoji ${text!.length > 20 ? "expanded" : ""}`}
as="textarea"
placeholder={i18next.t("comment.body-placeholder")}
containerStyle={{ height: !text ? "80px" : inputHeight }}
Expand Down
9 changes: 7 additions & 2 deletions src/features/shared/entry-list-content/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import "./_index.scss";
import { Account, Entry } from "@/entities";
import { Account, Community, Entry } from "@/entities";
import { EntryListItem } from "@/features/shared";
import { getPromotedEntriesQuery } from "@/api/queries";
import { EntryListContentNoData } from "@/features/shared/entry-list-content/entry-list-content-no-data";
Expand All @@ -13,6 +13,7 @@ interface Props {
username: string;
showEmptyPlaceholder?: boolean;
account?: Account;
community?: Community;
}

export function EntryListContent({
Expand All @@ -22,7 +23,8 @@ export function EntryListContent({
loading,
username,
showEmptyPlaceholder = true,
account
account,
community
}: Props) {
let dataToRender = [...entries];
let promotedEntries: Entry[] = [];
Expand Down Expand Up @@ -50,6 +52,7 @@ export function EntryListContent({
entry={p}
promoted={true}
order={4}
community={community}
/>
);
}
Expand All @@ -64,6 +67,7 @@ export function EntryListContent({
key={`${e.author}-${e.permlink}`}
entry={e}
order={i}
community={community}
/>
);
} else {
Expand All @@ -73,6 +77,7 @@ export function EntryListContent({
key={`${e.author}-${e.permlink}`}
entry={e}
order={i}
community={community}
/>
);
}
Expand Down
6 changes: 3 additions & 3 deletions src/features/shared/entry-list-item/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import "./_index.scss";
import defaults from "@/defaults.json";
import { Account, Community, Entry, FullAccount } from "@/entities";
import { dateToFormatted, dateToRelative } from "@/utils";
import { commentSvg, pinSvg, repeatSvg } from "@ui/svg";
import { pinSvg, repeatSvg } from "@ui/svg";
import { EntryLink } from "../entry-link";
import {
EntryMenu,
Expand Down Expand Up @@ -51,10 +51,10 @@ export function EntryListItemComponent({
}: Props) {
const pageAccount = account as FullAccount;

const pinned = pageAccount?.profile?.pinned;

const isCrossPost = !!entryProp.original_entry;
const entry = entryProp.original_entry || entryProp;
const pinned = entry?.stats?.is_pinned ?? pageAccount?.profile?.pinned;

const dateRelative = dateToRelative(entry.created);
const dateFormatted = dateToFormatted(entry.created);
const reBlogged =
Expand Down
4 changes: 2 additions & 2 deletions src/features/shared/navbar/sidebar/navbar-side-main-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ export function NavbarSideMainMenu({ onHide }: Props) {
<hr className="my-2 border-[--border-color]" />
<NavbarSideMainMenuItem
label={i18next.t("market.swap-title")}
to="/market#swap"
to="/market/swap"
onClick={onHide}
icon={<UilMoneyWithdraw size={16} />}
/>
<NavbarSideMainMenuItem
label={i18next.t("market.advanced-title")}
to="/market#advanced"
to="/market/advanced"
onClick={onHide}
icon={<UilDashboard size={16} />}
/>
Expand Down

0 comments on commit a000dfe

Please sign in to comment.