Skip to content

Commit

Permalink
close #86
Browse files Browse the repository at this point in the history
  • Loading branch information
wwsalmon committed Aug 18, 2023
1 parent 24bc18a commit 45c668b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion pages/[username]/[updateUrl].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {FiHeart} from "react-icons/fi";
import {notificationModel} from "../../models/models";
import {getMentionsAndBodySegments} from "../../components/UpdateCommentItem";
import { DeleteModal } from "../../components/Modal";
import { ssrRedirect } from "next-response-helpers";

export default function UpdatePage(props: { data: GetUpdateRequestResponse, updateUrl: string, userData: User }) {
const router = useRouter();
Expand Down Expand Up @@ -288,7 +289,7 @@ export const getServerSideProps: GetServerSideProps = async (context) => {
// or are the user
data.user._id.toString() === userData._id.toString()
)
)) return { notFound: true };
)) return ssrRedirect(`/@${data.user.urlName}?privateredirect=true`);

if (userData) await notificationModel.updateMany({userId: userData._id, updateId: data.update._id}, {read: true});

Expand Down
7 changes: 7 additions & 0 deletions pages/[username]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,19 @@ export default function UserProfile(props: { user: UserAgg, userData: User, foll

const isProfilePrivateToLoggedInUser = (pageUser.private || pageUser.truePrivate) && (!userData || !pageUser.followers.includes(props.userData.email) && !isOwner);

const isPrivateUpdateRedirect = !!router.query.privateredirect;

return (
<div className="max-w-4xl mx-auto px-4">
<NextSeo
title={`${pageUser.name}'s daily updates | Updately`}
description={`Follow ${pageUser.name} on Updately to get their updates in your feed.`}
/>
{isPrivateUpdateRedirect && (
<div className="my-16 bg-black p-4 text-white rounded">
<p>You accessed a link to an update on a private account that you do not follow. Follow the account to view the update.</p>
</div>
)}
<div className="sm:flex mt-16 mb-8">
<UserHeaderLeft pageUser={pageUser} userData={userData}/>
<div className="flex sm:ml-auto mt-6 sm:mt-0">
Expand Down
2 changes: 0 additions & 2 deletions utils/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ export async function getUpdateRequest(username: string, url: string): Promise<G
getLookup("users", "_id", "mentionedUsers", "mentionedUsersArr"),
]);

console.log(user._id, url);

if (!updates.length) return null;


Expand Down

0 comments on commit 45c668b

Please sign in to comment.