Skip to content

Commit

Permalink
Merge pull request #283 from lewisl9029/feature-outgoing-network-traf…
Browse files Browse the repository at this point in the history
…fic-buffering

Feature outgoing network traffic buffering. Fixes #280. Closes #282. Closes #239. Closes #238.
  • Loading branch information
lewisl9029 committed Sep 4, 2015
2 parents 57f76f2 + aa88ac6 commit 85a0fdc
Show file tree
Hide file tree
Showing 28 changed files with 839 additions and 431 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,6 @@ export default /*@ngInject*/ function tocBeginConversationModal() {

this.contactId = '';

let initializeSentInvite = (contactChannel) => {
return state.save(
state.cloud.channels,
[contactChannel.id, 'sentInvite'],
true
)
.then(() => state.save(
state.cloud.contacts,
[this.contactId, 'statusId'],
0
))
.then(() => {
this.removeModal();
return $q.when();
});
};

this.inviteMethod = 'enter';

this.inviteMethods = {
Expand Down Expand Up @@ -75,10 +58,11 @@ export default /*@ngInject*/ function tocBeginConversationModal() {
return;
}

return contacts.invite(this.contactId)
.then(initializeSentInvite)
return contacts.saveSendingInvite(this.contactId)
.then(() => {
this.removeModal();
this.contactId = '';
return $q.when();
});
}
}
Expand All @@ -102,9 +86,12 @@ export default /*@ngInject*/ function tocBeginConversationModal() {
return $q.reject(`${contactId} is not a valid Toc ID.`);
}

return contacts.invite(contactId);
return contacts.saveSendingInvite(contactId);
})
.then(() => {
this.removeModal();
return $q.when();
})
.then(initializeSentInvite)
.catch((error) => $log.error(error));
}

Expand Down
38 changes: 34 additions & 4 deletions app/components/channel-card/channel-card-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,46 @@ export default /*@ngInject*/ function tocChannelCard() {
this.contact = contactCursor.get(
this.channel.channelInfo.contactIds[0]
);
updateStatus();
};

let updateStatus = () => {
if (this.contact.statusId === -1) {
this.status = 'toc-contact-status-pending';
return;
}

if (this.contact.statusId === 0) {
this.status = 'toc-contact-status-offline';
return;
}

if (this.contact.statusId === 1) {
this.status = 'toc-contact-status-online';
return;
}

this.status = 'toc-contact-status-unknown';
};

let updateQuote = () => {
if (this.channel.sentInvite) {
this.quote = `ID: ${this.channel.channelInfo.contactIds[0]}`;
if (this.channel.inviteStatus === 'accepting') {
this.quote = `Accepting invite`;
return;
}

if (this.channel.inviteStatus === 'sending') {
this.quote = `Sending invite`;
return;
}

if (this.channel.inviteStatus === 'sent') {
this.quote = `Sent invite`;
return;
}

if (this.channel.receivedInvite) {
this.quote = 'New invite';
if (this.channel.inviteStatus === 'received') {
this.quote = 'Received invite';
return;
}

Expand Down
7 changes: 3 additions & 4 deletions app/components/channel-card/channel-card.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<div class="toc-channel-card item item-avatar" ng-class="{
'toc-channel-pending':
channelCard.channel.sentInvite || channelCard.channel.receivedInvite
}">
'toc-channel-pending': channelCard.contact.statusId === -1
}">
<img class="toc-channel-card-avatar"
ng-src="{{channelCard.getAvatar(channelCard.contact.userInfo)}}">
</img>
<div class="toc-channel-card-status-indicator"
ng-class="'toc-contact-status-' + channelCard.contact.statusId">
ng-class="channelCard.status">
</div>
<h2>{{channelCard.contact.userInfo.displayName || 'Anonymous'}}</h2>
<p class="toc-channel-card-quote" ng-class="{
Expand Down
13 changes: 11 additions & 2 deletions app/components/channel-card/channel-card.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,20 @@
font-style: italic;
}

.toc-contact-status-0 {
.toc-contact-status-unknown {
border: 2px solid lighten($dark, 50);
background-color: lighten($dark, 50);
}

.toc-contact-status-pending {
border: 2px solid lighten($dark, 50);
}

.toc-contact-status-offline {
border: 2px solid $balanced;
}

.toc-contact-status-1 {
.toc-contact-status-online {
border: 2px solid $balanced;
background-color: $balanced;
}
Expand Down
19 changes: 10 additions & 9 deletions app/components/channel-list/channel-list-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,18 @@ export default /*@ngInject*/ function tocChannelList() {
state.addListener(contactsCursor, updateContacts, $scope);

this.handleClick = function handleChannelClick(channel) {
if (channel.sentInvite) {
if (channel.inviteStatus === 'sent' ||
channel.inviteStatus === 'sending' ||
channel.inviteStatus === 'accepting'
) {
return;
}

if (channel.receivedInvite) {
let contact =
state.cloud.contacts.get([channel.channelInfo.contactIds[0]]);
if (channel.inviteStatus === 'received') {
let contactId = channel.channelInfo.contactIds[0];
let channelId = channel.channelInfo.id;
let contact = state.cloud.contacts.get([contactId]);

return $ionicPopup.show({
template: `Accept invite from ${contact.userInfo.displayName || 'Anonymous'}?`,
title: 'Accept Invite',
Expand All @@ -55,11 +60,7 @@ export default /*@ngInject*/ function tocChannelList() {
text: 'Accept',
type: 'button-outline button-balanced',
onTap: (event) => {
return contacts.invite(channel.channelInfo.contactIds[0])
.then(() => state.remove(
state.cloud.channels,
[channel.channelInfo.id, 'receivedInvite']
));
return contacts.saveAcceptingInvite(channelId);
}
}
]
Expand Down
Loading

0 comments on commit 85a0fdc

Please sign in to comment.