-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added astronomical clock #144
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,11 @@ import React from "react"; | |
import { TextWrap } from "./Text"; | ||
import ContestClock from "../../molecules/Clock"; | ||
|
||
export const Clock = ({ part }) => { | ||
export const Clock = ({ tickerSettings, part }) => { | ||
return <TextWrap part={part}> | ||
<ContestClock/> | ||
<ContestClock | ||
timeZone={tickerSettings.timeZone === "" ? null : tickerSettings.timeZone} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not just make the default null or undefined instead of an empty string? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But if we have such a situation: we set "timeZone" to utc. Then we set "timeZone" to an empty string. In tickerSettings "timeZone" is now equals to an empty string. So it's not null => we have InvalidDateAndTime. But we expected contest time. We can change this part of code: const dateTime = DateTime.now().setZone(event.target.value);
if (dateTime.isValid || event.target.value === "") {
setErrorMessage("");
onChangeFieldEventHandler(setEditData, "timeZone")(event);
} else {
setErrorMessage(dateTime.invalidReason);
} But I don't think this is a good idea, becase we need to create a new function instead of using onChangeFieldEventHandler. (This necessary for this because if event.target.value is an empty string we can change value to null). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm talking mostly about backend behaviour here. As far as i can see this line of code just changes an empty string from the backend to a null There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay I can do something like this: override fun toMessage(): ClockTickerMessage {
if (timeZone != null && timeZone.isEmpty()) {
return ClockTickerMessage(ClockTickerSettings(part, periodMs, null))
}
return ClockTickerMessage(this)
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
/> | ||
</TextWrap>; | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now there is a strange type in the typescript.
But I guess we will fix it once we (cc @kunyavskiy) figure out a way to canonize them to all be either null or undefined.