-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
2,029 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
-- Migration number: 0010 2025-01-12T07:37:01.623Z | ||
ALTER TABLE users ADD COLUMN oldest_blog_post_date TEXT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* generated using openapi-typescript-codegen -- do no edit */ | ||
/* istanbul ignore file */ | ||
/* tslint:disable */ | ||
/* eslint-disable */ | ||
import type { CancelablePromise } from '../core/CancelablePromise'; | ||
import { OpenAPI } from '../core/OpenAPI'; | ||
import { request as __request } from '../core/request'; | ||
|
||
export class BlogService { | ||
|
||
/** | ||
* Views a blog post | ||
* @param requestBody | ||
* @returns any Empty object indicates success on viewing blog post | ||
* @throws ApiError | ||
*/ | ||
public static postViewBlogPost( | ||
requestBody?: { | ||
blogDate: string; | ||
}, | ||
): CancelablePromise<any> { | ||
return __request(OpenAPI, { | ||
method: 'POST', | ||
url: '/api/users/@me/view-blog', | ||
body: requestBody, | ||
mediaType: 'application/json', | ||
}); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { BellIcon } from "@heroicons/react/24/outline"; | ||
import moment from "moment"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { posts } from "../routes/Blog/posts"; | ||
import useAuth from "../useAuth"; | ||
import { Tooltip, TooltipContent, TooltipTrigger } from "./Tooltip"; | ||
|
||
export function BlogAlert() { | ||
const { user } = useAuth(); | ||
const navigate = useNavigate(); | ||
|
||
// Get the most recent blog post date | ||
const latestPost = posts | ||
.filter((post) => post.showInList) | ||
.sort((a, b) => moment(b.date).diff(moment(a.date)))[0]; | ||
|
||
const hasNewPost = Boolean( | ||
user && | ||
(!user.oldest_blog_post_date || | ||
moment(latestPost?.date).isAfter(moment(user.oldest_blog_post_date))), | ||
); | ||
|
||
const button = ( | ||
<button | ||
type="button" | ||
onClick={() => navigate(`/blog/${latestPost?.id}`)} | ||
className="relative rounded-full bg-gray-800 p-1 text-gray-400 hover:text-white focus:outline-none" | ||
> | ||
<span className="-inset-1.5 absolute" /> | ||
<span className="sr-only">View blog updates</span> | ||
<BellIcon className="h-6 w-6" aria-hidden="true" /> | ||
{hasNewPost && ( | ||
<span className="absolute top-0 right-0 block h-2 w-2 rounded-full bg-red-600 ring-1 ring-gray-400" /> | ||
)} | ||
</button> | ||
); | ||
|
||
if (!user) { | ||
return ( | ||
<Tooltip> | ||
<TooltipTrigger asChild>{button}</TooltipTrigger> | ||
<TooltipContent | ||
className="mt-2 rounded-lg border border-gray-600 bg-gray-950 p-2 text-cyan-500 text-sm shadow-lg" | ||
arrowClassName={ | ||
"fill-gray-950 [&>path:first-of-type]:stroke-gray-600" | ||
} | ||
> | ||
Log in to get notified when new blog posts are published | ||
</TooltipContent> | ||
</Tooltip> | ||
); | ||
} | ||
|
||
return button; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.