Skip to content

Commit

Permalink
Merge pull request #2762 from daostack/CW-mention-streams
Browse files Browse the repository at this point in the history
In-chat mention and creation of new stream
  • Loading branch information
pvm-code authored Dec 19, 2024
2 parents 70525c1 + 9018e78 commit cea5255
Show file tree
Hide file tree
Showing 76 changed files with 1,794 additions and 678 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"@floating-ui/react-dom-interactions": "^0.13.1",
"@headlessui/react": "^1.7.4",
"@storybook/addon-viewport": "^6.5.13",
"@tanstack/react-query": "4.5.0",
"@tanstack/react-table": "^8.7.9",
"@types/react-pdf": "^5.7.2",
"axios": "^0.21.0",
Expand All @@ -33,7 +34,6 @@
"lodash": "^4.17.20",
"millify": "^3.5.2",
"moment": "^2.29.1",
"node-sass": "^4.14.1",
"openpgp": "4.10.4",
"pluralize": "^8.0.0",
"query-string": "^7.1.0",
Expand Down Expand Up @@ -67,6 +67,7 @@
"redux-persist": "^6.0.0",
"redux-saga": "^1.1.3",
"reselect": "^4.0.0",
"node-sass": "^4.14.1",
"slate": "0.94.1",
"slate-history": "0.93.0",
"slate-react": "0.98.1",
Expand Down
5 changes: 5 additions & 0 deletions src/globals.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ declare global {
};
}
}

declare module '*.module.scss' {
const classes: { [key: string]: string };
export default classes;
}
31 changes: 20 additions & 11 deletions src/pages/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ import {
NotificationsHandler,
} from "./handlers";
import { Router } from "./router";
import {
QueryClient,
QueryClientProvider,
} from '@tanstack/react-query'

// Create a client
const queryClient = new QueryClient()

const App = () => {
const dispatch = useDispatch();
Expand All @@ -28,17 +35,19 @@ const App = () => {
}, [dispatch, isDesktop]);

return (
<ReactRouter history={history}>
<BackgroundNotificationModal />
<CommonHandler />
<TextDirectionHandler />
<ThemeHandler />
<UserNotificationsAmountHandler />
<WebViewLoginHandler />
<NotificationsHandler />
<LoginContainer />
<Router />
</ReactRouter>
<QueryClientProvider client={queryClient}>
<ReactRouter history={history}>
<BackgroundNotificationModal />
<CommonHandler />
<TextDirectionHandler />
<ThemeHandler />
<UserNotificationsAmountHandler />
<WebViewLoginHandler />
<NotificationsHandler />
<LoginContainer />
<Router />
</ReactRouter>
</QueryClientProvider>
);
};

Expand Down
1 change: 1 addition & 0 deletions src/pages/App/router/components/LayoutRoute/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface RenderFunctionOptions<T extends Route = Route>
configuration: T;
userRoles?: UserRole[];
authenticated: boolean;
component?: React.ComponentType<any>;
}

export type RenderRouteContentFunction<T extends Route = Route> = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interface CirclesSelectProps {
value: CircleSelectType | CircleSelectType[] | null;
selectStyles?: StylesConfig<CircleSelectType>;
error?: string;
onBlur: (e: React.FocusEvent<any, Element>) => void;
onBlur: (e: React.FocusEvent<HTMLInputElement>) => void;
isOptionDisabled?: (option: CircleSelectType) => boolean;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { FC, useMemo } from "react";
import React, { FC, useMemo, ReactElement } from "react";
import classNames from "classnames";
import { ReactElement } from "hoist-non-react-statics/node_modules/@types/react";
import { ProgressBar } from "@/shared/components";
import { VotingCardType } from "@/shared/models";

Expand Down
2 changes: 1 addition & 1 deletion src/pages/OldCommon/hooks/useCommonMembers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export const useCommonMembers = ({ commonId }: Options): Return => {
const useCommonMembersTrace = trace(perf, 'useCommonMembers');
useCommonMembersTrace.start();

const cachedUserStates = selectUserStates()(store.getState());
const cachedUserStates = selectUserStates(store.getState());
const hasUsersFromCache = commonMembers.some(
({ userId }) => cachedUserStates[userId]?.data,
);
Expand Down
13 changes: 13 additions & 0 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import {
useZoomDisabling,
useImageSizeCheck,
useQueryParams,
useFetchDiscussionsByCommonId,
} from "@/shared/hooks";
import { ArrowInCircleIcon } from "@/shared/icons";
import { LinkPreviewData } from "@/shared/interfaces";
Expand Down Expand Up @@ -113,6 +114,7 @@ interface ChatComponentInterface {
directParent?: DirectParent | null;
renderChatInput?: () => ReactNode;
onUserClick?: (userId: string) => void;
onStreamMentionClick?: (feedItemId: string) => void;
onFeedItemClick?: (feedItemId: string) => void;
onInternalLinkClick?: (data: InternalLinkData) => void;
}
Expand Down Expand Up @@ -161,6 +163,7 @@ export default function ChatComponent({
directParent,
renderChatInput: renderChatInputOuter,
onUserClick,
onStreamMentionClick,
onFeedItemClick,
onInternalLinkClick,
}: ChatComponentInterface) {
Expand Down Expand Up @@ -207,6 +210,7 @@ export default function ChatComponent({
},
onFeedItemClick,
onUserClick,
onStreamMentionClick,
commonId,
onInternalLinkClick,
});
Expand All @@ -220,6 +224,9 @@ export default function ChatComponent({
chatChannelId: chatChannel?.id || "",
participants: chatChannel?.participants,
});

const { data: discussionsData } = useFetchDiscussionsByCommonId(commonId);

const users = useMemo(
() => (chatChannel ? chatUsers : discussionUsers),
[chatUsers, discussionUsers, chatChannel],
Expand Down Expand Up @@ -877,6 +884,7 @@ export default function ChatComponent({
onMessageDelete={handleMessageDelete}
directParent={directParent}
onUserClick={onUserClick}
onStreamMentionClick={onStreamMentionClick}
onFeedItemClick={onFeedItemClick}
onInternalLinkClick={onInternalLinkClick}
isEmpty={
Expand Down Expand Up @@ -914,6 +922,7 @@ export default function ChatComponent({
onClearFinished={onClearFinished}
shouldReinitializeEditor={shouldReinitializeEditor}
users={users}
discussions={discussionsData ?? []}
onEnterKeyDown={onEnterKeyDown}
emojiCount={emojiCount}
setMessage={setMessage}
Expand All @@ -929,6 +938,10 @@ export default function ChatComponent({
canSendMessage={Boolean(canSendMessage)}
inputContainerRef={inputContainerRef}
editorRef={editorRef}
user={user}
commonId={commonId}
circleVisibility={discussion?.circleVisibility}
onInternalLinkClick={onInternalLinkClick}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ interface ChatContentInterface {
onMessageDelete?: (messageId: string) => void;
directParent?: DirectParent | null;
onUserClick?: (userId: string) => void;
onStreamMentionClick?: (link: string) => void;
onFeedItemClick?: (feedItemId: string) => void;
onInternalLinkClick?: (data: InternalLinkData) => void;
isEmpty?: boolean;
Expand Down Expand Up @@ -106,6 +107,7 @@ const ChatContent: ForwardRefRenderFunction<
onMessageDelete,
directParent,
onUserClick,
onStreamMentionClick,
onFeedItemClick,
onInternalLinkClick,
isEmpty,
Expand Down Expand Up @@ -292,6 +294,7 @@ const ChatContent: ForwardRefRenderFunction<
onMessageDelete={onMessageDelete}
directParent={directParent}
onUserClick={onUserClick}
onStreamMentionClick={onStreamMentionClick}
onFeedItemClick={onFeedItemClick}
onInternalLinkClick={onInternalLinkClick}
chatChannelId={chatChannelId}
Expand All @@ -312,6 +315,7 @@ const ChatContent: ForwardRefRenderFunction<
onMessageDelete={onMessageDelete}
directParent={directParent}
onUserClick={onUserClick}
onStreamMentionClick={onStreamMentionClick}
onFeedItemClick={onFeedItemClick}
onInternalLinkClick={onInternalLinkClick}
isMessageEditAllowed={isMessageEditAllowed}
Expand Down
Loading

0 comments on commit cea5255

Please sign in to comment.