Skip to content

Commit

Permalink
Revert package.json changes, adjust existing
Browse files Browse the repository at this point in the history
  • Loading branch information
arnautov-anton committed Dec 4, 2024
1 parent 66c8cf4 commit 8f1a777
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 59 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@
"esbuild-plugin-replace": "^1.4.0",
"eslint": "7.14.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^9.1.0",
"eslint-config-prettier": "^6.15.0",
"eslint-config-react-app": "^6.0.0",
"eslint-import-resolver-alias": "^1.1.2",
"eslint-import-resolver-babel-module": "^5.2.0",
Expand All @@ -236,7 +236,7 @@
"eslint-plugin-jest-dom": "^3.3.0",
"eslint-plugin-jsx-a11y": "^6.4.1",
"eslint-plugin-node": "^11.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-react": "^7.21.5",
"eslint-plugin-react-hooks": "^4.2.0",
Expand All @@ -252,7 +252,7 @@
"jsdom": "^24.1.1",
"lint-staged": "^15.2.1",
"moment-timezone": "^0.5.43",
"prettier": "^3.3.3",
"prettier": "^2.2.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"react-test-renderer": "^18.1.0",
Expand Down
8 changes: 4 additions & 4 deletions src/components/ChannelList/ChannelList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const DEFAULT_OPTIONS = {};
const DEFAULT_SORT = {};

export type ChannelListProps<
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
StreamChatGenerics extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
> = {
/** Additional props for underlying ChannelSearch component and channel search controller, [available props](https://getstream.io/chat/docs/sdk/react/utility-components/channel_search/#props) */
additionalChannelSearchProps?: Omit<ChannelSearchProps<StreamChatGenerics>, 'setChannels'>;
Expand Down Expand Up @@ -280,10 +280,9 @@ const UnMemoizedChannelList = <SCG extends DefaultStreamChatGenerics = DefaultSt

useMobileNavigation(channelListRef, navOpen, closeMobileNav);

const { customFn, defaultFn } = usePrepareShapeHandlers<SCG>({
const { customHandler, defaultHandler } = usePrepareShapeHandlers<SCG>({
allowNewMessagesFromUnfilteredChannels,
filters,
sort,
lockChannelOrder,
onAddedToChannel,
onChannelDeleted,
Expand All @@ -295,11 +294,12 @@ const UnMemoizedChannelList = <SCG extends DefaultStreamChatGenerics = DefaultSt
onMessageNewHandler,
onRemovedFromChannel,
setChannels,
sort,
// TODO: implement
// customHandleChannelListShape
});

useChannelListShape<SCG>(customFn ?? defaultFn);
useChannelListShape<SCG>(customHandler ?? defaultHandler);

// TODO: maybe move this too
useConnectionRecoveredListener(forceUpdate);
Expand Down
53 changes: 28 additions & 25 deletions src/components/ChannelList/hooks/useChannelListShape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,17 @@ type HandleNotificationMessageNewParameters<SCG extends ExtendableGenerics> = Ba
lockChannelOrder: boolean;
} & Required<Pick<ChannelListProps<SCG>, 'filters' | 'sort'>>;

type HandleNotificationRemovedFromChannelParameters<SCG extends ExtendableGenerics> =
BaseParameters<SCG> & RepeatedParameters<SCG>;
type HandleNotificationRemovedFromChannelParameters<
SCG extends ExtendableGenerics
> = BaseParameters<SCG> & RepeatedParameters<SCG>;

type HandleNotificationAddedToChannelParameters<SCG extends ExtendableGenerics> =
BaseParameters<SCG> &
RepeatedParameters<SCG> & {
allowNewMessagesFromUnfilteredChannels: boolean;
lockChannelOrder: boolean;
} & Required<Pick<ChannelListProps<SCG>, 'sort'>>;
type HandleNotificationAddedToChannelParameters<
SCG extends ExtendableGenerics
> = BaseParameters<SCG> &
RepeatedParameters<SCG> & {
allowNewMessagesFromUnfilteredChannels: boolean;
lockChannelOrder: boolean;
} & Required<Pick<ChannelListProps<SCG>, 'sort'>>;

type HandleMemberUpdatedParameters<SCG extends ExtendableGenerics> = BaseParameters<SCG> & {
lockChannelOrder: boolean;
Expand Down Expand Up @@ -99,12 +101,12 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
const handleMessageNew = useCallback(
({
allowNewMessagesFromUnfilteredChannels,
filters,
sort,
customHandler,
event,
filters,
lockChannelOrder,
setChannels,
sort,
}: HandleMessageNewParameters<SCG>) => {
if (typeof customHandler === 'function') {
return customHandler(setChannels, event);
Expand Down Expand Up @@ -159,11 +161,11 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
const handleNotificationMessageNew = useCallback(
async ({
allowNewMessagesFromUnfilteredChannels,
sort,
filters,
customHandler,
event,
filters,
setChannels,
sort,
}: HandleNotificationMessageNewParameters<SCG>) => {
if (typeof customHandler === 'function') {
return customHandler(setChannels, event);
Expand Down Expand Up @@ -246,7 +248,7 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
);

const handleMemberUpdated = useCallback(
({ sort, event, lockChannelOrder, setChannels }: HandleMemberUpdatedParameters<SCG>) => {
({ event, lockChannelOrder, setChannels, sort }: HandleMemberUpdatedParameters<SCG>) => {
if (!event.member?.user || event.member.user.id !== client.userID || !event.channel_type) {
return;

Check warning on line 253 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L253

Added line #L253 was not covered by tests
}
Expand All @@ -258,7 +260,7 @@ export const useChannelListShapeDefaults = <SCG extends ExtendableGenerics>() =>
const considerPinnedChannels = shouldConsiderPinnedChannels(sort);

Check warning on line 260 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L260

Added line #L260 was not covered by tests

// TODO: extract this and consider single property sort object too
const pinnedAtSort = Array.isArray(sort) ? (sort[0]?.pinned_at ?? null) : null;
const pinnedAtSort = Array.isArray(sort) ? sort[0]?.pinned_at ?? null : null;

setChannels((currentChannels) => {
const targetChannel = client.channel(channelType, channelId);

Check warning on line 266 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L265-L266

Added lines #L265 - L266 were not covered by tests
Expand Down Expand Up @@ -448,17 +450,18 @@ type UseDefaultHandleChannelListShapeParameters<SCG extends ExtendableGenerics>
| 'onMessageNewHandler'
| 'onRemovedFromChannel'
> & {
setChannels: SetChannels<SCG>;
customHandleChannelListShape?: (data: {
defaults: ReturnType<typeof useChannelListShapeDefaults<SCG>>;
defaults: ReturnType<typeof useChannelListShapeDefaults>;
event: Event<SCG>;
setChannels: SetChannels<SCG>;
}) => void;
setChannels: SetChannels<SCG>;
};

export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
allowNewMessagesFromUnfilteredChannels,
customHandleChannelListShape,
filters,
lockChannelOrder,
onAddedToChannel,
onChannelDeleted,
Expand All @@ -470,7 +473,6 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
onMessageNewHandler,
onRemovedFromChannel,
setChannels,
filters,
sort,
}: UseDefaultHandleChannelListShapeParameters<SCG>) => {
const defaults = useChannelListShapeDefaults<SCG>();
Expand All @@ -480,6 +482,7 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
const customHandleChannelListShapeRef = useRef<(e: Event<SCG>) => void>();

customHandleChannelListShapeRef.current = (event: Event<SCG>) => {
// @ts-expect-error can't use ReturnType<typeof useChannelListShapeDefaults<SCG>> until we upgrade prettier to at least v2.7.0
customHandleChannelListShape?.({ defaults, event, setChannels });

Check warning on line 486 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L486

Added line #L486 was not covered by tests
};

Expand All @@ -488,33 +491,33 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
case 'message.new':
defaults.handleMessageNew({
allowNewMessagesFromUnfilteredChannels,
sort,
filters,
customHandler: onMessageNewHandler,
event,
filters,
lockChannelOrder,
setChannels,
sort,
});
break;
case 'notification.message_new':
defaults.handleNotificationMessageNew({
allowNewMessagesFromUnfilteredChannels,
sort,
filters,
customHandler: onMessageNew,
event,
filters,
lockChannelOrder,
setChannels,
sort,
});
break;
case 'notification.added_to_channel':
defaults.handleNotificationAddedToChannel({
allowNewMessagesFromUnfilteredChannels,
sort,
customHandler: onAddedToChannel,
event,
lockChannelOrder,
setChannels,
sort,
});
break;
case 'notification.removed_from_channel':
Expand Down Expand Up @@ -548,10 +551,10 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
break;

Check warning on line 551 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L550-L551

Added lines #L550 - L551 were not covered by tests
case 'member.updated':
defaults.handleMemberUpdated({

Check warning on line 553 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L553

Added line #L553 was not covered by tests
sort,
event,
lockChannelOrder,
setChannels,
sort,
});
break;

Check warning on line 559 in src/components/ChannelList/hooks/useChannelListShape.ts

View check run for this annotation

Codecov / codecov/patch

src/components/ChannelList/hooks/useChannelListShape.ts#L559

Added line #L559 was not covered by tests
default:
Expand All @@ -572,8 +575,8 @@ export const usePrepareShapeHandlers = <SCG extends ExtendableGenerics>({
}, [customHandleChannelListShape]);

return {
defaultFn,
customFn,
customHandler: customFn,
defaultHandler: defaultFn,
};
};

Expand Down
2 changes: 1 addition & 1 deletion src/components/ChannelList/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type MoveChannelUpwardsParams<SCG extends DefaultStreamChatGenerics = DefaultStr
* This function should not be used to move pinned already channels.
*/
export const moveChannelUpwards = <
SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics,
SCG extends DefaultStreamChatGenerics = DefaultStreamChatGenerics
>({
channels,
channelToMove,
Expand Down
45 changes: 19 additions & 26 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2114,11 +2114,6 @@
dependencies:
"@octokit/openapi-types" "^16.0.0"

"@pkgr/core@^0.1.0":
version "0.1.1"
resolved "https://registry.yarnpkg.com/@pkgr/core/-/core-0.1.1.tgz#1ec17e2edbec25c8306d424ecfbf13c7de1aaa31"
integrity sha512-cq8o4cWH0ibXh9VGi5P20Tu9XF/0fFXl9EUinr9QfTM7a7p0oTA4iJRCQWppXR1Pg8dSM0UCItCkPwsk9qWWYA==

"@playwright/test@^1.42.1":
version "1.42.1"
resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.42.1.tgz#9eff7417bcaa770e9e9a00439e078284b301f31c"
Expand Down Expand Up @@ -5653,10 +5648,12 @@ eslint-config-airbnb@^18.2.1:
object.assign "^4.1.2"
object.entries "^1.1.2"

eslint-config-prettier@^9.1.0:
version "9.1.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-9.1.0.tgz#31af3d94578645966c082fcb71a5846d3c94867f"
integrity sha512-NSWl5BFQWEPi1j4TjVNItzYV7dZXZ+wP6I6ZhrBGpChQhZRUaElihE9uRRkcbRnNb76UMKDF3r+WTmNcGPKsqw==
eslint-config-prettier@^6.15.0:
version "6.15.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.15.0.tgz#7f93f6cb7d45a92f1537a70ecc06366e1ac6fed9"
integrity sha512-a1+kOYLR8wMGustcgAjdydMsQ2A/2ipRPwRKUmfYaSxc9ZPcrku080Ctl6zrZzZNs/U82MjSv+qKREkoq3bJaw==
dependencies:
get-stdin "^6.0.0"

eslint-config-react-app@^6.0.0:
version "6.0.0"
Expand Down Expand Up @@ -5781,13 +5778,12 @@ eslint-plugin-node@^11.1.0:
resolve "^1.10.1"
semver "^6.1.0"

eslint-plugin-prettier@^5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-5.2.1.tgz#d1c8f972d8f60e414c25465c163d16f209411f95"
integrity sha512-gH3iR3g4JfF+yYPaJYkN7jEl9QbweL/YfkoRlNnuIEHEz1vHVlCmWOS+eGGiRuzHQXdJFCOTxRgvju9b8VUmrw==
eslint-plugin-prettier@^3.1.4:
version "3.3.1"
resolved "https://registry.yarnpkg.com/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz#7079cfa2497078905011e6f82e8dd8453d1371b7"
integrity sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==
dependencies:
prettier-linter-helpers "^1.0.0"
synckit "^0.9.1"

eslint-plugin-promise@^4.2.1:
version "4.3.1"
Expand Down Expand Up @@ -6575,6 +6571,11 @@ get-port@^5.0.0:
resolved "https://registry.yarnpkg.com/get-port/-/get-port-5.1.1.tgz#0469ed07563479de6efb986baf053dcd7d4e3193"
integrity sha512-g/Q1aTSDOxFpchXC4i8ZWvxA1lnPqx/JHqcpIw0/LX9T8x/GBbi6YnlN5nhaKIFkT8oFsscUKgDJYxfwfS6QsQ==

get-stdin@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/get-stdin/-/get-stdin-6.0.0.tgz#9e09bf712b360ab9225e812048f71fde9c89657b"
integrity sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==

get-stream@^6.0.0:
version "6.0.1"
resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7"
Expand Down Expand Up @@ -10788,10 +10789,10 @@ prettier-linter-helpers@^1.0.0:
dependencies:
fast-diff "^1.1.2"

prettier@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.3.3.tgz#30c54fe0be0d8d12e6ae61dbb10109ea00d53105"
integrity sha512-i2tDNA0O5IrMO757lfrdQZCc2jPNDVntV0m/+4whiDfWaTKfMNgR7Qz0NAeGz/nRqF4m5/6CLzbP4/liHt12Ew==
prettier@^2.2.0:
version "2.2.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.2.1.tgz#795a1a78dd52f073da0cd42b21f9c91381923ff5"
integrity sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==

pretty-format@^26.6.2:
version "26.6.2"
Expand Down Expand Up @@ -12494,14 +12495,6 @@ symlink-or-copy@^1.1.8, symlink-or-copy@^1.2.0, symlink-or-copy@^1.3.1:
resolved "https://registry.yarnpkg.com/symlink-or-copy/-/symlink-or-copy-1.3.1.tgz#9506dd64d8e98fa21dcbf4018d1eab23e77f71fe"
integrity sha512-0K91MEXFpBUaywiwSSkmKjnGcasG/rVBXFLJz5DrgGabpYD6N+3yZrfD6uUIfpuTu65DZLHi7N8CizHc07BPZA==

synckit@^0.9.1:
version "0.9.2"
resolved "https://registry.yarnpkg.com/synckit/-/synckit-0.9.2.tgz#a3a935eca7922d48b9e7d6c61822ee6c3ae4ec62"
integrity sha512-vrozgXDQwYO72vHjUb/HnFbQx1exDjoKzqx23aXEg2a9VIg2TSFZ8FmeZpTjUCFMYw7mpX4BE2SFu8wI7asYsw==
dependencies:
"@pkgr/core" "^0.1.0"
tslib "^2.6.2"

table@^5.2.3:
version "5.4.6"
resolved "https://registry.yarnpkg.com/table/-/table-5.4.6.tgz#1292d19500ce3f86053b05f0e8e7e4a3bb21079e"
Expand Down

0 comments on commit 8f1a777

Please sign in to comment.