forked from NdoleStudio/httpsms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMessageThread.vue
More file actions
169 lines (165 loc) · 4.66 KB
/
Copy pathMessageThread.vue
File metadata and controls
169 lines (165 loc) · 4.66 KB
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
<script setup lang="ts">
import { useDisplay } from 'vuetify'
import {
mdiPlus,
mdiDownload,
mdiCheckAll,
mdiCheck,
mdiAlert,
mdiAccount,
} from '@mdi/js'
import { formatPhoneNumber, startsWithLetter } from '~/utils/filters'
const { mdAndDown } = useDisplay()
const threadsStore = useThreadsStore()
const phonesStore = usePhonesStore()
const appStore = useAppStore()
const notificationsStore = useNotificationsStore()
function threadDate(date: string): string {
return new Date(date).toLocaleString(undefined, {
month: 'short',
day: 'numeric',
})
}
function onInstallApp() {
notificationsStore.addNotification({
type: 'info',
message: 'Downloading the httpSMS Android App',
})
}
</script>
<template>
<div>
<v-progress-linear
v-if="threadsStore.loadingThreads"
color="primary"
indeterminate
/>
<div
v-if="!threadsStore.loadingThreads && threadsStore.archivedThreads"
class="bg-warning py-1 text-center text-uppercase text-title-medium"
>
Archived Messages
</div>
<v-sheet
v-if="
!threadsStore.loadingThreads &&
threadsStore.threads.length === 0 &&
!threadsStore.archivedThreads
"
class="text-center mt-6 mx-3"
>
<div v-if="mdAndDown">
<v-img
class="mx-auto mb-4"
max-width="80%"
src="/img/person-texting.svg"
/>
<p v-if="phonesStore.owner" class="text-medium-emphasis">
Start sending messages
</p>
</div>
<v-btn
v-if="phonesStore.owner && phonesStore.phones.length !== 0"
color="primary"
:to="{ name: 'messages' }"
>
<v-icon :icon="mdiPlus" start />
New Message
</v-btn>
</v-sheet>
<div
v-if="phonesStore.phones.length === 0 && !threadsStore.loadingThreads"
class="px-4 text-center"
>
<p>
Install the mobile app on your Android phone to start sending messages.
You can also
<a
href="https://discord.gg/kGk8HVqeEZ"
target="_blank"
class="text-decoration-none hover:text-decoration-underline"
>message us on Discord</a
>
to help set things up.
</p>
<v-btn
color="primary"
:href="appStore.appData.appDownloadUrl"
@click="onInstallApp"
>
<v-icon :icon="mdiDownload" start />
Download App
</v-btn>
</div>
<v-list
v-if="!threadsStore.loadingThreads && threadsStore.threads.length > 0"
class="py-0"
lines="two"
>
<v-list-item
v-for="thread in threadsStore.threads"
:key="thread.id"
:to="{ name: 'threads-id', params: { id: thread.id } }"
:active="threadsStore.threadId === thread.id"
>
<template #prepend>
<v-avatar :color="thread.color" size="40">
<v-icon v-if="!startsWithLetter(thread.contact)" color="white">{{
mdiAccount
}}</v-icon>
<span v-else class="text-white text-headline-small">{{
thread.contact.substring(0, 1)
}}</span>
</v-avatar>
</template>
<v-list-item-title>{{
formatPhoneNumber(thread.contact)
}}</v-list-item-title>
<v-list-item-subtitle
class="text-truncate mt-1"
style="max-width: 250px"
>
{{ thread.last_message_content }}
</v-list-item-subtitle>
<template #append>
<div class="d-flex flex-column align-end">
<span class="text-body-small text-medium-emphasis">
{{ threadDate(thread.order_timestamp) }}
</span>
<div class="mt-1">
<v-icon
v-if="thread.status === 'expired'"
color="warning"
size="x-small"
:icon="mdiAlert"
/>
<v-icon
v-else-if="thread.status === 'delivered'"
color="primary"
size="x-small"
:icon="mdiCheckAll"
/>
<v-icon
v-else-if="thread.status === 'received'"
color="success"
size="x-small"
:icon="mdiCheckAll"
/>
<v-icon
v-else-if="thread.status === 'sent'"
size="x-small"
:icon="mdiCheck"
/>
<v-icon
v-else-if="thread.status === 'failed'"
color="error"
size="x-small"
:icon="mdiAlert"
/>
</div>
</div>
</template>
</v-list-item>
</v-list>
</div>
</template>