Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
12e78b6
added height, width in attachment meta and image caching
usmansalimLM May 2, 2025
2aba148
updated logic for default height and width
usmansalimLM May 2, 2025
6f0c4de
replaced keys for attachment meta and type
usmansalimLM May 5, 2025
6d7ab52
updated key for attachment
usmansalimLM May 5, 2025
3b048a0
fixed pagination in replies and formatted code
usmansalimLM May 9, 2025
29fa1f2
updated keys
usmansalimLM May 13, 2025
f66f56f
added flashlist and fixed video playing on scroll
usmansalimLM May 14, 2025
78b712f
added default height and width
usmansalimLM May 14, 2025
33c7ab7
added retry for video crash
usmansalimLM May 15, 2025
acb0d74
added flashlist
usmansalimLM May 15, 2025
d45280a
updated imports
usmansalimLM May 15, 2025
c758dda
added changes in video component
usmansalimLM May 16, 2025
c0196bd
updated custom widget key
usmansalimLM May 16, 2025
25c738d
removed fast image
usmansalimLM May 16, 2025
dacec0e
resolved comments
usmansalimLM May 16, 2025
428f2b8
updated custom widget key
usmansalimLM May 16, 2025
8af75d4
formatted code and added logic to calculate layout
usmansalimLM May 17, 2025
f04c43b
fixed seeking issues
usmansalimLM May 18, 2025
b524f67
resolved comments
usmansalimLM May 18, 2025
01f4025
resolved comments
usmansalimLM May 18, 2025
9b2e435
updated custom widget key
usmansalimLM May 19, 2025
458659d
resolved comments
usmansalimLM May 19, 2025
002150b
removed unused imports
usmansalimLM May 19, 2025
cc05a27
resolved comments
usmansalimLM May 19, 2025
51ec73c
added optimization
usmansalimLM May 19, 2025
345f854
resolved comment and replies issues
usmansalimLM May 20, 2025
549d9b2
fixed comment count issue
usmansalimLM May 20, 2025
1467ce6
fixed video player pause issue
usmansalimLM May 21, 2025
d9cd0cd
fixed peer testing issues
usmansalimLM May 21, 2025
67d3969
removed comments
usmansalimLM May 21, 2025
13663cb
resolved comments
usmansalimLM May 21, 2025
29f2ff9
refactored replies logic
usmansalimLM May 21, 2025
8ac115e
removed unused code
usmansalimLM May 22, 2025
d61280c
fixed pagination
usmansalimLM May 22, 2025
eb2f4e9
added missing logic
usmansalimLM May 23, 2025
e0ed67d
fixed duplication in replies
usmansalimLM May 23, 2025
78c4886
fixed pagination issue
usmansalimLM May 23, 2025
c846c74
added constant
usmansalimLM May 23, 2025
5e08017
upgraded version
usmansalimLM May 26, 2025
b864670
updated package lock
usmansalimLM May 26, 2025
6ee303f
Merge pull request #130 from LikeMindsCommunity/feature/LM-12281_atta…
usmansalimLM May 26, 2025
28377c9
Merge branch 'main' into release/v1.17.0
usmansalimLM May 26, 2025
be51751
adde main branch in workflow
usmansalimLM May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/branch-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
pull_request:
branches:
- master
- main

jobs:
validate-source-branch:
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ import { LMCommentViewData } from "../../models";
import { styles } from "./styles";
import decode from "../../utils/decodeMentions";
import { timeStamp } from "../../utils";
import { useAppSelector } from "../../store/store";
import { useAppDispatch, useAppSelector } from "../../store/store";
import { MemberRightsEnum } from "../../enums/MemberRightsEnum";
import STYLES from "../../constants/Styles";
import { usePostDetailContext } from "../../context";
import { CommunityConfigs } from "../../communityConfigs";
import pluralizeOrCapitalize from "../../utils/variables";
import { WordAction } from "../../enums/Variables";
import { clearComments } from "../../store/actions/postDetail";
const LMCommentItem = React.memo(
({
likeIconButton,
Expand Down Expand Up @@ -60,8 +61,11 @@ const LMCommentItem = React.memo(
comment?.likesCount
);
const [repliesArray, setRepliesArray] = useState<LMCommentViewData[]>([]);
const [replyPageNumber, setReplyPageNumber] = useState(2);
const [haveFirstPageReplies, setHaveFirstPageReplies] = useState(false);
const [repliesLoading, setRepliesLoading] = useState(false);
const [replyPageNumber, setReplyPageNumber] = useState(1);
const customLikeIcon = likeIconButton?.icon;
const [hasRepliesPaginationEnded, setHasRepliesPaginationEnded] = useState(false);
const loggedInUserMemberRights = useAppSelector(
(state) => state.login.memberRights
);
Expand All @@ -70,6 +74,7 @@ const LMCommentItem = React.memo(
);
const memberData = useAppSelector((state) => state.login.member);
const isCM = memberData?.state === STATE_ADMIN;
const dispatch = useAppDispatch();

// this handles the show more functionality
const onTextLayout = (event) => {
Expand All @@ -79,13 +84,11 @@ const LMCommentItem = React.memo(
}
};

const {setCommentOnFocus} = usePostDetailContext()
const {setCommentOnFocus, commentOnFocus} = usePostDetailContext();

useEffect(() => {
if (isRepliesVisible) {
setShowReplies(true);
onTapReplies &&
onTapReplies((data: Array<LMCommentViewData>) => setRepliesArray(data), "");
}
}, [isRepliesVisible]);

Expand Down Expand Up @@ -136,6 +139,12 @@ const LMCommentItem = React.memo(
};

const handleReplies = () => {
if (showReplies) {
setHasRepliesPaginationEnded(false);
setReplyPageNumber(1);
setHaveFirstPageReplies(false);
dispatch(clearComments(comment?.id))
}
setShowReplies(!showReplies);
};

Expand Down Expand Up @@ -353,10 +362,13 @@ const LMCommentItem = React.memo(
))}
<LMButton
onTap={() => {
onTapReplies
onTapReplies && !showReplies
? (onTapReplies(
(data: Array<LMCommentViewData>) =>
setRepliesArray(data),
(data: Array<LMCommentViewData>) => {
setRepliesArray(data);
setReplyPageNumber(replyPageNumber + 1)
setHaveFirstPageReplies(true);
},
""
),
handleReplies())
Expand Down Expand Up @@ -437,10 +449,10 @@ const LMCommentItem = React.memo(
{/* replies section */}
{showReplies && comment.repliesCount > 0 && (
<View style={styles.repliesView}>
{repliesArray && (
{comment?.replies && (
<FlatList
keyboardShouldPersistTaps={"handled"}
data={repliesArray}
data={comment?.replies ?? []}
renderItem={({ item }: any) => {
return (
<>
Expand All @@ -464,22 +476,29 @@ const LMCommentItem = React.memo(
</>
);
}}
// ListFooterComponentStyle={{}}
ListFooterComponent={
<>
{repliesArray.length > 0 ? (
{comment?.replies.length > 0 ? (
<>
{comment.repliesCount > repliesArray.length && (
{comment.repliesCount > comment?.replies.length && !hasRepliesPaginationEnded && (
<View style={styles.showMoreView}>
<LMButton
onTap={
onTapViewMore
onTapViewMore && !repliesLoading
? () => {
setReplyPageNumber(replyPageNumber + 1);
setRepliesLoading(true);
onTapViewMore(
replyPageNumber,
(data: Array<LMCommentViewData>) =>
haveFirstPageReplies ? replyPageNumber : 1,
(data: Array<LMCommentViewData>, hasPaginationEnded?: boolean) => {
setHaveFirstPageReplies(true);
setRepliesArray(data)
setRepliesLoading(false);
setReplyPageNumber(replyPageNumber + 1);
if (hasPaginationEnded) {
setHasRepliesPaginationEnded(hasPaginationEnded)
}
},
haveFirstPageReplies
);
}
: () => null
Expand All @@ -501,7 +520,7 @@ const LMCommentItem = React.memo(
buttonStyle={styles.viewMoreButton}
/>
<Text style={styles.commentPageNumberText}>
{repliesArray.length} of {comment.repliesCount}
{comment?.replies?.length} of {comment.repliesCount}
</Text>
</View>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export interface LMCommentProps {
likeTextButton?: LMButtonProps; // custom like text button
onTapViewMore?: (
page: number,
data: (repliesArray: Array<LMCommentViewData>) => void
data: (repliesArray: Array<LMCommentViewData>) => void,
haveFirstPageReplies?: boolean
) => void; // callback function to be executed on click of view more replies
commentMaxLines?: number; // maximun lines of comment to be shown
menuIcon?: LMButtonProps; // custom menu icon button
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import pluralizeOrCapitalize from "../../utils/variables";
import { WordAction } from "../../enums/Variables";
import useDebounceCallback from "../../hooks/useDebounceCallback"
import LMLoader from "../../components/LMLoader";
import { AttachmentType } from "@likeminds.community/feed-rn";

const LMCreatePostHeader = () => {
const dispatch = useAppDispatch();
Expand Down Expand Up @@ -84,7 +85,7 @@ const LMCreatePostHeader = () => {
const map: Map<string | undefined, string | undefined> = new Map();
const taggedUsers: any = userTaggingDecoder(postContentText);

const ogTags = formattedLinkAttachments[0]?.attachmentMeta?.ogTags;
const ogTags = formattedLinkAttachments[0]?.metaData?.ogTags;

// To fire user tagged analytics event
if (taggedUsers?.length > 0) {
Expand All @@ -109,12 +110,12 @@ const LMCreatePostHeader = () => {
let videoCount = 0;
let documentCount = 0;
for (let i = 0; i < allAttachment.length; i++) {
if (allAttachment[i].attachmentType === IMAGE_ATTACHMENT_TYPE) {
if (allAttachment[i].type === AttachmentType.IMAGE) {
imageCount++;
} else if (allAttachment[i].attachmentType === VIDEO_ATTACHMENT_TYPE) {
} else if (allAttachment[i].type === AttachmentType.VIDEO) {
videoCount++;
} else if (
allAttachment[i].attachmentType === DOCUMENT_ATTACHMENT_TYPE
allAttachment[i].type === AttachmentType.DOCUMENT
) {
documentCount++;
}
Expand Down Expand Up @@ -255,7 +256,7 @@ const LMCreatePostHeader = () => {
? styles.enabledOpacity
: styles.disabledOpacity
}
onPress={debouncedHandleOnPress}
onPress={handleOnPress}
>
{customCreatePostScreenHeader?.rightComponent ? (
customCreatePostScreenHeader?.rightComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
} from "../../constants/Strings";
import { styles } from "../../screens/createPost/styles";
import { LMButton } from "../../uiComponents";
import { AttachmentType } from "@likeminds.community/feed-rn";

const LMCreatePostMedia = () => {
const postListStyle = STYLES.$POST_LIST_STYLE;
Expand Down Expand Up @@ -96,7 +97,7 @@ const LMCreatePostMedia = () => {
>
<LMPostPollView
item={{
...formattedPollAttachments[0]?.attachmentMeta,
...formattedPollAttachments[0]?.metaData,
disabled: true,
}}
post={post}
Expand Down Expand Up @@ -134,11 +135,11 @@ const LMCreatePostMedia = () => {
) : (
<>
{/* single image selected section */}
{formattedMediaAttachments[0]?.attachmentType ===
IMAGE_ATTACHMENT_TYPE && (
{formattedMediaAttachments[0]?.type ===
AttachmentType.IMAGE && (
<LMImage
{...postMediaStyle?.image}
imageUrl={`${formattedMediaAttachments[0]?.attachmentMeta.url}`}
imageUrl={`${formattedMediaAttachments[0]?.metaData?.url}`}
showCancel={
postMediaStyle?.image?.showCancel != undefined
? postMediaStyle?.image?.showCancel
Expand All @@ -153,11 +154,11 @@ const LMCreatePostMedia = () => {
/>
)}
{/* single video selected section */}
{formattedMediaAttachments[0]?.attachmentType ===
VIDEO_ATTACHMENT_TYPE && (
{formattedMediaAttachments[0]?.type ===
AttachmentType.VIDEO && (
<LMCreatePostVideo
{...postMediaStyle?.video}
videoUrl={`${formattedMediaAttachments[0]?.attachmentMeta.url}`}
videoUrl={`${formattedMediaAttachments[0]?.metaData?.url}`}
showCancel={
postMediaStyle?.video?.showCancel != undefined
? postMediaStyle?.video?.showCancel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ import {
SET_FLOW_TO_CAROUSEL_SCREEN,
STATUS_BAR_STYLE,
} from "../../../store/types/types";
import {AttachmentType} from "@likeminds.community/feed-rn"
import { CAROUSEL_SCREEN } from "../../../constants/screenNames";
import Layout from "../../../constants/Layout";

const LMCarousel = React.memo(
({
Expand Down Expand Up @@ -49,6 +51,30 @@ const LMCarousel = React.memo(
}
};

// this functions calculates the max height among all the attachments in the carousel
const getMaxHeightOfAttachments = () => {
if (!post?.attachments?.length) return 0;

const screenWidth = Layout.window.width

// Map over attachments and compute scaled heights
const scaledHeights = post?.attachments?.map(item => {
const meta = item?.metaData;
const width = meta?.width;
const height = meta?.height;

if (!width || !height) return 0;

// Determine desired aspect ratio (portrait vs landscape)
const desiredAspectRatio = width > height ? 1.91 : 0.8;
return screenWidth * (1 / desiredAspectRatio);
});

let max = Math.max(...scaledHeights);

return max > 0 ? max : 500
};

return (
<SwiperFlatList
autoplay={lastItem ? true : false}
Expand All @@ -64,7 +90,7 @@ const LMCarousel = React.memo(
setLastItem(false);
}
}}
style={StyleSheet.flatten([styles.swiperView, carouselStyle])}
style={StyleSheet.flatten([styles.swiperView, carouselStyle, {minHeight: getMaxHeightOfAttachments()}])}
// handling custom style of pagination container
paginationStyle={StyleSheet.flatten([
styles.paginationView,
Expand All @@ -89,7 +115,7 @@ const LMCarousel = React.memo(
renderItem={({ item, index }) => (
<View style={styles.swiperListMediaContainer} onStartShouldSetResponder={() => true}>
{/* this section render image */}
{item?.attachmentType === IMAGE_ATTACHMENT_TYPE && (
{item?.type === AttachmentType.IMAGE && (
<Pressable
onPress={() => {
navigation.navigate(CAROUSEL_SCREEN, {
Expand All @@ -107,9 +133,9 @@ const LMCarousel = React.memo(
}}
>
<LMImage
imageUrl={item?.attachmentMeta?.url}
width={imageItem?.width}
height={imageItem?.height}
imageUrl={item?.metaData?.url}
width={item?.metaData?.width}
height={item?.metaData?.height}
imageStyle={imageItem?.imageStyle}
boxFit={imageItem?.boxFit}
boxStyle={imageItem?.boxStyle}
Expand All @@ -131,7 +157,7 @@ const LMCarousel = React.memo(
</Pressable>
)}
{/* this section render video */}
{item?.attachmentType === VIDEO_ATTACHMENT_TYPE && (
{item?.type === AttachmentType.VIDEO && (
<Pressable
onPress={() => {
navigation.navigate(CAROUSEL_SCREEN, {
Expand All @@ -151,9 +177,9 @@ const LMCarousel = React.memo(
}}
>
<LMVideo
videoUrl={item?.attachmentMeta?.url}
height={videoItem?.height}
width={videoItem?.width}
videoUrl={item?.metaData?.url}
height={item?.metaData?.height}
width={item?.metaData?.width}
videoStyle={videoItem?.videoStyle}
boxFit={videoItem?.boxFit}
boxStyle={videoItem?.boxStyle}
Expand Down Expand Up @@ -183,7 +209,7 @@ const LMCarousel = React.memo(
videoInFeed={videoItem?.videoInFeed}
videoInCarousel={true}
currentVideoInCarousel={
attachments[activeIndex]?.attachmentMeta?.url
attachments[activeIndex]?.metaData?.url
}
postId={videoItem?.postId}
showMuteUnmute={true}
Expand Down
Loading