- Notifications
You must be signed in to change notification settings - Fork328
Dan product notifications#1524
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
d1c7351
intomasterUh oh!
There was an error while loading.Please reload this page.
pub fn update_viewed(new: &Vec<String>, cookies: &CookieJar<'_>) { | ||
let mut cookie = Cookie::new("session", format!(r#"{{"notifications": {:?}}}"#, new)); | ||
pub fn update_viewed(new: &Vec<NotificationCookie>, cookies: &CookieJar<'_>) { | ||
let serialized = new.iter().map(|x| x.to_string()).collect::<Vec<String>>(); |
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.
You want to useserde_json::to_string
impl std::fmt::Display for NotificationCookie { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
let mut rsp = format!(r#"{{"id": "{}""#, self.id.clone()); |
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.
serde_json::to_string
self | ||
} | ||
pub fn json(body: String) -> Response { |
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.
We should move this topgml_components
crate.
Some(session) => { | ||
match serde_json::from_str::<serde_json::Value>(session.value()).unwrap()["notifications"].as_array() { | ||
Some(items) => items | ||
.into_iter() | ||
.map(|x| x.as_str().unwrap().to_string()) | ||
.collect::<Vec<String>>(), | ||
.map(|x| serde_json::from_str::<NotificationCookie>(&x.to_string()).unwrap()) |
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 is not backwards compatible. You need to catch the deserialization error here and either bubble up the error, convert the old format to the new one, or return a default value.
This reverts commitd1c7351.
Uh oh!
There was an error while loading.Please reload this page.