Skip to content

Commit

Permalink
refinement: add broadcast notifacation to student's side #90
Browse files Browse the repository at this point in the history
  • Loading branch information
CapFreddy committed May 26, 2020
1 parent ecfe01f commit 00a2341
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions app/javascript/src/shared/components/navbar.vue
Expand Up @@ -121,6 +121,7 @@
import Issue from '../../issues/models/issue'
import IssuesService from "../../issues/services/issues_service";
import AlertMixin from '../../shared/components/mixins/alert'
import axios from "axios";
export default {
props: ['broadcast_num'],
Expand Down Expand Up @@ -173,6 +174,7 @@
class_name: project.class_name
});
}
setInterval(this.getLatestBroadcast, 2000);
},
updated() {
if (this.dialogVisible) {
Expand Down Expand Up @@ -305,6 +307,17 @@
this.loading = false;
this.dialogVisible = false;
})
},
getLatestBroadcast() {
axios.get('/broadcasts/get_latest_broadcast').then((response) => {
if (response.data['broadcast_num'] > this.broadcast_num) {
this.broadcast_num = response.data['broadcast_num'];
this.$notify({
title: '新广播',
message: response.data['latest_broadcast']['content']
});
}
});
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/src/shared/components/teacher_navbar.vue
Expand Up @@ -143,11 +143,11 @@
getLatestBroadcast() {
axios.get('/broadcasts/get_latest_broadcast').then((response) => {
if (response.data['broadcast_num'] > this.broadcast_num) {
this.broadcast_num = response.data['broadcast_num']
this.broadcast_num = response.data['broadcast_num'];
this.$notify({
title: '新广播',
message: response.data['latest_broadcast']['content']
})
});
}
});
}
Expand Down

0 comments on commit 00a2341

Please sign in to comment.