<commit_before>import React from 'react';
import { getActions, withMutation } from 'meteor/vulcan:core';
import compose from 'recompose/compose';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import withNewEvents from '../../lib/events/withNewEvents.jsx';

export const withRecordPostView = (Component) => {
  const mapStateToProps = state => ({ postsViewed: state.postsViewed });
  const mapDispatchToProps = dispatch => bindActionCreators(getActions().postsViewed, dispatch);

  async function recordPostView(props) {
    try {

      // destructure the relevant props
      const {
        // from the parent component, used in withDocument, GraphQL HOC
        documentId,
        // from connect, Redux HOC
        setViewed,
        postsViewed,
        // from withMutation, GraphQL HOC
        increasePostViewCount,
        
        document,
        currentUser,
        recordEvent,
      } = props;

      // a post id has been found & it's has not been seen yet on this client session
      if (documentId && !postsViewed.includes(documentId)) {

        // Trigger the asynchronous mutation with postId as an argument
        // Deliberately not awaiting, because this should be fire-and-forget
        increasePostViewCount({postId: documentId});

        // Update the redux store
        setViewed(documentId);
      }

      //LESSWRONG: register page-visit event
      if(currentUser) {
        const eventProperties = {
          userId: currentUser._id,
          important: false,
          intercom: true,
        };
<commit_msg>Add in an await, causing an order-of-execution change which hackily causes the current view to not count for comment-unread-cutoff-date widget initialization.<commit_after>import React from 'react';
import { getActions, withMutation } from 'meteor/vulcan:core';
import compose from 'recompose/compose';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import withNewEvents from '../../lib/events/withNewEvents.jsx';

export const withRecordPostView = (Component) => {
  const mapStateToProps = state => ({ postsViewed: state.postsViewed });
  const mapDispatchToProps = dispatch => bindActionCreators(getActions().postsViewed, dispatch);

  async function recordPostView(props) {
    try {

      // destructure the relevant props
      const {
        // from the parent component, used in withDocument, GraphQL HOC
        documentId,
        // from connect, Redux HOC
        setViewed,
        postsViewed,
        // from withMutation, GraphQL HOC
        increasePostViewCount,
        
        document,
        currentUser,
        recordEvent,
      } = props;

      // a post id has been found & it's has not been seen yet on this client session
      if (documentId && !postsViewed.includes(documentId)) {

        // Trigger the asynchronous mutation with postId as an argument
        // Deliberately not awaiting, because this should be fire-and-forget
        await increasePostViewCount({postId: documentId});

        // Update the redux store
        setViewed(documentId);
      }

      //LESSWRONG: register page-visit event
      if(currentUser) {
        const eventProperties = {
          userId: currentUser._id,
          important: false,
          intercom: true,
        };

{'fraction_non_alphanumeric': 0.0886151997596876, 'fraction_numerical': 0.0, 'mean_word_length': 2.651315789473684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1562057', 'n_tokens_mistral': 903, 'n_tokens_neox': 883, 'n_words': 279}