jamespot-front-business 1.1.67 → 1.1.68

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.
package/dist/esm.js CHANGED
@@ -476,6 +476,36 @@ const CommentListSlice = createSlice({
476
476
  discardComments: (state, action) => {
477
477
  state.comments = state.comments.filter((c) => c.idArticle !== action.payload.idArticle);
478
478
  },
479
+ hydrateComment: (state, action) => {
480
+ const { idArticle, list } = action.payload;
481
+ const hasList = state.comments.find((c) => c.idArticle === idArticle);
482
+ if (!hasList) {
483
+ state.comments = [
484
+ ...state.comments.filter((c) => c.idArticle !== idArticle),
485
+ {
486
+ idArticle,
487
+ list,
488
+ },
489
+ ];
490
+ return;
491
+ }
492
+ const initialUris = [];
493
+ const allUris = state.comments.reduce((uris, c) => {
494
+ return [...uris, ...c.list.map((el) => el.uri)];
495
+ }, initialUris);
496
+ const safeList = list.filter((el) => !allUris.includes(el.uri));
497
+ state.comments = state.comments.map((c) => {
498
+ return c.idArticle === idArticle
499
+ ? Object.assign(Object.assign({}, c), { list: [...c.list, ...safeList] }) : c;
500
+ });
501
+ },
502
+ updateComment: (state, action) => {
503
+ state.comments = state.comments.map((c) => {
504
+ const { idArticle, idComment, data } = action.payload;
505
+ return c.idArticle === idArticle
506
+ ? Object.assign(Object.assign({}, c), { list: c.list.map((comment) => comment.id === idComment ? Object.assign(Object.assign({}, comment), { description: data.description }) : comment) }) : c;
507
+ });
508
+ },
479
509
  },
480
510
  extraReducers: (builder) => {
481
511
  builder