Skip to content
Snippets Groups Projects
Unverified Commit 424f6132 authored by Diego Sampaio's avatar Diego Sampaio Committed by GitHub
Browse files

chore: remove ISubscription type casting on RoomOpenerEmbedded (#35295)

parent 683df295
No related branches found
No related tags found
No related merge requests found
import type { ISubscription, Serialized } from '@rocket.chat/core-typings';
export const mapSubscriptionFromApi = ({
ts,
lr,
ls,
_updatedAt,
oldRoomKeys,
suggestedOldRoomKeys,
...subscription
}: Serialized<ISubscription>): ISubscription => ({
...subscription,
ts: new Date(ts),
ls: new Date(ls),
lr: new Date(lr),
_updatedAt: new Date(_updatedAt),
...(oldRoomKeys && { oldRoomKeys: oldRoomKeys.map(({ ts, ...key }) => ({ ...key, ts: new Date(ts) })) }),
...(suggestedOldRoomKeys && { suggestedOldRoomKeys: suggestedOldRoomKeys.map(({ ts, ...key }) => ({ ...key, ts: new Date(ts) })) }),
});
import type { ISubscription, RoomType } from '@rocket.chat/core-typings';
import type { RoomType } from '@rocket.chat/core-typings';
import { Box, States, StatesIcon, StatesSubtitle, StatesTitle } from '@rocket.chat/fuselage';
import { FeaturePreviewOff, FeaturePreviewOn } from '@rocket.chat/ui-client';
import { useEndpoint, useStream, useUserId } from '@rocket.chat/ui-contexts';
......@@ -20,6 +20,7 @@ import { NotAuthorizedError } from '../../lib/errors/NotAuthorizedError';
import { NotSubscribedToRoomError } from '../../lib/errors/NotSubscribedToRoomError';
import { OldUrlRoomError } from '../../lib/errors/OldUrlRoomError';
import { RoomNotFoundError } from '../../lib/errors/RoomNotFoundError';
import { mapSubscriptionFromApi } from '../../lib/utils/mapSubscriptionFromApi';
const RoomProvider = lazy(() => import('./providers/RoomProvider'));
const RoomNotFound = lazy(() => import('./RoomNotFound'));
......@@ -59,7 +60,8 @@ const RoomOpenerEmbedded = ({ type, reference }: RoomOpenerProps): ReactElement
return;
}
CachedChatSubscription.upsertSubscription(subscriptionData.subscription as unknown as ISubscription);
CachedChatSubscription.upsertSubscription(mapSubscriptionFromApi(subscriptionData.subscription));
LegacyRoomManager.computation.invalidate();
}, [subscriptionData]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment