1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
<template>
<div class="header">
<Button
type="primary"
class="new-message-button"
:disabled="$store.getters.showMessageComposer"
button-id="mail_new_message"
role="complementary"
@click="onNewMessage">
<template #icon>
<IconAdd
:size="20" />
</template>
{{ t('mail', 'New message') }}
</Button>
<Button v-if="currentMailbox"
type="tertiary-no-background"
class="refresh__button"
:disabled="refreshing"
@click="refreshMailbox">
<template #icon>
<IconRefresh
:size="20" />
</template>
</Button>
</div>
</template>
<script>
import { NcButton as Button } from '@nextcloud/vue'
import IconAdd from 'vue-material-design-icons/Plus'
import IconRefresh from 'vue-material-design-icons/Refresh'
import logger from '../logger'
export default {
name: 'NewMessageButtonHeader',
components: {
Button,
IconAdd,
IconRefresh,
},
data() {
return {
refreshing: false,
}
},
computed: {
currentMailbox() {
if (this.$route.name === 'message' || this.$route.name === 'mailbox') {
return this.$store.getters.getMailbox(this.$route.params.mailboxId)
}
return undefined
},
},
methods: {
async refreshMailbox() {
if (this.refreshing === true) {
logger.debug('already sync\'ing mailbox.. aborting')
return
}
this.refreshing = true
try {
await this.$store.dispatch('syncEnvelopes', { mailboxId: this.currentMailbox.databaseId })
logger.debug('Current mailbox is sync\'ing ')
} catch (error) {
logger.error('could not sync current mailbox', { error })
} finally {
this.refreshing = false
}
},
onNewMessage() {
this.$store.dispatch('showMessageComposer', {
})
},
},
}
</script>
<style lang="scss" scoped>
.header {
display: flex;
align-items: center;
padding: 8px 8px 8px 48px;
gap: 4px;
height: 61px;
border-right: 1px solid var(--color-border)
}
.refresh__button {
background-color: transparent;
}
.new-message-button {
background-image: var(--gradient-primary-background);
}
</style>
|