-
+
{paper && paper.title}
-
+
{paper.paper_title && paper.paper_title !== paper.title ? (
-
+
{`From Paper: ${paper.paper_title}`}
-
+
) : null}
@@ -933,6 +933,9 @@ const styles = StyleSheet.create({
fontSize: 30,
position: "relative",
wordBreak: "break-word",
+ fontWeight: "unset",
+ padding: 0,
+ margin: 0,
"@media only screen and (max-width: 760px)": {
fontSize: 28,
},
@@ -951,6 +954,7 @@ const styles = StyleSheet.create({
opacity: 0.5,
fontSize: 16,
marginTop: 10,
+ fontWeight: "unset",
"@media only screen and (max-width: 415px)": {
fontSize: 14,
},
diff --git a/components/TabBar.js b/components/TabBar.js
index 9907f4f703..d5c0b40054 100644
--- a/components/TabBar.js
+++ b/components/TabBar.js
@@ -2,13 +2,14 @@ import Link from "next/link";
import { StyleSheet, css } from "aphrodite";
import colors, { paperTabColors } from "~/config/themes/colors";
import { paperTabFont } from "~/config/themes/fonts";
+import Loader from "~/components/Loader/Loader";
// Components
import ComponentWrapper from "./ComponentWrapper";
const TabBar = (props) => {
const selectedTab = props.selectedTab;
- const { dynamic_href } = props;
+ const { dynamic_href, fetching } = props;
const tabs = props.tabs.map(formatTabs);
return (
@@ -22,7 +23,7 @@ const TabBar = (props) => {
return null;
}
}
- return renderTab(tab, selectedTab, dynamic_href);
+ return renderTab(tab, selectedTab, dynamic_href, props.fetching);
})}
@@ -38,7 +39,8 @@ function formatTabs(tab) {
function renderTab(
{ key, href, label, showCount, count },
selected,
- dynamic_href
+ dynamic_href,
+ fetching
) {
let isSelected = false;
let classNames = [styles.tab];
@@ -52,7 +54,9 @@ function renderTab(
{label}{" "}
- {showCount && }
+ {showCount && (
+
+ )}
@@ -60,14 +64,29 @@ function renderTab(
}
const Count = (props) => {
- const { amount, isSelected } = props;
+ const { amount, isSelected, fetching } = props;
// if (amount < 1) {
// return
;
// }
+
return (
-
- {amount > 0 ? amount : 0}
+
+ {fetching ? (
+
+ ) : amount > 0 ? (
+ amount
+ ) : (
+ 0
+ )}
);
@@ -134,6 +153,13 @@ const styles = StyleSheet.create({
borderBottom: "solid 3px",
borderColor: colors.PURPLE(1),
},
+ loaderContainer: {
+ padding: 0,
+ width: "unset",
+ },
+ loaderStyle: {
+ display: "unset",
+ },
});
export default TabBar;
diff --git a/config/api.js b/config/api.js
index 0c764a2ae0..1d64c87449 100644
--- a/config/api.js
+++ b/config/api.js
@@ -183,15 +183,8 @@ const routes = (BASE_URL) => {
return url;
},
- USER_CONTRIBUTION: ({
- authorId,
- commentOffset,
- replyOffset,
- paperUploadOffset,
- }) => {
- let url =
- BASE_URL +
- `author/${authorId}/get_user_contributions/?commentOffset=${commentOffset}&replyOffset=${replyOffset}&paperUploadOffset=${paperUploadOffset}`;
+ USER_CONTRIBUTION: ({ authorId }) => {
+ let url = BASE_URL + `author/${authorId}/get_user_contributions/`;
return url;
},
diff --git a/pages/user/[authorId]/[tabName]/index.js b/pages/user/[authorId]/[tabName]/index.js
index c58fb36064..6e590299f1 100644
--- a/pages/user/[authorId]/[tabName]/index.js
+++ b/pages/user/[authorId]/[tabName]/index.js
@@ -35,6 +35,7 @@ const AuthorPage = (props) => {
let { tabName } = router.query;
const dispatch = useDispatch();
const store = useStore();
+ const [fetching, setFetching] = useState(true);
const [openShareModal, setOpenShareModal] = useState(false);
const [hoverName, setHoverName] = useState(false);
const [hoverDescription, setHoverDescription] = useState(false);
@@ -106,19 +107,12 @@ const AuthorPage = (props) => {
if (!author.user) {
return;
}
- let {
- commentOffset,
- replyOffset,
- paperUploadOffset,
- } = props.author.userContributions;
await dispatch(
AuthorActions.getUserContributions({
authorId: router.query.authorId,
- commentOffset,
- replyOffset,
- paperUploadOffset,
})
);
+ setFetching(false);
}
function fetchUserTransactions() {
@@ -150,6 +144,7 @@ const AuthorPage = (props) => {
}
useEffect(() => {
+ setFetching(true);
async function refetchAuthor() {
await dispatch(
AuthorActions.getAuthor({ authorId: router.query.authorId })
@@ -246,20 +241,44 @@ const AuthorPage = (props) => {
];
let renderTabContent = () => {
- switch (tabName) {
- case "contributions":
- return
;
- case "authored-papers":
- return
;
- case "discussions":
- return
;
- case "citations":
- return null;
- case "transactions":
- return
;
- case "boosts":
- return
;
- }
+ return (
+ // render all tab content on the dom, but only show if selected
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ );
};
let renderEditButton = (action) => {
@@ -703,6 +722,7 @@ const AuthorPage = (props) => {
dynamic_href={"/user/[authorId]/[tabName]"}
author={author}
user={user}
+ fetching={fetching}
/>
{renderTabContent()}
({
diff --git a/redux/author/index.js b/redux/author/index.js
index d08e3650bf..e6417334ee 100644
--- a/redux/author/index.js
+++ b/redux/author/index.js
@@ -79,44 +79,47 @@ export const AuthorActions = {
};
},
- getUserContributions: ({
- authorId,
- commentOffset = 0,
- replyOffset = 0,
- paperUploadOffset = 0,
- }) => {
- return async (dispatch) => {
+ getUserContributions: ({ authorId, next = null }) => {
+ return async (dispatch, getState) => {
dispatch({
contributionsDoneFetching: false,
type: types.GET_USER_CONTRIBUTIONS_PENDING,
});
- const response = await fetch(
- API.USER_CONTRIBUTION({
- authorId,
- commentOffset,
- replyOffset,
- paperUploadOffset,
- }),
- API.GET_CONFIG()
- ).catch(utils.handleCatch);
+
+ let ENDPOINT = next
+ ? next
+ : API.USER_CONTRIBUTION({
+ authorId,
+ });
+
+ const response = await fetch(ENDPOINT, API.GET_CONFIG()).catch(
+ utils.handleCatch
+ );
let action = actions.getUserContributionsFailure();
if (response.ok) {
const body = await response.json();
- let contributions = [];
+
+ let contributions = next
+ ? [...getState().author.userContributions.contributions]
+ : [];
for (let i = 0; i < body.results.length; i++) {
let contribution = body.results[i];
if (contribution.type === "reply") {
let formatted = discussionShim.transformReply(body.results[i]);
- formatted.type = contribution.type;
+ // formatted.type = contribution.type;
contributions.push(formatted);
} else if (contribution.type === "comment") {
let formatted = discussionShim.transformComment(body.results[i]);
- formatted.type = contribution.type;
+ // formatted.type = contribution.type;
contributions.push(formatted);
} else if (contribution.type === "paper") {
let formatted = paperShim.paper(body.results[i]);
- formatted.type = contribution.type;
+ // formatted.type = contribution.type;
+ contributions.push(formatted);
+ } else {
+ let formatted = paperShim.paper(body.results[i]);
+ // formatted.type = contribution.type;
contributions.push(formatted);
}
}
@@ -135,6 +138,15 @@ export const AuthorActions = {
};
},
+ getNextUserContributions: ({ authorId }) => {
+ return async (dispatch) => {
+ dispatch({
+ contributionsDoneFetching: false,
+ type: types.GET_USER_CONTRIBUTIONS_PENDING,
+ });
+ };
+ },
+
saveAuthorChanges: ({ changes, authorId, file }) => {
return (dispatch) => {
let config = API.PATCH_CONFIG(changes);