Skip to content

Commit

Permalink
Superlikes list on Home Page shows time since it was made
Browse files Browse the repository at this point in the history
Refactoring to prepare for SuperDislike button
  • Loading branch information
QortalSeth committed Jan 23, 2025
1 parent 4366306 commit 5d79576
Show file tree
Hide file tree
Showing 8 changed files with 456 additions and 22 deletions.
425 changes: 425 additions & 0 deletions src/components/common/ContentButtons/SuperDislike.tsx

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions src/components/common/ContentButtons/SuperLike.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {
import {
fontSizeLarge,
fontSizeMedium,
minPriceSuperlike,
minPriceSuperLike,
} from "../../../constants/Misc.ts";
import { setNotification } from "../../../state/features/notificationsSlice.ts";
import { RootState } from "../../../state/store.ts";
Expand Down Expand Up @@ -52,7 +52,7 @@ export const SuperLike = ({
const [isOpen, setIsOpen] = useState<boolean>(false);

const [superlikeDonationAmount, setSuperlikeDonationAmount] =
useState<number>(minPriceSuperlike);
useState<number>(minPriceSuperLike);
const [currentBalance, setCurrentBalance] = useState<string>("");

const [comment, setComment] = useState<string>("");
Expand Down Expand Up @@ -95,10 +95,10 @@ export const SuperLike = ({
throw new Error("Could not retrieve content creator's address");
if (
!superlikeDonationAmount ||
superlikeDonationAmount < minPriceSuperlike
superlikeDonationAmount < minPriceSuperLike
)
throw new Error(
`The amount is ${superlikeDonationAmount}, but it needs to be at least ${minPriceSuperlike} QORT`
`The amount is ${superlikeDonationAmount}, but it needs to be at least ${minPriceSuperLike} QORT`
);

const listOfPublishes = [];
Expand Down Expand Up @@ -286,8 +286,8 @@ export const SuperLike = ({
</InputLabel>
<BoundedNumericTextField
addIconButtons={!isScreenSmall}
minValue={+minPriceSuperlike}
initialValue={minPriceSuperlike.toString()}
minValue={+minPriceSuperLike}
initialValue={minPriceSuperLike.toString()}
maxValue={numberToInt(+currentBalance)}
allowDecimals={false}
allowNegatives={false}
Expand Down
22 changes: 14 additions & 8 deletions src/components/common/ListSuperLikes/ListSuperLikes.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import * as React from "react";
import EmojiEventsIcon from "@mui/icons-material/EmojiEvents";
import ThumbUpIcon from "@mui/icons-material/ThumbUp";
import { Box } from "@mui/material";
import Avatar from "@mui/material/Avatar";
import Divider from "@mui/material/Divider";
import List from "@mui/material/List";
import ListItem from "@mui/material/ListItem";
import Divider from "@mui/material/Divider";
import ListItemText from "@mui/material/ListItemText";
import ListItemAvatar from "@mui/material/ListItemAvatar";
import Avatar from "@mui/material/Avatar";
import ListItemText from "@mui/material/ListItemText";
import Typography from "@mui/material/Typography";
import ThumbUpIcon from "@mui/icons-material/ThumbUp";
import { Box } from "@mui/material";
import * as React from "react";
import { useSelector } from "react-redux";
import { RootState } from "../../../state/store";
import { useNavigate } from "react-router-dom";
import EmojiEventsIcon from "@mui/icons-material/EmojiEvents";
import { fontSizeSmall } from "../../../constants/Misc.ts";
import { RootState } from "../../../state/store";
import { formatDate } from "../../../utils/time.ts";

const truncateMessage = message => {
return message.length > 40 ? message.slice(0, 40) + "..." : message;
};
Expand Down Expand Up @@ -139,6 +142,9 @@ export default function ListSuperLikes({ superlikes }) {
{forName}
</Box>
)}
<span style={{ fontSize: fontSizeSmall }}>
{formatDate(superlike.created)}
</span>
</Box>
</ListItem>
<Box
Expand Down
4 changes: 2 additions & 2 deletions src/components/common/Notifications/Notifications.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
FOR_SUPER_LIKE,
SUPER_LIKE_BASE,
} from "../../../constants/Identifiers.ts";
import { minPriceSuperlike } from "../../../constants/Misc.ts";
import { minPriceSuperLike } from "../../../constants/Misc.ts";

const generalLocal = localForage.createInstance({
name: "q-tube-general",
Expand Down Expand Up @@ -141,7 +141,7 @@ export const Notifications = () => {
if (!result) continue;
const res = await getPaymentInfo(result);
if (
+res?.amount >= minPriceSuperlike &&
+res?.amount >= minPriceSuperLike &&
res.recipient === usernameAddress &&
isTimestampWithinRange(res?.timestamp, comment.created)
) {
Expand Down
2 changes: 1 addition & 1 deletion src/constants/Identifiers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const useTestIdentifiers = false;
export const useTestIdentifiers = false;
export const QTUBE_VIDEO_BASE = useTestIdentifiers
? "MYTEST_vid_"
: "qtube_vid_";
Expand Down
5 changes: 4 additions & 1 deletion src/constants/Misc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export const minPriceSuperlike = 1;
import { useTestIdentifiers } from "./Identifiers.ts";

export const minPriceSuperLike = 1;
export const minPriceSuperDislike = 1;

export const titleFormatter = /[\r\n]+/g;
export const titleFormatterOnSave = /[\r\n/<>:"'\\*|?]+/g;
Expand Down
4 changes: 2 additions & 2 deletions src/pages/ContentPages/VideoContent/VideoContent-State.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
SUPER_LIKE_BASE,
} from "../../../constants/Identifiers.ts";
import {
minPriceSuperlike,
minPriceSuperLike,
titleFormatterOnSave,
} from "../../../constants/Misc.ts";
import { useFetchSuperLikes } from "../../../hooks/useFetchSuperLikes.tsx";
Expand Down Expand Up @@ -199,7 +199,7 @@ export const useVideoContentState = () => {
if (!result) continue;
const res = await getPaymentInfo(result);
if (
+res?.amount >= minPriceSuperlike &&
+res?.amount >= minPriceSuperLike &&
res.recipient === nameAddressParam &&
isTimestampWithinRange(res?.timestamp, comment.created)
) {
Expand Down
4 changes: 2 additions & 2 deletions src/wrappers/GlobalWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { EditPlaylist } from "../components/Publish/EditPlaylist/EditPlaylist";
import ConsentModal from "../components/common/ConsentModal";
import { useFetchSuperLikes } from "../hooks/useFetchSuperLikes";
import { SUPER_LIKE_BASE } from "../constants/Identifiers.ts";
import { minPriceSuperlike } from "../constants/Misc.ts";
import { minPriceSuperLike } from "../constants/Misc.ts";

interface Props {
children: React.ReactNode;
Expand Down Expand Up @@ -167,7 +167,7 @@ const GlobalWrapper: React.FC<Props> = ({ children, setTheme }) => {
if (!result) continue;
const res = await getPaymentInfo(result);
if (
+res?.amount >= minPriceSuperlike &&
+res?.amount >= minPriceSuperLike &&
isTimestampWithinRange(res?.timestamp, comment.created)
) {
addSuperlikeRawDataGetToList({
Expand Down

0 comments on commit 5d79576

Please sign in to comment.