Skip to content

Commit

Permalink
Merge pull request #39 from G4brym/auto-refresh-emails
Browse files Browse the repository at this point in the history
Auto refresh email list every 5 minutes
  • Loading branch information
G4brym authored Sep 17, 2023
2 parents 454c21f + affcd4a commit e4ca0c7
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions packages/dashboard/src/components/email/EmailList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,33 +64,48 @@
<!-- end row-->
</template>
<script>
import utils from "@/utils";
import utils from '@/utils'
export default {
data: function () {
return {
timeInterval: null
}
},
methods: {
timeAgo(time) {
return utils.timeSince(new Date(time));
timeAgo (time) {
return utils.timeSince(new Date(time))
},
getEmailDate(time) {
const date = new Date(time);
getEmailDate (time) {
const date = new Date(time)
const mm = date.getMonth() + 1; // getMonth() is zero-based
const dd = date.getDate();
const mm = date.getMonth() + 1 // getMonth() is zero-based
const dd = date.getDate()
return `${dd}/${(mm > 9 ? "" : "0") + mm}`;
return `${dd}/${(mm > 9 ? '' : '0') + mm}`
}
},
created() {
unmounted () {
clearInterval(this.timeInterval)
this.timeInterval = null
},
created () {
const self = this
this.timeInterval = setInterval(() => {
self.$store.dispatch('refreshObjects')
}, 300000) // 5 minutes
this.$watch(
() => this.$route.params.folder,
(newFolder) => {
if (this.$store.state.activeTab === "email") {
this.$store.dispatch("refreshObjects");
if (this.$store.state.activeTab === 'email') {
this.$store.dispatch('refreshObjects')
}
}
);
)
}
};
}
</script>

<style lang="scss" scoped>
Expand Down

0 comments on commit e4ca0c7

Please sign in to comment.