Skip to content

Commit

Permalink
Merge pull request #1077 from jhuopensource/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
JiaqiWang18 authored Feb 13, 2024
2 parents 8b4de8c + ae7c26e commit 73f83e9
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 16 deletions.
2 changes: 1 addition & 1 deletion manifests/prod/cronjob.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ spec:
containers:
- image: semesterly.azurecr.io/semesterly:Version
name: gunicorn-cron
command: ["/bin/bash","/code/run_parser.sh"]
command: ["/bin/bash", "/code/run_parser.sh"]
workingDir: /code
envFrom:
- secretRef:
Expand Down
24 changes: 18 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions static/js/redux/state/slices/newsModalSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const newsModalSlice = createSlice({
state.isVisible = false;
},
showNewsModal: (state) => {
localStorage.setItem("lastViewedNewsDate", new Date(Date.now()).toISOString()); // !
state.isVisible = true;
},
},
Expand Down
48 changes: 45 additions & 3 deletions static/js/redux/ui/Semesterly.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,55 @@ const Semesterly = () => {
// DataLastUpdated Input example- 2021-05-02 14:42 UTC
// Params: How the backend sends a timestamp
// dateString: of the form yyyy-mm-dd hh:mm
const dateString = dataLastUpdated.toString().slice(0, -4); // exclude UTC
const dateString = dataLastUpdated.toString();

if (!dateString || dateString.length === 0) return "";

// Convert given datetime to local datetime of user
// in form yyyy-mm-dd hh:mm TZ (Timezone full name)
return new Date(dateString).toString();
// in form (month) dd, yyyy

const curDate: Date = new Date(dateString);

const months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
];

let dayEnding: String;
const curDay = curDate.getDay();
if (curDay >= 11 && curDay <= 13) {
dayEnding = "th";
}

switch (curDay % 10) {
case 1:
dayEnding = "st";
break;
case 2:
dayEnding = "nd";
break;
case 3:
dayEnding = "rd";
break;
default:
dayEnding = "th";
}

const monthIndex: number = curDate.getMonth();

return `${
months[monthIndex]
} ${curDate.getUTCDate()}${dayEnding}, ${curDate.getFullYear()}`;
};

const mobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
Expand Down
3 changes: 3 additions & 0 deletions static/js/redux/ui/SideBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const SideBar = () => {

const hideDropdown = () => {
setShowDropdown(false);

// * Set hoveredCourse to -1 if user clicks out
setHoveredCourse(-1);
};

const toggleDropdown = () => {
Expand Down
10 changes: 4 additions & 6 deletions static/js/redux/ui/modals/NewsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,21 @@ const NewsModal = () => {

useEffect(() => {
const tutorialData = JSON.parse(localStorage.getItem("tutorial"));
if (!tutorialData || !tutorialData.modalTutShown || isSigningUp) {
return;
}
const displayCriteria = tutorialData && tutorialData.modalTutShown && !isSigningUp;

const fetchData = async () => {
const response = await fetch(getNewsEndpoint());
const data = await response.json();

// Only display modal if the news was posted after the last viewed time
if (data.date && new Date(data.date) > lastViewedTime) {
if (data.date && new Date(data.date) > lastViewedTime && displayCriteria) {
dispatch(newsModalActions.showNewsModal());
// Set to current date and time
localStorage.setItem("lastViewedNewsDate", new Date(Date.now()).toISOString());
}

setNewsTitle(data.title);
setNewsBody(data.body);
setNewsTitle(data.title === "" ? "No news at the moment!" : data.title);
setNewsBody(data.body === "" ? "Please check back again later." : data.body);
};

fetchData();
Expand Down

0 comments on commit 73f83e9

Please sign in to comment.