Skip to content

Commit

Permalink
Potential fix for #12: topic presence notifications (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaylevin authored Mar 7, 2019
1 parent 0b574ab commit 156ab7a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 47 deletions.
11 changes: 2 additions & 9 deletions src/components/Topic.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>

<div class="contact-right">
<div v-if="topic.online === true" class="contact-presence">
<div v-if="topicOnline" class="contact-presence">
<span>&#183;</span>
</div>

Expand Down Expand Up @@ -47,20 +47,13 @@ export default {
return this.topic.touched;
},
topicOnline() {
return this.topic.online;
return store.state.client.tinodeClient.getTopic(this.topic.topic).online;
}
}
};
</script>

<style lang="scss">
// p {
// -webkit-user-select: text;
// -khtml-user-select: text;
// -moz-user-select: text;
// -o-user-select: text;
// user-select: text;
// }
.contact {
display: flex;
justify-content: center;
Expand Down
32 changes: 3 additions & 29 deletions src/store/modules/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,36 +84,10 @@ export default {

me.onPres = function(pres) {
console.log("Received Presence msg:", pres);
let contact = store.getters.contacts.find(c => {
return c.topic == pres.src;
store.dispatch("updateTopicPresence", {
topicID: pres.src,
presence: pres.what == "on" ? true : false
});
if (contact) {
if (pres.topic == "me") {
switch (pres.what) {
case "on":
store.dispatch("updateTopicPresence", {
topicID: pres.src,
presence: true
});

break;
case "off":
store.dispatch("updateTopicPresence", {
topicID: pres.src,
presence: false
});
break;

case "msg":
// presence message for a notification
break;
}
}
} else {
console.log(
"Received a presence message from someone whom client is not subbed to"
);
}
};

fnd.onMeta = function(meta) {
Expand Down
15 changes: 6 additions & 9 deletions src/store/modules/contacts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import axios from "axios";

export function defaultState() {
return {
contacts: [],
contacts: [{}],
selectedTopicID: "",

// Add contact form drop down menu in ContactsListView.vue
addContactForm: {
searchQuery: "",
searchResults: [],
searchResults: [{}],
isVisible: false
}
};
Expand Down Expand Up @@ -95,13 +97,8 @@ export default {
payload.topicID,
payload.presence
);

let contact = state.contacts.find(c => {
return c.topic == payload.topicID;
});
if (contact) {
contact.online = payload.presence;
}
let topic = store.state.client.tinodeClient.getTopic(payload.topicID);
topic.online = payload.presence;
},
selectTopic(state, topicID) {
console.log("Selecting topic", topicID);
Expand Down

0 comments on commit 156ab7a

Please sign in to comment.