1
0
mirror of https://github.com/nerzhul/ocsms.git synced 2025-06-07 07:56:23 +00:00

More rework on the conversation

This commit is contained in:
Loic Blot 2018-09-06 08:04:38 +02:00 committed by Loïc Blot
parent 3dfaedc317
commit 4e60b5779f
3 changed files with 65 additions and 15 deletions

View File

@ -24,12 +24,9 @@ var ContactList = new Vue({
// phoneNumber must exist // phoneNumber must exist
if (contact.nav !== null) { if (contact.nav !== null) {
this.fetchConversation(contact); ContactList.fetchConversation(contact);
Sms.selectConversation($("a[mailbox-navigation='" + contact.nav + "']")); Sms.selectConversation($("a[mailbox-navigation='" + contact.nav + "']"));
} }
},
fetchConversation: function (contact) {
// @TODO
} }
}, },
computed: { computed: {

64
js/devel/conversation.js Normal file
View File

@ -0,0 +1,64 @@
/**
* Nextcloud - Phone Sync
*
* This file is licensed under the Affero General Public License version 3 or
* later. See the COPYING file.
*
* @author Loic Blot <loic.blot@unix-experience.fr>
* @copyright Loic Blot 2014-2018
*/
var ContactList = new Vue({
el: '#ocsms-app-content',
data: {
selectedContact: {},
isConvLoading: false,
messages: [],
lastConvMessageDate: 0
},
created: function () {
},
methods: {
fetchConversation: function (contact) {
// If contact is not null, we will fetch a conversation for a new contact
if (contact != null) {
this.selectedContact = contact;
this.isConvLoading = true;
}
this.messages = [];
this.lastConvMessageDate = 0;
var self = this;
$.getJSON(Sms.generateURL('/front-api/v1/conversation'), {'phoneNumber': $scope.selectedContact.nav},
function (jsondata, status) {
var phoneNumberLabel = self.selectedContact.nav;
if (typeof jsondata['phoneNumbers'] !== 'undefined') {
var phoneNumberList = arrayUnique(jsondata['phoneNumbers']);
phoneNumberLabel = phoneNumberList.toString();
}
// Reinit messages before showing conversation
app.formatConversation(jsondata);
$scope.$apply(function () {
if (typeof jsondata['contactName'] === 'undefined' || jsondata['contactName'] === '') {
self.selectedContact.label = phoneNumberLabel;
self.selectedContact.opt_numbers = "";
}
else {
self.selectedContact.label = jsondata['contactName'];
self.selectedContact.opt_numbers = phoneNumberLabel;
}
self.totalMessageCount = jsondata['msgCount'] !== undefined ? jsondata['msgCount'] : 0;
self.isConvLoading = false;
});
$('#ocsms-app-content').scrollTop(1E10);
}
);
};
}
});

View File

@ -35,17 +35,6 @@ app.controller('OcSmsController', ['$scope', '$interval', '$timeout', '$compile'
$scope.selectedContact = {}; $scope.selectedContact = {};
$scope.lastSearch = ''; $scope.lastSearch = '';
// Conversations
$scope.loadConversation = function (contact) {
OC.Util.History.pushState('phonenumber=' + contact.nav);
// phoneNumber must exist
if (contact.nav !== null) {
$scope.fetchConversation(contact);
Sms.selectConversation($("a[mailbox-navigation='" + contact.nav + "']"));
}
};
$scope.fetchConversation = function (contact) { $scope.fetchConversation = function (contact) {
// If contact is not null, we will fetch a conversation for a new contact // If contact is not null, we will fetch a conversation for a new contact
if (contact != null) { if (contact != null) {