-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Allow private notes on games in kid mode #16769
Allow private notes on games in kid mode #16769
Conversation
modules/chat/src/main/ChatUi.scala
Outdated
"name" -> name, | ||
"lines" -> lines, | ||
"resourceId" -> resourceId.value | ||
"data" -> false |
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.
this makes the TS types lie
data: ChatData;
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.
Done
I put the mandatory fields only with 'sensible' content
Example:
"chat":{"data":{"id":"","name":"","lines":[],"resourceId":"","loginRequired":true,"restricted":true},"kidMode":true,"noteId":"YHW3eKqs","noteAge":256381}
modules/chat/src/main/ChatUi.scala
Outdated
) | ||
if ctx.kid.yes then | ||
Json | ||
.obj("data" -> false) |
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.
this makes the TS types lie
data: ChatData;
modules/chat/src/main/ChatUi.scala
Outdated
Json | ||
.obj("data" -> false) | ||
.add("kidMode" -> true) | ||
.add("noteId" -> (withNoteAge.isDefined && ctx.noBlind).option(chat.id.value.take(8))) |
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.
code duplication with line 99
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.
Done
modules/chat/src/main/ChatUi.scala
Outdated
.add("timeout" -> (public && Granter.opt(_.ChatTimeout))) | ||
.add("shadowban" -> (public && Granter.opt(_.Shadowban))) | ||
) | ||
.add("kidMode" -> ctx.kid.yes) |
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.
this can be omitted since we know that ctx.kid.no
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.
Done
I am not sure how it works though
absent means false (on the typescript side) ?
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.
lila usually omits false or missing values altogether.
modules/chat/src/main/ChatUi.scala
Outdated
"data" -> Json | ||
.obj( | ||
"id" -> "", | ||
"name" -> "", |
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.
no, this is not good. If the ts typing says that there exists data.id: string
and data.name: string
, and you pass them empty strings, then you just made typing useless. Worse, the typing now gives a false sense of security.
I don't want our TS code to check if every string is empty before use.
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.
I may have misunderstood your point in the first place.
Hopefully this fix will be what you had in mind
Thanks for your patience and your feedback
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.
I can see some errors in the console when playing with the notes.
But it's also happening on master.
{"SyntaxError":"JSON.parse: unexpected end of data at line 1 column 1 of the JSON data","stack":""}
Another idea to fix #16715 (follow-up on #16761)
Chat json data is stripped for kids to only keep what is needed to write notes.
The UI part makes sure the chat tabs (room and palantir) are not displayed and no communication with redis is happening.