Skip to content

Commit 1988546

Browse files
author
Gareth Redfern
committed
move getUsers function into beforeRouteUpdate
1 parent fc2d2c2 commit 1988546

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/views/Users.vue

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,25 +55,18 @@ import FlashMessage from "@/components/FlashMessage";
5555
import AvatarIcon from "@/components/icons/AvatarIcon";
5656
import BasePagination from "@/components/BasePagination";
5757
58-
function getUsers(to, next) {
59-
const currentPage = parseInt(to.query.page) || 1;
60-
store.dispatch("user/getUsers", currentPage).then(() => {
61-
to.params.page = currentPage;
62-
next();
63-
});
64-
}
65-
6658
export default {
6759
name: "UsersView",
6860
components: { FlashMessage, BasePagination, MailIcon, AvatarIcon },
6961
computed: {
7062
...mapGetters("user", ["loading", "error", "users", "meta", "links"]),
7163
},
7264
beforeRouteEnter(to, from, next) {
73-
getUsers(to, next);
74-
},
75-
beforeRouteUpdate(to, from, next) {
76-
getUsers(to, next);
65+
const currentPage = parseInt(to.query.page) || 1;
66+
store.dispatch("user/getUsers", currentPage).then(() => {
67+
to.params.page = currentPage;
68+
next();
69+
});
7770
},
7871
};
7972
</script>

0 commit comments

Comments
 (0)