Skip to content

Commit

Permalink
Merge branch 'CW-2196-pagination' of https://github.com/daostack/comm…
Browse files Browse the repository at this point in the history
…on-web into CW-2196-pagination
  • Loading branch information
pvm-code committed Nov 15, 2023
2 parents 9f23f42 + d4f8a76 commit a8a6ec3
Show file tree
Hide file tree
Showing 27 changed files with 134 additions and 38 deletions.
12 changes: 12 additions & 0 deletions craco.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,17 @@ module.exports = {
tsConfigPath: "./tsconfig.paths.json",
},
},
{
plugin: {
overrideWebpackConfig: ({ webpackConfig }) => {
webpackConfig.devtool =
process.env.REACT_APP_ENV === "dev"
? "source-map"
: "eval-cheap-module-source-map";

return webpackConfig;
},
},
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
flex-direction: column;
flex: 1;
width: inherit;
height: calc(100% - #{$container-desktop-header-height});
height: calc(100% - var(--chat-header-height, 0rem));
background-color: $white;
box-sizing: border-box;
--chat-input-wrapper-height: 3.125rem;
Expand All @@ -29,8 +29,7 @@
.emptyChat {
display: flex;
justify-content: center;
padding: 0.5rem 2rem 0;
padding-bottom: calc(var(--chat-input-wrapper-height) + 7rem);
align-self: center;
}

.bottomChatContainer {
Expand Down
8 changes: 4 additions & 4 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,13 @@ export default function ChatComponent({
const chatWrapperId = useMemo(() => `chat-wrapper-${uuidv4()}`, []);
const chatInputWrapperRef = useRef<HTMLDivElement>(null);
const chatContainerRef = useRef<HTMLDivElement>(null);
const [isScrolling, setScrolling] = useState(false);
const [isScrolling, setIsScrolling] = useState(false);
const chatContentContextValue: ChatContentData = useMemo(
() => ({
isScrolling,
chatContentRect: chatContainerRef.current?.getBoundingClientRect(),
}),
[isScrolling],
[isScrolling, chatContainerRef.current],
);

const [message, setMessage] = useState<TextEditorValue>(
Expand Down Expand Up @@ -611,11 +611,11 @@ export default function ChatComponent({

useEffect(() => {
const deactivateScrollingFlag = debounce(() => {
setScrolling(false);
setIsScrolling(false);
}, 300);

function handleScroll() {
setScrolling(true);
setIsScrolling(true);
deactivateScrollingFlag();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
.noMessagesText {
align-self: flex-start;
max-width: 17.5rem;
margin: 3.375rem 0 0;
padding: 0.5rem 1rem;
font-size: $xsmall;
line-height: 143%;
Expand Down
1 change: 1 addition & 0 deletions src/pages/common/components/ChatComponent/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface ChatItem {
lastSeenItem?: CommonFeedObjectUserUnique["lastSeen"];
lastSeenAt?: CommonFeedObjectUserUnique["lastSeenAt"];
seenOnce?: boolean;
hasUnseenMention?: CommonFeedObjectUserUnique["hasUnseenMention"];
}

export interface ChatContextValue {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
lastSeenItem: feedItemUserMetadata?.lastSeen,
lastSeenAt: feedItemUserMetadata?.lastSeenAt,
seenOnce: feedItemUserMetadata?.seenOnce,
hasUnseenMention: feedItemUserMetadata?.hasUnseenMention,
});
}
}, [
Expand All @@ -177,6 +178,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
feedItemUserMetadata?.lastSeen,
feedItemUserMetadata?.lastSeenAt,
feedItemUserMetadata?.seenOnce,
feedItemUserMetadata?.hasUnseenMention,
]);

const onDiscussionDelete = useCallback(async () => {
Expand Down Expand Up @@ -321,6 +323,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
isPreviewMode={isPreviewMode}
isPinned={isPinned}
commonName={commonName}
commonId={commonId}
image={commonImage}
imageAlt={`${commonName}'s image`}
isProject={isProject}
Expand All @@ -333,6 +336,10 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
seen={feedItemUserMetadata?.seen ?? !isFeedItemUserMetadataFetched}
ownerId={item.userId}
discussionPredefinedType={discussion?.predefinedType}
hasUnseenMention={
feedItemUserMetadata?.hasUnseenMention ??
!isFeedItemUserMetadataFetched
}
>
{renderContent()}
</FeedCard>
Expand Down
6 changes: 6 additions & 0 deletions src/pages/common/components/FeedCard/FeedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type FeedCardProps = PropsWithChildren<{
lastMessage?: TextEditorValue;
isPreviewMode?: boolean;
commonName?: string;
commonId?: string;
image?: string;
imageAlt?: string;
isProject?: boolean;
Expand All @@ -45,6 +46,7 @@ type FeedCardProps = PropsWithChildren<{
discussionPredefinedType?: PredefinedTypes;
hasFiles?: boolean;
hasImages?: boolean;
hasUnseenMention?: boolean;
}>;

const MOBILE_HEADER_HEIGHT = 52;
Expand All @@ -69,6 +71,7 @@ export const FeedCard = forwardRef<FeedCardRef, FeedCardProps>((props, ref) => {
lastMessage,
isPreviewMode = true,
commonName,
commonId,
image,
imageAlt,
isProject,
Expand All @@ -79,6 +82,7 @@ export const FeedCard = forwardRef<FeedCardRef, FeedCardProps>((props, ref) => {
menuItems,
seenOnce,
seen,
hasUnseenMention,
ownerId,
discussionPredefinedType,
hasImages,
Expand Down Expand Up @@ -192,6 +196,7 @@ export const FeedCard = forwardRef<FeedCardRef, FeedCardProps>((props, ref) => {
lastMessage: !isLoading ? lastMessage : undefined,
menuItems,
commonName,
commonId,
image,
imageAlt,
isProject,
Expand All @@ -204,6 +209,7 @@ export const FeedCard = forwardRef<FeedCardRef, FeedCardProps>((props, ref) => {
discussionPredefinedType,
hasFiles,
hasImages,
hasUnseenMention,
})}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,7 @@
border-radius: 50%;
background-color: $c-pink-primary;
}

.hasUnseenMention {
color: $c-pink-primary;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ interface FeedCardTagsProps {
isActive: boolean;
isPinned?: boolean;
isFollowing?: boolean;
hasUnseenMention?: boolean;
}

export const FeedCardTags: FC<FeedCardTagsProps> = (props) => {
Expand All @@ -28,6 +29,7 @@ export const FeedCardTags: FC<FeedCardTagsProps> = (props) => {
isActive,
isPinned,
isFollowing,
hasUnseenMention,
} = props;
const user = useSelector(selectUser());
const isOwner = ownerId === user?.uid;
Expand All @@ -54,6 +56,7 @@ export const FeedCardTags: FC<FeedCardTagsProps> = (props) => {
})}
/>
)}
{hasUnseenMention && <div className={styles.hasUnseenMention}>@</div>}
{isFollowing && (
<StarIcon className={styles.starIcon} stroke="currentColor" />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
isFollowing,
isLoading = false,
shouldHideBottomContent = false,
hasUnseenMention,
} = props;
const contextMenuRef = useRef<ContextMenuRef>(null);
const [isLongPressing, setIsLongPressing] = useState(false);
Expand Down Expand Up @@ -154,6 +155,7 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
isActive={isActive}
isPinned={isPinned}
isFollowing={isFollowing}
hasUnseenMention={hasUnseenMention}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useHistory } from "react-router-dom";
import classNames from "classnames";
import { useFeedItemContext } from "@/pages/common";
import { useRoutesContext } from "@/shared/contexts";
import { useCommon } from "@/shared/hooks/useCases";
import { useCommon, useFeedItemFollow } from "@/shared/hooks/useCases";
import { OpenIcon } from "@/shared/icons";
import { CommonFeed } from "@/shared/models";
import { CommonAvatar, parseStringToTextEditorValue } from "@/shared/ui-kit";
Expand All @@ -22,6 +22,10 @@ export const ProjectFeedItem: FC<ProjectFeedItemProps> = (props) => {
const { getCommonPagePath } = useRoutesContext();
const { renderFeedItemBaseContent } = useFeedItemContext();
const { data: common, fetched: isCommonFetched, fetchCommon } = useCommon();
const feedItemFollow = useFeedItemFollow(
{ feedItemId: item.id, commonId: item.data.id },
{ withSubscription: true },
);
const {
projectUnreadStreamsCount: unreadStreamsCount,
projectUnreadMessages: unreadMessages,
Expand Down Expand Up @@ -76,6 +80,7 @@ export const ProjectFeedItem: FC<ProjectFeedItemProps> = (props) => {
lastMessage,
renderLeftContent,
shouldHideBottomContent: !lastMessage,
isFollowing: feedItemFollow.isFollowing,
})}
</>
) || null
Expand Down
3 changes: 3 additions & 0 deletions src/pages/common/components/FeedItem/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export interface FeedItemBaseContentProps {
seen?: boolean;
ownerId?: string;
commonName?: string;
commonId?: string;
renderImage?: (className?: string) => ReactNode;
renderLeftContent?: () => ReactNode;
image?: string;
Expand All @@ -42,6 +43,8 @@ export interface FeedItemBaseContentProps {
hasImages?: boolean;
isLoading?: boolean;
shouldHideBottomContent?: boolean;
dmUserId?: string;
hasUnseenMention?: boolean;
}

export interface GetLastMessageOptions {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
lastSeenItem: feedItemUserMetadata?.lastSeen,
lastSeenAt: feedItemUserMetadata?.lastSeenAt,
seenOnce: feedItemUserMetadata?.seenOnce,
hasUnseenMention: feedItemUserMetadata?.hasUnseenMention,
});
}
}, [
Expand All @@ -281,6 +282,7 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
feedItemUserMetadata?.lastSeen,
feedItemUserMetadata?.lastSeenAt,
feedItemUserMetadata?.seenOnce,
feedItemUserMetadata?.hasUnseenMention,
]);

useEffect(() => {
Expand Down Expand Up @@ -458,6 +460,11 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
seen={feedItemUserMetadata?.seen ?? !isFeedItemUserMetadataFetched}
menuItems={menuItems}
ownerId={item.userId}
commonId={commonId}
hasUnseenMention={
feedItemUserMetadata?.hasUnseenMention ??
!isFeedItemUserMetadataFetched
}
>
{renderContent()}
</FeedCard>
Expand Down
7 changes: 6 additions & 1 deletion src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ import {
import { InfiniteScroll, TextEditorValue } from "@/shared/ui-kit";
import {
addQueryParam,
checkIsProject,
deleteQueryParam,
getParamsFromOneOfRoutes,
getUserName,
Expand Down Expand Up @@ -616,6 +615,12 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
}
}, [batchNumber]);

useEffect(() => {
if (sharedFeedItemId && isTabletView && allFeedItems) {
setActiveChatItem({ feedItemId: sharedFeedItemId });
}
}, [sharedFeedItemId, isTabletView, allFeedItems]);

useImperativeHandle(
ref,
() => ({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
@import "../../../../../../constants";

.rightPaneContainerWithHeader {
--chat-header-height: #{$container-desktop-header-height};
}

.titleWrapper {
height: $container-desktop-header-height;
height: var(--chat-header-height);
padding: 0 1.25rem;
display: flex;
align-items: center;
background-color: $c-light-gray-2;
border-bottom: 0.0625rem solid $c-light-gray;
box-sizing: border-box;
}

.title {
margin: 0;
display: -webkit-box;
Expand All @@ -22,6 +27,7 @@
overflow-wrap: break-word;
text-overflow: ellipsis;
}

.titleRTL {
text-align: right;
direction: rtl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ const DesktopChat: FC<ChatProps> = (props) => {
}, [dmUserId]);

return (
<DesktopRightPane className={className}>
<DesktopRightPane
className={classNames(className, {
[styles.rightPaneContainerWithHeader]: withTitle,
})}
>
{withTitle && (
<div className={styles.titleWrapper}>
{dmUser?.photoURL && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@import "../../../../../../constants";

.modal {
height: 90vh;

.modalHeaderWrapper {
padding: 0;

Expand Down
1 change: 1 addition & 0 deletions src/pages/inbox/BaseInbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ const InboxPage: FC<InboxPageProps> = (props) => {
renderChatChannelItem={renderChatChannelItem}
onFeedItemUpdate={handleFeedItemUpdate}
getLastMessage={getLastMessage}
sharedFeedItemId={sharedFeedItemId}
emptyText={
isActiveUnreadInboxItemsQueryParam
? "Hurry! No unread items in your inbox :-)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ export const ChatChannelItem: FC<ChatChannelFeedLayoutItemProps> = (props) => {
ownerId={userId}
renderImage={renderImage}
isImageRounded
dmUserId={dmUserId}
/>
);
};
Loading

0 comments on commit a8a6ec3

Please sign in to comment.