Merge branch 'main' into gm_to_channel

This commit is contained in:
harshil Sharma 2023-11-01 10:48:02 +05:30
commit 3555eb5d72
4 changed files with 46 additions and 33 deletions

View file

@ -25,7 +25,7 @@ type Props = {
currentUserId?: string;
currentUsername?: string;
location: string;
post: Post;
post: Post | null;
showJoinLeave: boolean;
testID?: string;
theme: Theme;
@ -65,23 +65,11 @@ const CombinedUserActivity = ({
const intl = useIntl();
const isTablet = useIsTablet();
const serverUrl = useServerUrl();
const itemTestID = `${testID}.${post.id}`;
const textStyles = getMarkdownTextStyles(theme);
const {allUserIds, allUsernames, messageData} = post.props.user_activity;
const styles = getStyleSheet(theme);
const content = [];
const removedUserIds: string[] = [];
const loadUserProfiles = () => {
if (allUserIds.length) {
fetchMissingProfilesByIds(serverUrl, allUserIds);
}
if (allUsernames.length) {
fetchMissingProfilesByUsernames(serverUrl, allUsernames);
}
};
const getUsernames = (userIds: string[]) => {
const someone = intl.formatMessage({id: 'channel_loader.someone', defaultMessage: 'Someone'});
const you = intl.formatMessage({id: 'combined_system_message.you', defaultMessage: 'You'});
@ -120,6 +108,9 @@ const CombinedUserActivity = ({
}, [post, canDelete, isTablet, intl, location]);
const renderMessage = (postType: string, userIds: string[], actorId: string) => {
if (!post) {
return null;
}
let actor = '';
if (usernamesById[actorId]) {
actor = `@${usernamesById[actorId]}`;
@ -177,9 +168,26 @@ const CombinedUserActivity = ({
};
useEffect(() => {
loadUserProfiles();
}, [allUserIds, allUsernames]);
if (!post) {
return;
}
const {allUserIds, allUsernames} = post.props.user_activity;
if (allUserIds.length) {
fetchMissingProfilesByIds(serverUrl, allUserIds);
}
if (allUsernames.length) {
fetchMissingProfilesByUsernames(serverUrl, allUsernames);
}
}, [post?.props.user_activity.allUserIds, post?.props.user_activity.allUsernames]);
if (!post) {
return null;
}
const itemTestID = `${testID}.${post.id}`;
const {messageData} = post.props.user_activity;
for (const message of messageData) {
const {postType, actorId} = message;
const userIds = new Set<string>(message.userIds);

View file

@ -28,24 +28,29 @@ const withCombinedPosts = withObservables(['postId'], ({database, postId}: WithD
// Columns observed: `props` is used by `usernamesById`. `message` is used by generateCombinedPost.
const posts = queryPostsById(database, postIds).observeWithColumns(['props', 'message']);
const post = posts.pipe(map((ps) => generateCombinedPost(postId, ps)));
const post = posts.pipe(map((ps) => (ps.length ? generateCombinedPost(postId, ps) : null)));
const canDelete = combineLatest([posts, currentUser]).pipe(
switchMap(([ps, u]) => (ps.length ? observePermissionForPost(database, ps[0], u, Permissions.DELETE_OTHERS_POSTS, false) : of$(false))),
);
const usernamesById = post.pipe(
switchMap(
(p) => queryUsersByIdsOrUsernames(database, p.props.user_activity.allUserIds, p.props.user_activity.allUsernames).observeWithColumns(['username']).
pipe(
// eslint-disable-next-line max-nested-callbacks
switchMap((users) => {
(p) => {
if (!p) {
return of$<Record<string, string>>({});
}
return queryUsersByIdsOrUsernames(database, p.props.user_activity.allUserIds, p.props.user_activity.allUsernames).observeWithColumns(['username']).
pipe(
// eslint-disable-next-line max-nested-callbacks
return of$(users.reduce((acc: Record<string, string>, user) => {
acc[user.id] = user.username;
return acc;
}, {}));
}),
),
switchMap((users) => {
// eslint-disable-next-line max-nested-callbacks
return of$(users.reduce((acc: Record<string, string>, user) => {
acc[user.id] = user.username;
return acc;
}, {}));
}),
);
},
),
);

12
package-lock.json generated
View file

@ -43,7 +43,7 @@
"@voximplant/react-native-foreground-service": "3.0.2",
"base-64": "1.0.0",
"commonmark": "npm:@mattermost/commonmark@0.30.1-1",
"commonmark-react-renderer": "github:mattermost/commonmark-react-renderer#235bc817bcade503fb81fa51bbbe3c84f958ed12",
"commonmark-react-renderer": "github:mattermost/commonmark-react-renderer#81b5d27509652bae50b4b510ede777dd3bd923cf",
"deep-equal": "2.2.2",
"deepmerge": "4.3.1",
"emoji-regex": "10.2.1",
@ -9707,8 +9707,8 @@
},
"node_modules/commonmark-react-renderer": {
"version": "4.3.5",
"resolved": "git+ssh://git@github.com/mattermost/commonmark-react-renderer.git#235bc817bcade503fb81fa51bbbe3c84f958ed12",
"integrity": "sha512-GP3+17loU8tNal91FAlqDcDyUHdhahMPpV/XBm++VAyoyvsGKx3wGQZY/cVKXNx+SV2UANXVf4VFx8GpAkqCBQ==",
"resolved": "git+ssh://git@github.com/mattermost/commonmark-react-renderer.git#81b5d27509652bae50b4b510ede777dd3bd923cf",
"integrity": "sha512-2UYjN/Fix93L6udBsmZqCUggE7e5NA8rXHO2R3Dxs3lwHac3MsOMdEYZPST3Z/CCFc6gyKqWqDtCQXofbHffPA==",
"license": "MIT",
"dependencies": {
"lodash.assign": "^4.2.0",
@ -30102,9 +30102,9 @@
}
},
"commonmark-react-renderer": {
"version": "git+ssh://git@github.com/mattermost/commonmark-react-renderer.git#235bc817bcade503fb81fa51bbbe3c84f958ed12",
"integrity": "sha512-GP3+17loU8tNal91FAlqDcDyUHdhahMPpV/XBm++VAyoyvsGKx3wGQZY/cVKXNx+SV2UANXVf4VFx8GpAkqCBQ==",
"from": "commonmark-react-renderer@github:mattermost/commonmark-react-renderer#235bc817bcade503fb81fa51bbbe3c84f958ed12",
"version": "git+ssh://git@github.com/mattermost/commonmark-react-renderer.git#81b5d27509652bae50b4b510ede777dd3bd923cf",
"integrity": "sha512-2UYjN/Fix93L6udBsmZqCUggE7e5NA8rXHO2R3Dxs3lwHac3MsOMdEYZPST3Z/CCFc6gyKqWqDtCQXofbHffPA==",
"from": "commonmark-react-renderer@github:mattermost/commonmark-react-renderer#81b5d27509652bae50b4b510ede777dd3bd923cf",
"requires": {
"lodash.assign": "^4.2.0",
"lodash.isplainobject": "^4.0.6",

View file

@ -44,7 +44,7 @@
"@voximplant/react-native-foreground-service": "3.0.2",
"base-64": "1.0.0",
"commonmark": "npm:@mattermost/commonmark@0.30.1-1",
"commonmark-react-renderer": "github:mattermost/commonmark-react-renderer#235bc817bcade503fb81fa51bbbe3c84f958ed12",
"commonmark-react-renderer": "github:mattermost/commonmark-react-renderer#81b5d27509652bae50b4b510ede777dd3bd923cf",
"deep-equal": "2.2.2",
"deepmerge": "4.3.1",
"emoji-regex": "10.2.1",