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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
<template>
<AppContent>
<AppDetailsToggle v-if="showThread" @close="hideMessage" />
<div id="app-content-wrapper">
<AppContentList
v-infinite-scroll="onScroll"
v-shortkey.once="shortkeys"
infinite-scroll-immediate-check="false"
:show-details="showThread"
:infinite-scroll-disabled="false"
:infinite-scroll-distance="10"
@shortkey.native="onShortcut">
<Mailbox
v-if="!mailbox.isPriorityInbox"
:account="account"
:mailbox="mailbox"
:search-query="query"
:bus="bus" />
<template v-else>
<div class="app-content-list-item">
<SectionTitle class="important" :name="t('mail', 'Important')" />
<Popover trigger="hover focus">
<button slot="trigger" :aria-label="t('mail', 'Important info')" class="button icon-info" />
{{ importantInfo }}
</Popover>
</div>
<Mailbox
class="nameimportant"
:account="unifiedAccount"
:mailbox="unifiedInbox"
:search-query="appendToSearch('is:important')"
:paginate="'manual'"
:is-priority-inbox="true"
:initial-page-size="5"
:collapsible="true"
:bus="bus" />
<SectionTitle class="app-content-list-item starred" :name="t('mail', 'Favorites')" />
<Mailbox
class="namestarred"
:account="unifiedAccount"
:mailbox="unifiedInbox"
:search-query="appendToSearch('is:starred not:important')"
:paginate="'manual'"
:is-priority-inbox="true"
:initial-page-size="5"
:bus="bus" />
<SectionTitle class="app-content-list-item other" :name="t('mail', 'Other')" />
<Mailbox
class="nameother"
:account="unifiedAccount"
:mailbox="unifiedInbox"
:open-first="false"
:search-query="appendToSearch('not:starred not:important')"
:is-priority-inbox="true"
:bus="bus" />
</template>
</AppContentList>
<NewMessageDetail v-if="newMessage" />
<Thread v-else-if="showThread" @delete="deleteMessage" />
<NoMessageSelected v-else-if="hasEnvelopes && !isMobile" />
</div>
</AppContent>
</template>
<script>
import AppContent from '@nextcloud/vue/dist/Components/AppContent'
import AppContentList from '@nextcloud/vue/dist/Components/AppContentList'
import Popover from '@nextcloud/vue/dist/Components/Popover'
import infiniteScroll from 'vue-infinite-scroll'
import isMobile from '@nextcloud/vue/dist/Mixins/isMobile'
import SectionTitle from './SectionTitle'
import Vue from 'vue'
import AppDetailsToggle from './AppDetailsToggle'
import logger from '../logger'
import Mailbox from './Mailbox'
import NewMessageDetail from './NewMessageDetail'
import NoMessageSelected from './NoMessageSelected'
import Thread from './Thread'
import { UNIFIED_ACCOUNT_ID, UNIFIED_INBOX_ID } from '../store/constants'
export default {
name: 'MailboxThread',
directives: {
infiniteScroll,
},
components: {
AppContent,
AppContentList,
AppDetailsToggle,
Mailbox,
NewMessageDetail,
NoMessageSelected,
Popover,
SectionTitle,
Thread,
},
mixins: [isMobile],
props: {
account: {
type: Object,
required: true,
},
mailbox: {
type: Object,
required: true,
},
},
data() {
return {
alive: false,
// eslint-disable-next-line
importantInfo: t('mail', 'Messages will automatically be marked as important based on which messages you interacted with or marked as important. In the beginning you might have to manually change the importance to teach the system, but it will improve over time.'),
bus: new Vue(),
searchQuery: undefined,
shortkeys: {
del: ['del'],
flag: ['s'],
next: ['arrowright'],
prev: ['arrowleft'],
refresh: ['r'],
unseen: ['u'],
},
}
},
computed: {
unifiedAccount() {
return this.$store.getters.getAccount(UNIFIED_ACCOUNT_ID)
},
unifiedInbox() {
return this.$store.getters.getMailbox(UNIFIED_INBOX_ID)
},
hasEnvelopes() {
return this.$store.getters.getEnvelopes(this.mailbox.databaseId, this.searchQuery).length > 0
},
showThread() {
return (this.mailbox.isPriorityInbox === true || this.hasEnvelopes) && this.$route.name === 'message'
},
query() {
if (this.$route.params.filter === 'starred') {
if (this.searchQuery) {
return this.searchQuery + ' is:starred'
}
return 'is:starred'
}
return this.searchQuery
},
newMessage() {
return (
this.$route.params.threadId === 'new'
|| this.$route.params.threadId === 'reply'
|| this.$route.params.threadId === 'replyAll'
)
},
},
created() {
this.alive = true
window.addEventListener('DOMContentLoaded', (event) => {
// eslint-disable-next-line no-new
new OCA.Search(this.searchProxy, this.clearSearchProxy)
})
},
beforeDestroy() {
this.alive = false
},
methods: {
hideMessage() {
this.$router.replace({
name: 'mailbox',
params: {
mailboxId: this.mailbox.databaseId,
filter: this.$route.params.filter ? this.$route.params.filter : undefined,
},
})
},
deleteMessage(id) {
this.bus.$emit('delete', id)
},
onScroll(event) {
logger.debug('scroll', { event })
this.bus.$emit('loadMore')
},
onShortcut(e) {
this.bus.$emit('shortcut', e)
},
appendToSearch(str) {
if (this.searchQuery === undefined) {
return str
}
return this.searchQuery + ' ' + str
},
searchProxy(query) {
if (this.alive) {
this.search(query)
}
},
clearSearchProxy() {
if (this.alive) {
this.clearSearch()
}
},
search(query) {
this.searchQuery = query
},
clearSearch() {
this.searchQuery = undefined
},
},
}
</script>
<style lang="scss" scoped>
.v-popover > .trigger > {
z-index: 1;
}
.icon-info {
background-image: var(--icon-info-000);
}
.app-content-list-item:hover {
background: transparent;
}
.button {
background-color: var(--color-main-background);
width: 44px;
height: 44px;
border: 0;
margin-bottom: 17px;
&:hover,
&:focus {
background-color: var(--color-background-dark);
}
}
#app-content-wrapper {
display: flex;
}
</style>
|