Skip to content

Commit

Permalink
reload courses on auth change
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarnadas committed Oct 14, 2020
1 parent 43322fa commit f76b56b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "smmdb"
version = "0.2.1"
version = "0.2.2"
authors = ["Mario Reder <[email protected]>"]
edition = "2018"

Expand Down
16 changes: 15 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ pub enum Message {
ApplyFilters,
PaginateForward,
PaginateBackward,
ReloadCourses,
UpvoteCourse(String),
DownvoteCourse(String),
ResetCourseVote(String),
Expand Down Expand Up @@ -415,6 +416,19 @@ impl Application for App {
},
)
}
Message::ReloadCourses => {
self.state = AppState::Loading;
Command::perform(
Box::pin(Smmdb::update(
self.smmdb.get_query_params().clone(),
self.settings.apikey.clone(),
)),
move |res| match res {
Ok(courses) => Message::SetSmmdbCourses(courses),
Err(err) => Message::FetchError(err.to_string()),
},
)
}
Message::UpvoteCourse(course_id) => {
if let Some(apikey) = self.settings.apikey.clone() {
Command::perform(
Expand Down Expand Up @@ -492,7 +506,7 @@ impl Application for App {
self.current_page = settings_page.get_prev_page()
}
self.error_state = AppErrorState::None;
Command::none()
async { Message::ReloadCourses }.into()
}
Message::RejectSettings(err) => {
self.error_state = AppErrorState::Some(err);
Expand Down

0 comments on commit f76b56b

Please sign in to comment.