* Make readingList testable * Make history and readingList more similar * Extract ItemListTags component * Simplify load next page logic * History and reading list load more should be the same * Extract ItemListLoadMoreButton component * Use the same exact CSS for both * Use empty instead of 0 * Extract ItemListItem component * Remove unnecessary else * Same search function * Use a common module to group related functionality * Extract loadNextPage and fix load more button presence logic * Extract toggleTag * Refactor toggleStatusView and pass page * Added additional tests
25 lines
599 B
JavaScript
25 lines
599 B
JavaScript
import { h, render } from 'preact';
|
|
import { getUserDataAndCsrfToken } from '../chat/util';
|
|
import { ReadingList } from '../readingList/readingList';
|
|
|
|
function loadElement() {
|
|
getUserDataAndCsrfToken().then(({ currentUser }) => {
|
|
const root = document.getElementById('reading-list');
|
|
if (root) {
|
|
render(
|
|
<ReadingList
|
|
availableTags={currentUser.followed_tag_names}
|
|
statusView={root.dataset.view}
|
|
/>,
|
|
root,
|
|
root.firstElementChild,
|
|
);
|
|
}
|
|
});
|
|
}
|
|
|
|
window.InstantClick.on('change', () => {
|
|
loadElement();
|
|
});
|
|
|
|
loadElement();
|