Skip to content

Commit

Permalink
refactor: show snowfall in December and January
Browse files Browse the repository at this point in the history
  • Loading branch information
brandstetterm committed Jan 8, 2025
1 parent 51073ef commit 638a2b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion src/components/SettingsDialog/Appearance/Appearance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export const Appearance = () => {
const activeMenuItem: MenuItemConfig = useOutletContext();
const currentMonth = new Date().getMonth();

// Snowfall is enabled only in December and January
const isDecemberOrJanuary = currentMonth === 11 || currentMonth === 0;

return (
<div className={classNames("settings-dialog__container", getColorClassName(activeMenuItem?.color))}>
<header className="settings-dialog__header">
Expand All @@ -25,7 +28,7 @@ export const Appearance = () => {
<div className="appearance-container">
<ThemeSettings />
{/** Since snowfall is only enabled in December, we only show the snowfall settings in December too */}
{currentMonth === 11 && <SnowfallSettings />}
{isDecemberOrJanuary && <SnowfallSettings />}
<NotificationSettings />
<BoardReactionsSettings />
<SkinToneSelector />
Expand Down
16 changes: 10 additions & 6 deletions src/components/SnowfallWrapper/SnowfallWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,20 @@ export const SnowfallWrapper = () => {
const currentMonth = new Date().getMonth();

useEffect(() => {
// Festive greetings are displayed only once, when the month changes to December
if (currentMonth === 11 && snowfallNotificationEnabled) {
Toast.info({title: t("Snowfall.toastTitle"), message: t("Snowfall.toastMessage")});
}
dispatch(setSnowfallNotification(false));
}, [currentMonth, dispatch, snowfallNotificationEnabled, t]);

return (
<>
{/** Snowfall is only enabled in December */}
{snowfallEnabled && currentMonth === 11 && <Snowfall color="#99bcff" />}
</>
);
// Snowfall is enabled only in December and January
const isDecemberOrJanuary = currentMonth === 11 || currentMonth === 0;

// If snowfall is disabled or it's not December or January, return null
if (!snowfallEnabled || !isDecemberOrJanuary) {
return null;
}

return <Snowfall color="#99bcff" />;
};

0 comments on commit 638a2b2

Please sign in to comment.