π¨ The ultimate agentic social media scheduling tool π€
TypeScript nextjsopen-sourceopen-source-social-media-scheduling-toolosspostiz-cloudpostiz-hostedredisscheduling-toolsocial-media-scheduling-tooltypescript
feat: better looking notifications
Nevo David31eda4942bb7
diff --git a/apps/frontend/src/components/new-layout/layout.component.tsx b/apps/frontend/src/components/new-layout/layout.component.tsxindex 2a9b3e8af..49785a705 100644--- a/apps/frontend/src/components/new-layout/layout.component.tsx+++ b/apps/frontend/src/components/new-layout/layout.component.tsx@@ -141,6 +141,7 @@ export const LayoutComponent = ({ children }: { children: ReactNode }) => {</div></div><div className="flex-1 min-w-0 bg-newBgLineColor rounded-[12px] overflow-hidden flex flex-col gap-[1px] blurMe">+ {/* relative: the notifications popup spans this bar on phones */}<div className="relative flex bg-newBgColorInner h-[80px] mobile:h-[64px] px-[20px] mobile:px-[12px] gap-[12px] items-center"><buttonclassName="hidden mobile:flex items-center justify-center w-[36px] h-[36px] -ms-[6px] rounded-[8px] text-textItemBlur hover:text-newTextColor hover:bg-boxFocused"diff --git a/apps/frontend/src/components/notifications/notification.component.tsx b/apps/frontend/src/components/notifications/notification.component.tsxindex 1e7930c22..290308b96 100644--- a/apps/frontend/src/components/notifications/notification.component.tsx+++ b/apps/frontend/src/components/notifications/notification.component.tsx@@ -21,9 +21,9 @@ function replaceLinks(text: string) {key={index}href={part}target="_blank"- rel="noreferrer"+ rel="noopener noreferrer"title={part}- className="inline-block max-w-full truncate align-bottom font-[500] underline decoration-newTextColor/30 underline-offset-[3px] hover:decoration-newTextColor"+ className="lbox inline-block max-w-full truncate align-bottom font-[500] underline decoration-newTextColor/30 underline-offset-[3px] hover:decoration-newTextColor">{part.replace(/^https?:\/\/(www\.)?/i, '')}</a>@@ -60,17 +60,24 @@ export const ShowNotification: FC<{</div>);};-export const NotificationOpenComponent = () => {+// every call marks the notifications as read, so it only runs when the popup opens+const useNotificationsList = () => {const fetch = useFetch();- const loadNotifications = useCallback(async () => {- return await (await fetch('/notifications/list')).json();- }, []);- const t = useT();-- const { data, isLoading, isValidating } = useSWR(+ return useSWR('notifications',- loadNotifications+ async () => {+ return await (await fetch('/notifications/list')).json();+ },+ {+ revalidateOnFocus: false,+ revalidateOnReconnect: false,+ dedupingInterval: 0,+ });+};+export const NotificationOpenComponent = () => {+ const t = useT();+ const { data, isLoading, isValidating } = useNotificationsList();const notifications: { createdAt: string; content: string }[] =data?.notifications || [];// reopening shows the cached list first, only the fresh one knows what is new@@ -81,7 +88,11 @@ export const NotificationOpenComponent = () => {return (<divid="notification-popup"- className="opacity-0 animate-normalFadeDown mt-[10px] mobile:mt-0 absolute w-[400px] mobile:w-auto top-[100%] end-0 mobile:start-[8px] mobile:!end-[8px] bg-newBgColorInner text-newTextColor rounded-[12px] flex flex-col border border-newTableBorder shadow-menu overflow-hidden z-[600]"+ className={clsx(+ 'opacity-0 animate-normalFadeDown mt-[10px] absolute w-[400px] top-[100%] end-0 bg-newBgColorInner text-newTextColor rounded-[12px] flex flex-col border border-newTableBorder shadow-menu overflow-hidden z-[600]',+ // on phones it spans the top bar, the ! beats the end-0 of tailwindcss-rtl+ 'mobile:mt-0 mobile:w-auto mobile:start-[8px] mobile:!end-[8px]'+ )}><div className="flex items-center gap-[8px] h-[56px] px-[16px] border-b border-newTableBorder"><div className="flex-1 text-[16px] font-[600]">@@ -165,7 +176,10 @@ const NotificationComponent = () => {height="24"viewBox="0 0 24 24"fill="none"- className={clsx('hover:text-newTextColor', show && 'text-newTextColor')}+ className={clsx(+ 'hover:text-newTextColor',+ show && 'text-newTextColor'+ )}><pathd="M14 21H10M18 8C18 6.4087 17.3679 4.88258 16.2427 3.75736C15.1174 2.63214 13.5913 2 12 2C10.4087 2 8.8826 2.63214 7.75738 3.75736C6.63216 4.88258 6.00002 6.4087 6.00002 8C6.00002 11.0902 5.22049 13.206 4.34968 14.6054C3.61515 15.7859 3.24788 16.3761 3.26134 16.5408C3.27626 16.7231 3.31488 16.7926 3.46179 16.9016C3.59448 17 4.19261 17 5.38887 17H18.6112C19.8074 17 20.4056 17 20.5382 16.9016C20.6852 16.7926 20.7238 16.7231 20.7387 16.5408C20.7522 16.3761 20.3849 15.7859 19.6504 14.6054C18.7795 13.206 18 11.0902 18 8Z"