@selfcommunity/react-ui 0.10.2-courses.182 → 0.10.2-courses.184
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -164,6 +164,8 @@ function LessonCommentObjects(inProps) {
|
|
|
164
164
|
updated = [...commentsObject.comments, comment];
|
|
165
165
|
}
|
|
166
166
|
commentsObject.updateLessonComments([...updated]);
|
|
167
|
+
utils_1.LRUCache.set(react_core_1.SCCache.getLessonCommentCacheKey(lessonObject.id), updated);
|
|
168
|
+
utils_1.LRUCache.deleteKeysWithPrefix(react_core_1.SCCache.getLessonCommentsCachePrefixKeys(lessonObject.id));
|
|
167
169
|
};
|
|
168
170
|
/**
|
|
169
171
|
* Renders root object(if obj)
|
|
@@ -174,6 +176,6 @@ function LessonCommentObjects(inProps) {
|
|
|
174
176
|
if (!commentsObject.comments.length && commentsObject.isLoadingNext) {
|
|
175
177
|
return (0, jsx_runtime_1.jsx)(Skeleton_1.default, Object.assign({ count: 5 }, CommentsObjectSkeletonProps));
|
|
176
178
|
}
|
|
177
|
-
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: commentsObject.comments.length > 0 ? ((0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ height: '100%', dataLength: commentsObject.comments.length, next: handleNext, hasMoreNext: Boolean(commentsObject.next), loaderNext: (0, jsx_runtime_1.jsx)(LessonCommentObject_1.LessonCommentObjectSkeleton, Object.assign({}, CommentObjectSkeletonProps, { count: 1 })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ ref: commentsEndRef }, { children: commentsObject.comments.map((c, index) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(LessonCommentObject_1.default, Object.assign({ commentObject: c, lessonObject: commentsObject.lessonObject, onDelete: (comment) => handleCommentsUpdate(comment, true), isEditing: (editing) => setIsEditing(editing) }, CommentComponentProps, { CommentObjectSkeletonProps: CommentObjectSkeletonProps }), c.id) }, index))) })) }))) : null }),
|
|
179
|
+
return ((0, jsx_runtime_1.jsx)(Root, Object.assign({ id: id, className: (0, classnames_1.default)(classes.root, className) }, rest, { children: (0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: commentsObject.comments.length > 0 ? ((0, jsx_runtime_1.jsx)(InfiniteScroll_1.default, Object.assign({ height: '100%', dataLength: commentsObject.comments.length, next: handleNext, hasMoreNext: Boolean(commentsObject.next), loaderNext: (0, jsx_runtime_1.jsx)(LessonCommentObject_1.LessonCommentObjectSkeleton, Object.assign({}, CommentObjectSkeletonProps, { count: 1 })) }, { children: (0, jsx_runtime_1.jsx)(material_1.List, Object.assign({ ref: commentsEndRef }, { children: commentsObject.comments.map((c, index) => ((0, jsx_runtime_1.jsx)(material_1.ListItem, { children: (0, jsx_runtime_1.jsx)(LessonCommentObject_1.default, Object.assign({ commentObject: c, lessonObject: commentsObject.lessonObject, onDelete: (comment) => handleCommentsUpdate(comment, true), isEditing: (editing) => setIsEditing(editing) }, CommentComponentProps, { CommentObjectSkeletonProps: CommentObjectSkeletonProps }), c.id) }, index))) })) }))) : null }), !editing && ((0, jsx_runtime_1.jsx)(CommentObjectReply_1.default, { id: `reply-lessonCommentObjects`, showAvatar: false, replyIcon: true, editable: !commenting, onReply: handleCommentAction, EditorProps: { placeholder: intl.formatMessage(messages.commentEditorPlaceholder), uploadFile: true, uploadImage: false } }, replyKey))] }) })));
|
|
178
180
|
}
|
|
179
181
|
exports.default = LessonCommentObjects;
|
|
@@ -8,8 +8,8 @@ import { Box, List, ListItem } from '@mui/material';
|
|
|
8
8
|
import classNames from 'classnames';
|
|
9
9
|
import { useThemeProps } from '@mui/system';
|
|
10
10
|
import { SCCommentsOrderBy } from '@selfcommunity/types';
|
|
11
|
-
import { CacheStrategies, Logger } from '@selfcommunity/utils';
|
|
12
|
-
import { UserUtils, useSCFetchLessonCommentObjects, useSCUser } from '@selfcommunity/react-core';
|
|
11
|
+
import { CacheStrategies, Logger, LRUCache } from '@selfcommunity/utils';
|
|
12
|
+
import { SCCache, UserUtils, useSCFetchLessonCommentObjects, useSCUser } from '@selfcommunity/react-core';
|
|
13
13
|
import { PREFIX } from './constants';
|
|
14
14
|
import LessonCommentsObjectSkeleton from './Skeleton';
|
|
15
15
|
import CommentObjectReply from '../CommentObjectReply';
|
|
@@ -162,6 +162,8 @@ export default function LessonCommentObjects(inProps) {
|
|
|
162
162
|
updated = [...commentsObject.comments, comment];
|
|
163
163
|
}
|
|
164
164
|
commentsObject.updateLessonComments([...updated]);
|
|
165
|
+
LRUCache.set(SCCache.getLessonCommentCacheKey(lessonObject.id), updated);
|
|
166
|
+
LRUCache.deleteKeysWithPrefix(SCCache.getLessonCommentsCachePrefixKeys(lessonObject.id));
|
|
165
167
|
};
|
|
166
168
|
/**
|
|
167
169
|
* Renders root object(if obj)
|
|
@@ -172,5 +174,5 @@ export default function LessonCommentObjects(inProps) {
|
|
|
172
174
|
if (!commentsObject.comments.length && commentsObject.isLoadingNext) {
|
|
173
175
|
return _jsx(LessonCommentsObjectSkeleton, Object.assign({ count: 5 }, CommentsObjectSkeletonProps));
|
|
174
176
|
}
|
|
175
|
-
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, rest, { children: _jsxs(_Fragment, { children: [_jsx(_Fragment, { children: commentsObject.comments.length > 0 ? (_jsx(InfiniteScroll, Object.assign({ height: '100%', dataLength: commentsObject.comments.length, next: handleNext, hasMoreNext: Boolean(commentsObject.next), loaderNext: _jsx(LessonCommentObjectSkeleton, Object.assign({}, CommentObjectSkeletonProps, { count: 1 })) }, { children: _jsx(List, Object.assign({ ref: commentsEndRef }, { children: commentsObject.comments.map((c, index) => (_jsx(ListItem, { children: _jsx(LessonCommentObject, Object.assign({ commentObject: c, lessonObject: commentsObject.lessonObject, onDelete: (comment) => handleCommentsUpdate(comment, true), isEditing: (editing) => setIsEditing(editing) }, CommentComponentProps, { CommentObjectSkeletonProps: CommentObjectSkeletonProps }), c.id) }, index))) })) }))) : null }),
|
|
177
|
+
return (_jsx(Root, Object.assign({ id: id, className: classNames(classes.root, className) }, rest, { children: _jsxs(_Fragment, { children: [_jsx(_Fragment, { children: commentsObject.comments.length > 0 ? (_jsx(InfiniteScroll, Object.assign({ height: '100%', dataLength: commentsObject.comments.length, next: handleNext, hasMoreNext: Boolean(commentsObject.next), loaderNext: _jsx(LessonCommentObjectSkeleton, Object.assign({}, CommentObjectSkeletonProps, { count: 1 })) }, { children: _jsx(List, Object.assign({ ref: commentsEndRef }, { children: commentsObject.comments.map((c, index) => (_jsx(ListItem, { children: _jsx(LessonCommentObject, Object.assign({ commentObject: c, lessonObject: commentsObject.lessonObject, onDelete: (comment) => handleCommentsUpdate(comment, true), isEditing: (editing) => setIsEditing(editing) }, CommentComponentProps, { CommentObjectSkeletonProps: CommentObjectSkeletonProps }), c.id) }, index))) })) }))) : null }), !editing && (_jsx(CommentObjectReply, { id: `reply-lessonCommentObjects`, showAvatar: false, replyIcon: true, editable: !commenting, onReply: handleCommentAction, EditorProps: { placeholder: intl.formatMessage(messages.commentEditorPlaceholder), uploadFile: true, uploadImage: false } }, replyKey))] }) })));
|
|
176
178
|
}
|