hunk.code_window: import { addMockDatasourceToOrg } from "actions/datasourceActions";
   import { getCurrentOrgId } from "selectors/organizationSelectors";
   import { getQueryParams } from "../../../utils/AppsmithUtils";
   import { AppState } from "../../../reducers";
   const MockDataSourceWrapper = styled.div`
     overflow: auto;
     display: grid;
     grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  
hunk.labels: keep keep keep add keep keep keep keep keep
hunk.after_edit: import AnalyticsUtil from "../../../utils/AnalyticsUtil";
  
hunk.file_path: app/client/src/pages/Editor/IntegrationEditor/MockDataSources.tsx
hunk.type: add
file: import { ReduxAction } from "constants/ReduxActionConstants";
  import { get } from "lodash";
  import { CommentsReduxState } from "./interfaces";
  
  const handleNewCommentThreadEvent = (
    state: CommentsReduxState,
    action: ReduxAction<any>,
  ) => {
    const { thread } = action.payload;
    const applicationCommentIdsByRefId = get(
      state.applicationCommentThreadsByRef,
      thread.applicationId,
      {},
    ) as Record<string, Array<string>>;
    const threadsForRefId = get(applicationCommentIdsByRefId, thread.refId, []);
    const existingComments = get(
      state.commentThreadsMap,
      `${thread._id}.comments`,
      [],
    ) as [];
  
    // TODO override fields explicitly?
    state.commentThreadsMap[thread._id] = {
      ...thread,
      ...(state.commentThreadsMap[thread._id] || {}),
      id: thread._id,
      comments: [...existingComments, ...(thread.comments || [])],
    };
  
    if (!state.applicationCommentThreadsByRef[thread.applicationId]) {
      state.applicationCommentThreadsByRef[thread.applicationId] = {};
    }
    state.applicationCommentThreadsByRef[thread.applicationId] = {
      ...state.applicationCommentThreadsByRef[thread.applicationId],
      [thread.refId]: Array.from(new Set([thread._id, ...threadsForRefId])),
    };
  
    const showUnreadIndicator = !state.isCommentMode;
  
    /**
     * Private threads are a part of the comments onboarding
     * These are termed bot threads, triggered from the backend based on the onboarding flow
     * We set these as visible and hide the currently visible thread, following the create event
     */
  
    if (thread.isPrivate) {
      state.visibleCommentThreadId = thread._id;
    }
  
    return {
      ...state,
      showUnreadIndicator,
    };
  };
  
  export default handleNewCommentThreadEvent;
  