2020-11-18 21:19:02 +00:00
|
|
|
<template>
|
|
|
|
<div>
|
|
|
|
<div v-if="loaded && page == 'browse'" class="container messages-page p-0 p-md-2 mt-n4" style="min-height: 50vh;">
|
|
|
|
<div class="col-12 col-md-8 offset-md-2 p-0 px-md-2">
|
|
|
|
<div class="card shadow-none border mt-4">
|
|
|
|
<div class="card-header bg-white py-4">
|
|
|
|
<span class="h4 font-weight-bold mb-0">Direct Messages</span>
|
|
|
|
<span class="float-right">
|
2020-11-19 06:07:00 +00:00
|
|
|
<a class="btn btn-outline-primary font-weight-bold py-0 rounded-pill" href="#" @click.prevent="goto('add')">New Message</a>
|
2020-11-18 21:19:02 +00:00
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
<div class="card-header bg-white">
|
|
|
|
<ul class="nav nav-pills nav-fill">
|
|
|
|
<li class="nav-item">
|
|
|
|
<a :class="[tab == 'inbox' ? 'nav-link px-4 font-weight-bold rounded-pill active' : 'nav-link px-4 font-weight-bold rounded-pill']" @click.prevent="switchTab('inbox')" href="#">Inbox</a>
|
|
|
|
</li>
|
|
|
|
<li class="nav-item">
|
|
|
|
<a :class="[tab == 'sent' ? 'nav-link px-4 font-weight-bold rounded-pill active' : 'nav-link px-4 font-weight-bold rounded-pill']" @click.prevent="switchTab('sent')" href="#">Sent</a>
|
|
|
|
</li>
|
|
|
|
<li class="nav-item">
|
|
|
|
<a :class="[tab == 'filtered' ? 'nav-link px-4 font-weight-bold rounded-pill active' : 'nav-link px-4 font-weight-bold rounded-pill']" @click.prevent="switchTab('filtered')" href="#">Filtered</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<ul v-if="tab == 'inbox'" class="list-group list-group-flush">
|
|
|
|
<div v-if="!messages.inbox.length" class="list-group-item d-flex justify-content-center align-items-center" style="min-height: 40vh;">
|
|
|
|
<p class="lead mb-0">No messages found :(</p>
|
|
|
|
</div>
|
2021-07-11 08:57:14 +00:00
|
|
|
<div v-else v-for="(thread, index) in messages.inbox" :key="'dm_inbox'+index">
|
2020-11-18 21:19:02 +00:00
|
|
|
<a class="list-group-item text-dark text-decoration-none border-left-0 border-right-0 border-top-0" :href="'/account/direct/t/'+thread.id">
|
|
|
|
<div class="media d-flex align-items-center">
|
2021-07-11 08:57:14 +00:00
|
|
|
<img class="mr-3 rounded-circle img-thumbnail" :src="thread.avatar" width="32" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';" v-once>
|
2020-11-18 21:19:02 +00:00
|
|
|
<div class="media-body">
|
|
|
|
<p class="mb-0">
|
2020-11-19 03:28:39 +00:00
|
|
|
<span class="font-weight-bold text-truncate">
|
2020-11-18 21:19:02 +00:00
|
|
|
{{thread.name}}
|
|
|
|
</span>
|
2020-11-19 03:28:39 +00:00
|
|
|
<span class="pl-1 text-muted small text-truncate" style="font-weight: 500;">
|
|
|
|
{{thread.isLocal ? '@' + thread.username : thread.username}}
|
|
|
|
</span>
|
2020-11-18 21:19:02 +00:00
|
|
|
</p>
|
|
|
|
<p class="text-muted mb-0" style="font-size:13px;font-weight: 500;">
|
|
|
|
<span>
|
|
|
|
<i class="far fa-comment text-primary"></i>
|
|
|
|
</span>
|
|
|
|
<span class="pl-1 pr-3">
|
|
|
|
Received
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{thread.timeAgo}}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<span class="float-right">
|
|
|
|
<i class="fas fa-chevron-right fa-lg text-lighter"></i>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</ul>
|
|
|
|
<ul v-if="tab == 'sent'" class="list-group list-group-flush">
|
|
|
|
<div v-if="!messages.sent.length" class="list-group-item d-flex justify-content-center align-items-center" style="min-height: 40vh;">
|
|
|
|
<p class="lead mb-0">No messages found :(</p>
|
|
|
|
</div>
|
2021-07-11 08:57:14 +00:00
|
|
|
<div v-else v-for="(thread, index) in messages.sent" :key="'dm_sent'+index">
|
2020-11-18 21:19:02 +00:00
|
|
|
<a class="list-group-item text-dark text-decoration-none border-left-0 border-right-0 border-top-0" href="#" @click.prevent="loadMessage(thread.id)">
|
|
|
|
<div class="media d-flex align-items-center">
|
2021-07-11 08:57:14 +00:00
|
|
|
<img class="mr-3 rounded-circle img-thumbnail" :src="thread.avatar" width="32" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';" v-once>
|
2020-11-18 21:19:02 +00:00
|
|
|
<div class="media-body">
|
|
|
|
<p class="mb-0">
|
2020-11-19 03:28:39 +00:00
|
|
|
<span class="font-weight-bold text-truncate">
|
2020-11-18 21:19:02 +00:00
|
|
|
{{thread.name}}
|
|
|
|
</span>
|
2020-11-19 03:28:39 +00:00
|
|
|
<span class="pl-1 text-muted small text-truncate" style="font-weight: 500;">
|
|
|
|
{{thread.isLocal ? '@' + thread.username : thread.username}}
|
|
|
|
</span>
|
2020-11-18 21:19:02 +00:00
|
|
|
</p>
|
|
|
|
<p class="text-muted mb-0" style="font-size:13px;font-weight: 500;">
|
|
|
|
<span>
|
|
|
|
<i class="far fa-paper-plane text-primary"></i>
|
|
|
|
</span>
|
|
|
|
<span class="pl-1 pr-3">
|
|
|
|
Delivered
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{thread.timeAgo}}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<span class="float-right">
|
|
|
|
<i class="fas fa-chevron-right fa-lg text-lighter"></i>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</ul>
|
|
|
|
<ul v-if="tab == 'filtered'" class="list-group list-group-flush">
|
|
|
|
<div v-if="!messages.filtered.length" class="list-group-item d-flex justify-content-center align-items-center" style="min-height: 40vh;">
|
|
|
|
<p class="lead mb-0">No messages found :(</p>
|
|
|
|
</div>
|
2021-07-11 08:57:14 +00:00
|
|
|
<div v-else v-for="(thread, index) in messages.filtered" :key="'dm_filtered'+index">
|
2020-11-18 21:19:02 +00:00
|
|
|
<a class="list-group-item text-dark text-decoration-none border-left-0 border-right-0 border-top-0" href="#" @click.prevent="loadMessage(thread.id)">
|
|
|
|
<div class="media d-flex align-items-center">
|
2021-07-11 08:57:14 +00:00
|
|
|
<img class="mr-3 rounded-circle img-thumbnail" :src="thread.avatar" width="32" onerror="this.onerror=null;this.src='/storage/avatars/default.jpg';" v-once>
|
2020-11-18 21:19:02 +00:00
|
|
|
<div class="media-body">
|
|
|
|
<p class="mb-0">
|
2020-11-19 03:28:39 +00:00
|
|
|
<span class="font-weight-bold text-truncate">
|
2020-11-18 21:19:02 +00:00
|
|
|
{{thread.name}}
|
|
|
|
</span>
|
2020-11-19 03:28:39 +00:00
|
|
|
<span class="pl-1 text-muted small text-truncate" style="font-weight: 500;">
|
|
|
|
{{thread.isLocal ? '@' + thread.username : thread.username}}
|
|
|
|
</span>
|
2020-11-18 21:19:02 +00:00
|
|
|
</p>
|
|
|
|
<p class="text-muted mb-0" style="font-size:13px;font-weight: 500;">
|
|
|
|
<span>
|
|
|
|
<i class="fas fa-shield-alt" style="color:#fd9426"></i>
|
|
|
|
</span>
|
|
|
|
<span class="pl-1 pr-3">
|
|
|
|
Filtered
|
|
|
|
</span>
|
|
|
|
<span>
|
|
|
|
{{thread.timeAgo}}
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<span class="float-right">
|
|
|
|
<i class="fas fa-chevron-right fa-lg text-lighter"></i>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
<div v-if="tab == 'inbox'" class="mt-3 text-center">
|
|
|
|
<button class="btn btn-outline-primary rounded-pill btn-sm" :disabled="inboxPage == 1" @click="messagePagination('inbox', 'prev')">Prev</button>
|
|
|
|
<button class="btn btn-outline-primary rounded-pill btn-sm" :disabled="messages.inbox.length != 8" @click="messagePagination('inbox', 'next')">Next</button>
|
|
|
|
</div>
|
|
|
|
<div v-if="tab == 'sent'" class="mt-3 text-center">
|
|
|
|
<button class="btn btn-outline-primary rounded-pill btn-sm" :disabled="sentPage == 1" @click="messagePagination('sent', 'prev')">Prev</button>
|
|
|
|
<button class="btn btn-outline-primary rounded-pill btn-sm" :disabled="messages.sent.length != 8" @click="messagePagination('sent', 'next')">Next</button>
|
|
|
|
</div>
|
|
|
|
<div v-if="tab == 'filtered'" class="mt-3 text-center">
|
|
|
|
<button class="btn btn-outline-primary rounded-pill btn-sm" :disabled="filteredPage == 1" @click="messagePagination('filtered', 'prev')">Prev</button>
|
|
|
|
<button class="btn btn-outline-primary rounded-pill btn-sm" :disabled="messages.filtered.length != 8" @click="messagePagination('filtered', 'next')">Next</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="loaded && page == 'add'" class="container messages-page p-0 p-md-2 mt-n4" style="min-height: 60vh;">
|
|
|
|
<div class="col-12 col-md-8 offset-md-2 p-0 px-md-2">
|
|
|
|
<div class="card shadow-none border mt-4">
|
|
|
|
<div class="card-header bg-white py-4 d-flex justify-content-between">
|
|
|
|
<span class="cursor-pointer px-3" @click="goto('browse')"><i class="fas fa-chevron-left"></i></span>
|
|
|
|
<span class="h4 font-weight-bold mb-0">New Direct Message</span>
|
|
|
|
<span><i class="fas fa-chevron-right text-white"></i></span>
|
|
|
|
</div>
|
|
|
|
<div class="card-body d-flex align-items-center justify-content-center" style="height: 60vh;">
|
2020-11-19 06:07:00 +00:00
|
|
|
<div>
|
|
|
|
<p class="mb-0 font-weight-bold">Select Recipient</p>
|
|
|
|
<autocomplete
|
2020-11-18 21:19:02 +00:00
|
|
|
:search="composeSearch"
|
2020-11-19 06:07:00 +00:00
|
|
|
:disabled="composeLoading"
|
2020-11-18 21:19:02 +00:00
|
|
|
placeholder="@dansup"
|
|
|
|
aria-label="Search usernames"
|
|
|
|
:get-result-value="getTagResultValue"
|
|
|
|
@submit="onTagSubmitLocation"
|
|
|
|
ref="autocomplete"
|
|
|
|
>
|
|
|
|
</autocomplete>
|
2020-11-19 06:07:00 +00:00
|
|
|
<div style="width:300px;"></div>
|
2020-11-18 21:19:02 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<style type="text/css" scoped>
|
|
|
|
</style>
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
2020-11-18 21:31:59 +00:00
|
|
|
import Autocomplete from '@trevoreyre/autocomplete-vue'
|
|
|
|
import '@trevoreyre/autocomplete-vue/dist/style.css'
|
2020-11-18 21:19:02 +00:00
|
|
|
export default {
|
2020-11-18 21:31:59 +00:00
|
|
|
components: {
|
|
|
|
Autocomplete
|
|
|
|
},
|
2020-11-18 21:19:02 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
config: window.App.config,
|
|
|
|
loaded: false,
|
|
|
|
profile: {},
|
|
|
|
page: 'browse',
|
|
|
|
pages: ['browse', 'add', 'read'],
|
|
|
|
tab: 'inbox',
|
|
|
|
tabs: ['inbox', 'sent', 'filtered'],
|
|
|
|
inboxPage: 1,
|
|
|
|
sentPage: 1,
|
|
|
|
filteredPage: 1,
|
|
|
|
threads: [],
|
|
|
|
thread: false,
|
|
|
|
threadIndex: false,
|
|
|
|
|
|
|
|
replyText: '',
|
|
|
|
composeUsername: '',
|
|
|
|
|
|
|
|
ctxContext: null,
|
|
|
|
ctxIndex: null,
|
|
|
|
|
|
|
|
uploading: false,
|
|
|
|
uploadProgress: null,
|
|
|
|
|
|
|
|
messages: {
|
|
|
|
inbox: [],
|
|
|
|
sent: [],
|
|
|
|
filtered: []
|
2020-11-19 06:07:00 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
newType: 'select',
|
|
|
|
composeLoading: false,
|
2020-11-18 21:19:02 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mounted() {
|
|
|
|
this.fetchProfile();
|
|
|
|
let self = this;
|
2020-11-18 21:31:59 +00:00
|
|
|
axios.get('/api/direct/browse', {
|
2020-11-18 21:19:02 +00:00
|
|
|
params: {
|
|
|
|
a: 'inbox'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
self.loaded = true;
|
|
|
|
this.threads = res.data
|
|
|
|
this.messages.inbox = res.data;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
updated() {
|
|
|
|
$('[data-toggle="tooltip"]').tooltip();
|
|
|
|
},
|
|
|
|
|
|
|
|
methods: {
|
|
|
|
fetchProfile() {
|
|
|
|
axios.get('/api/pixelfed/v1/accounts/verify_credentials').then(res => {
|
|
|
|
this.profile = res.data;
|
|
|
|
window._sharedData.curUser = res.data;
|
2020-12-03 04:45:50 +00:00
|
|
|
window.App.util.navatar();
|
2020-11-18 21:19:02 +00:00
|
|
|
});
|
|
|
|
},
|
2020-11-19 06:07:00 +00:00
|
|
|
|
2020-11-18 21:19:02 +00:00
|
|
|
goto(l = 'browse') {
|
|
|
|
this.page = l;
|
|
|
|
},
|
|
|
|
|
|
|
|
loadMessage(id) {
|
|
|
|
let url = '/account/direct/t/' + id;
|
|
|
|
window.location.href = url;
|
|
|
|
return;
|
|
|
|
},
|
|
|
|
|
|
|
|
truncate(t) {
|
|
|
|
return _.truncate(t);
|
|
|
|
},
|
|
|
|
|
|
|
|
switchTab(tab) {
|
|
|
|
let self = this;
|
|
|
|
switch(tab) {
|
|
|
|
case 'inbox':
|
|
|
|
if(this.messages.inbox.length == 0) {
|
|
|
|
// fetch
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'sent':
|
|
|
|
if(this.messages.sent.length == 0) {
|
2020-11-18 21:31:59 +00:00
|
|
|
axios.get('/api/direct/browse', {
|
2020-11-18 21:19:02 +00:00
|
|
|
params: {
|
|
|
|
a: 'sent'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
self.loaded = true;
|
|
|
|
self.threads = res.data
|
|
|
|
self.messages.sent = res.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'filtered':
|
|
|
|
if(this.messages.filtered.length == 0) {
|
2020-11-18 21:31:59 +00:00
|
|
|
axios.get('/api/direct/browse', {
|
2020-11-18 21:19:02 +00:00
|
|
|
params: {
|
|
|
|
a: 'filtered'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
self.loaded = true;
|
|
|
|
self.threads = res.data
|
|
|
|
self.messages.filtered = res.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
this.tab = tab;
|
|
|
|
},
|
|
|
|
|
|
|
|
composeSearch(input) {
|
|
|
|
if (input.length < 1) { return []; };
|
|
|
|
let self = this;
|
|
|
|
let results = [];
|
2020-11-19 06:07:00 +00:00
|
|
|
return axios.post('/api/direct/lookup', {
|
|
|
|
q: input
|
2020-11-18 21:19:02 +00:00
|
|
|
}).then(res => {
|
|
|
|
return res.data;
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
getTagResultValue(result) {
|
2020-11-19 06:07:00 +00:00
|
|
|
// return '@' + result.name;
|
|
|
|
return result.local ? '@' + result.name : result.name;
|
2020-11-18 21:19:02 +00:00
|
|
|
},
|
2020-11-18 21:31:59 +00:00
|
|
|
|
2020-11-18 21:19:02 +00:00
|
|
|
onTagSubmitLocation(result) {
|
|
|
|
//this.$refs.autocomplete.value = '';
|
2020-11-19 06:07:00 +00:00
|
|
|
this.composeLoading = true;
|
2020-11-18 21:19:02 +00:00
|
|
|
window.location.href = '/account/direct/t/' + result.id;
|
|
|
|
return;
|
|
|
|
},
|
|
|
|
|
|
|
|
messagePagination(tab, dir) {
|
|
|
|
if(tab == 'inbox') {
|
|
|
|
this.inboxPage = dir == 'prev' ? this.inboxPage - 1 : this.inboxPage + 1;
|
2020-11-18 21:31:59 +00:00
|
|
|
axios.get('/api/direct/browse', {
|
2020-11-18 21:19:02 +00:00
|
|
|
params: {
|
|
|
|
a: 'inbox',
|
|
|
|
page: this.inboxPage
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
self.loaded = true;
|
|
|
|
this.threads = res.data
|
|
|
|
this.messages.inbox = res.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if(tab == 'sent') {
|
|
|
|
this.sentPage = dir == 'prev' ? this.sentPage - 1 : this.sentPage + 1;
|
2020-11-18 21:31:59 +00:00
|
|
|
axios.get('/api/direct/browse', {
|
2020-11-18 21:19:02 +00:00
|
|
|
params: {
|
|
|
|
a: 'sent',
|
|
|
|
page: this.sentPage
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
self.loaded = true;
|
|
|
|
this.threads = res.data
|
|
|
|
this.messages.sent = res.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
if(tab == 'filtered') {
|
|
|
|
this.filteredPage = dir == 'prev' ? this.filteredPage - 1 : this.filteredPage + 1;
|
2020-11-18 21:31:59 +00:00
|
|
|
axios.get('/api/direct/browse', {
|
2020-11-18 21:19:02 +00:00
|
|
|
params: {
|
|
|
|
a: 'filtered',
|
|
|
|
page: this.filteredPage
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.then(res => {
|
|
|
|
self.loaded = true;
|
|
|
|
this.threads = res.data
|
|
|
|
this.messages.filtered = res.data;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-07-11 08:57:14 +00:00
|
|
|
</script>
|