-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Static Templates #567
Conversation
else | ||
conn | ||
|> put_status(404) | ||
|> json(%{error: "not_found"}) | ||
end | ||
end | ||
|
||
def static_templates(conn, _) do |
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.
Apologies if this was already discussed, but do we need to serve these from the backend? I was imagining just compiling the template text into the frontend bundle and accessing it statically, since that's the only place we need it.
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 don't think server vs. client was ever discussed, but that's an interesting idea. It didn't click until now that the server has no reason to care about the contents of the file. That should simplify some things so I can give that a shot and see how we feel.
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.
See comments, then looks good.
priv/config/static_templates.json
Outdated
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.
Looks like there are two copies of this file.
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.
Thanks. Forgot to delete the test fixture as well.
} | ||
}; | ||
|
||
let content; |
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.
nit: Since we're just returning the content immediately, we could put return
statements inside each if
and avoid a let
here.
onCancel={() => setPage(Page.MAIN)} | ||
onSelect={(template) => { | ||
setSelectedTemplate(template); | ||
setVisualText(template.audio_text); |
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 should be:
setVisualText(template.audio_text); | |
setVisualText(template.visual_text); |
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.
Woops, thank you.
This PR adds a static templates feature. We will keep a list of static templates in
priv/config/static_templates.json
. When a message is created using a template:I have also added an
archived
field to each static template in order to prevent IDs from being reused by mistake. If a template is deleted and the ID is used again later, any message linked to the deleted template would then be incorrectly linked to the new one. This is unlikely to happen, but wanted to prevent it nonetheless.