<commit_before>import { registerComponent, Components, useSingle } from 'meteor/vulcan:core';
import React from 'react';
import withUser from '../common/withUser';
import Users from 'meteor/vulcan:users';
import withErrorBoundary from '../common/withErrorBoundary';

const BookmarksList = ({currentUser, limit=50 }) => {
  const { PostsItem2, Loading } = Components

  const { document: user, loading } = useSingle({
    collection: Users,
    queryName: "postLinkPreview",
    fragmentName: 'UserBookmarks',
    fetchPolicy: 'cache-then-network',
    documentId: currentUser._id,
  });

  let bookmarkedPosts = user?.bookmarkedPosts || []
  bookmarkedPosts = bookmarkedPosts.slice(0, limit)

  if (loading) return <Loading/>

  return (
    <div>
      {bookmarkedPosts.map((post) => <PostsItem2 key={post._id} post={post} bookmark/>)}
    </div>
  )
}

registerComponent('BookmarksList', BookmarksList, withUser, withErrorBoundary);<commit_msg>Change so most recently added bookmarks display first.<commit_after>import { registerComponent, Components, useSingle } from 'meteor/vulcan:core';
import React from 'react';
import withUser from '../common/withUser';
import Users from 'meteor/vulcan:users';
import withErrorBoundary from '../common/withErrorBoundary';

const BookmarksList = ({currentUser, limit=50 }) => {
  const { PostsItem2, Loading } = Components

  const { document: user, loading } = useSingle({
    collection: Users,
    queryName: "postLinkPreview",
    fragmentName: 'UserBookmarks',
    fetchPolicy: 'cache-then-network',
    documentId: currentUser._id,
  });

  let bookmarkedPosts = user?.bookmarkedPosts || []
  bookmarkedPosts = bookmarkedPosts.reverse().slice(0, limit)

  if (loading) return <Loading/>

  return (
    <div>
      {bookmarkedPosts.map((post) => <PostsItem2 key={post._id} post={post} bookmark/>)}
    </div>
  )
}

registerComponent('BookmarksList', BookmarksList, withUser, withErrorBoundary);
{'fraction_non_alphanumeric': 0.13484302624806999, 'fraction_numerical': 0.0051466803911477095, 'mean_word_length': 4.785714285714286, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, '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': '368194', 'n_tokens_mistral': 615, 'n_tokens_neox': 574, 'n_words': 140}