Skip to content

Commit

Permalink
Feat inbox (#1076)
Browse files Browse the repository at this point in the history
* resolve merge conflit

* feat(inbox): user can send direct messages to other users.

* feat(email-notifications): email notifications for `new messages`.

user will receive email notification for unread messages

* refactor(user-settings): update user email setting preference.

* small proofreading edits

* fix(conversation): now, user can create multiple conversations

* style(conversations): remove typo
  • Loading branch information
distalx committed Nov 12, 2018
1 parent 358ab1b commit c8463e0
Show file tree
Hide file tree
Showing 68 changed files with 1,242 additions and 899 deletions.
1 change: 1 addition & 0 deletions client/css/_buttons.scss
Expand Up @@ -61,6 +61,7 @@
&:hover {
background: $white;
color: $cta-blue;
cursor: pointer;
}
}

Expand Down
1 change: 1 addition & 0 deletions client/css/_colors.scss
Expand Up @@ -29,6 +29,7 @@ $warning-orange: #f0ad4e;
$danger-red: #d9534f;
$well: #f5f5f5;
$end-hangout-color: #AD4545;
$light-grey: #D3D3D3;
$github: #333;
$slack: #3AAF85;

Expand Down
27 changes: 27 additions & 0 deletions client/css/_inbox.scss
@@ -0,0 +1,27 @@
.conversation-unread {
background: $light-grey;
}

// chat bubble

.ib-clear {clear: both}
.ib-from-me {
position:relative;
padding:15px;
margin-bottom: 4px;
color: black;
border: 1px solid $light-grey;
border-radius:25px;
float: right;
}
.ib-from-them {
position:relative;
padding:10px 20px;
margin-bottom: 4px;
// background:#E5E5EA;
border: 1px solid $light-grey;
border-radius:25px;
color: black;
float: left;
cursor: pointer;
}
1 change: 1 addition & 0 deletions client/css/style.scss
Expand Up @@ -29,6 +29,7 @@
@import 'study_groups';
@import 'discussion';
@import 'slack';
@import 'inbox';

@import 'sections';
@import 'tips_lists';
13 changes: 2 additions & 11 deletions client/layouts/layout.js
Expand Up @@ -28,18 +28,9 @@ Template.layout.events({
}
});
} else if (result.dismiss === "esc" || result.dismiss === "overlay") {
swal(
"No worries!",
"Sign up or sign in with Slack or Github at any time.",
"info"
);
swal("No worries!", "Sign up or sign in with Slack or Github at any time.", "info");
} else {
swal(
"Oops! Something went wrong",
error.error,
+"\n Try again",
"error"
);
swal("Oops! Something went wrong", error.error, +"\n Try again", "error");
}
});
}
Expand Down
3 changes: 3 additions & 0 deletions client/templates/admin/notification/all_notifications.html
Expand Up @@ -19,6 +19,9 @@ <h3>Notifications</h3>
{{#if equals type 'reported discussion'}}
<p class="alert {{#if hasBeenSeen}} {{else}} markAsRead alert-info{{/if}}"><i class="fas {{icon}}" aria-hidden="true"> </i> {{#if isActorAdmin actor.id}} {{actor.username}} {{else}} <a href="{{pathFor 'user by id'}}/{{actor.id}}"> {{actor.username}} </a> {{/if}} {{action}} <a href="{{pathFor 'user by id'}}/{{subject.id}}"> {{subject.username}}'s </a> discussion <a href="{{pathFor 'discussion' discussionId=discussion.id}}"> <b>{{discussion.topic}}</b> &nbsp;&nbsp; </a><i> {{matter}}</i>{{dispDate createdAt}} </p>
{{/if}}
{{#if equals type 'reported message'}}
<p class="alert {{#if hasBeenSeen}} {{else}} markAsRead alert-info{{/if}}"><i class="fas {{icon}}" aria-hidden="true"> </i> {{#if isActorAdmin actor.id}} {{actor.username}} {{else}} <a href="{{pathFor 'user by id'}}/{{actor.id}}"> {{actor.username}} </a> {{/if}} {{action}} <a href="{{pathFor 'user by id'}}/{{subject.id}}"> {{subject.username}}'s </a> message <a href="#"> <b>{{message.body}}</b> &nbsp;&nbsp; </a><i> {{matter}}</i>{{dispDate createdAt}} </p>
{{/if}}
{{#if equals type 'hangout edit'}}
<p class="alert {{#if hasBeenSeen}} {{else}} markAsRead alert-info{{/if}}"><i class="fas {{icon}}" aria-hidden="true"> </i> {{#if isActorAdmin actorId}} {{actorUsername}} {{else}} <a href="{{pathFor 'user by id'}}/{{actorId}}"> {{actorUsername}} </a> {{/if}} {{action}} <a href="{{pathFor 'user by id'}}/{{subjectId}}"> {{subjectUsername}}'s </a> <a href="{{pathFor 'hangout'}}/{{hangoutId}}"> hangout </a><i>. </i> {{dispDate createdAt}} </p>
{{/if}}
Expand Down
10 changes: 2 additions & 8 deletions client/templates/comments/comment_box.js
Expand Up @@ -115,10 +115,7 @@ Template.commentBox.events({
if (userId && !_.includes(this.upvotes, userId)) {
//checking if user has already voted for other category if true then switching
if (userId && _.includes(this.downvotes, userId)) {
Meteor.call("voteSwitching", commentId, "downvote-to-upvote", function(
error,
result
) {
Meteor.call("voteSwitching", commentId, "downvote-to-upvote", function(error, result) {
if (error) {
console.log("error", error);
}
Expand Down Expand Up @@ -147,10 +144,7 @@ Template.commentBox.events({
if (userId && !_.includes(this.downvotes, userId)) {
//checking if user has already voted for other category if true then switching
if (userId && _.includes(this.upvotes, userId)) {
Meteor.call("voteSwitching", commentId, "upvote-to-downvote", function(
error,
result
) {
Meteor.call("voteSwitching", commentId, "upvote-to-downvote", function(error, result) {
if (error) {
console.log("error", error);
}
Expand Down
19 changes: 3 additions & 16 deletions client/templates/discussion/discussion_card.js
Expand Up @@ -19,25 +19,12 @@ Template.discussionCard.events({
swal.disableButtons();
if (result.value) {
Meteor.call("discussions.remove", data, function(error) {
swal(
"Poof!",
"Your Discussion has been successfully deleted!",
"success"
);
swal("Poof!", "Your Discussion has been successfully deleted!", "success");
});
} else if (
result.dismiss === "cancel" ||
result.dismiss === "esc" ||
result.dismiss === "overlay"
) {
} else if (result.dismiss === "cancel" || result.dismiss === "esc" || result.dismiss === "overlay") {
swal("Phew!", "No changes made", "info");
} else {
swal(
"Oops! Something went wrong",
error.error,
+"\n Try again",
"error"
);
swal("Oops! Something went wrong", error.error, +"\n Try again", "error");
}
});
},
Expand Down
19 changes: 3 additions & 16 deletions client/templates/discussion/discussion_item.js
Expand Up @@ -19,25 +19,12 @@ Template.discussionItem.events({
swal.disableButtons();
if (result.value) {
Meteor.call("discussions.remove", data, function(error) {
swal(
"Poof!",
"Your Discussion has been successfully deleted!",
"success"
);
swal("Poof!", "Your Discussion has been successfully deleted!", "success");
});
} else if (
result.dismiss === "cancel" ||
result.dismiss === "esc" ||
result.dismiss === "overlay"
) {
} else if (result.dismiss === "cancel" || result.dismiss === "esc" || result.dismiss === "overlay") {
swal("Phew!", "No changes made", "info");
} else {
swal(
"Oops! Something went wrong",
error.error,
+"\n Try again",
"error"
);
swal("Oops! Something went wrong", error.error, +"\n Try again", "error");
}
}); // sweetAlert2
},
Expand Down
19 changes: 3 additions & 16 deletions client/templates/discussion/discussion_response_card.js
Expand Up @@ -20,25 +20,12 @@ Template.discussionResponseCard.events({
swal.disableButtons();
if (result.value) {
Meteor.call("discussionResponses.remove", data, function(error) {
swal(
"Poof!",
"Your Discussion has been successfully deleted!",
"success"
);
swal("Poof!", "Your Discussion has been successfully deleted!", "success");
});
} else if (
result.dismiss === "cancel" ||
result.dismiss === "esc" ||
result.dismiss === "overlay"
) {
} else if (result.dismiss === "cancel" || result.dismiss === "esc" || result.dismiss === "overlay") {
swal("Phew!", "No changes made", "info");
} else {
swal(
"Oops! Something went wrong",
error.error,
+"\n Try again",
"error"
);
swal("Oops! Something went wrong", error.error, +"\n Try again", "error");
}
});
},
Expand Down
22 changes: 5 additions & 17 deletions client/templates/hangout/hangout-clone.js
Expand Up @@ -14,8 +14,7 @@ Template.cloneHangoutModal.onRendered(function() {
});

templateInstance.editor.setContents(
templateInstance.data.hangout.data.description_in_quill_delta ||
templateInstance.data.hangout.data.description
templateInstance.data.hangout.data.description_in_quill_delta || templateInstance.data.hangout.data.description
);

//instructions for start date time picker
Expand All @@ -39,18 +38,11 @@ Template.cloneHangoutModal.onRendered(function() {
let studyGroupsKeys = [];

Object.entries(roles).forEach(([key, value]) => {
if (
value.includes("owner") ||
value.includes("admin") ||
(value.includes("moderator") && key !== "CB")
) {
if (value.includes("owner") || value.includes("admin") || (value.includes("moderator") && key !== "CB")) {
studyGroupsKeys.push(key);
} else if (value.includes("member") && key !== "CB") {
// check for exempt_from_default_permission
if (
StudyGroups.findOne({ _id: key }) &&
StudyGroups.findOne({ _id: key }).exempt_from_default_permission
) {
if (StudyGroups.findOne({ _id: key }) && StudyGroups.findOne({ _id: key }).exempt_from_default_permission) {
studyGroupsKeys.push(key);
}
}
Expand Down Expand Up @@ -86,9 +78,7 @@ Template.cloneHangoutModal.events({
var templateInstance = Template.instance();

const topic = $("#topic").val();
const description = QuillEditor.generatePlainTextFromDeltas(
templateInstance.editor.getContents()
);
const description = QuillEditor.generatePlainTextFromDeltas(templateInstance.editor.getContents());
const description_in_quill_delta = templateInstance.editor.getContents();
const start = $("#start-date-time").val();
const startDate = new Date(start);
Expand All @@ -97,9 +87,7 @@ Template.cloneHangoutModal.events({
const end = new Date(startDate.getTime() + 1000 * 60 * duration);
const type = $('input[name="hangout-type"]:checked').val();
const groupId = $(".study-group-single").val();
const externalCheckbox = $('input[name="externalCheckbox"]').prop(
"checked"
);
const externalCheckbox = $('input[name="externalCheckbox"]').prop("checked");
const externalButtonText = $('input[name="externalButtonText"]').val();
const externalURL = $('input[name="externalURL"]').val();

Expand Down
11 changes: 3 additions & 8 deletions client/templates/hangout/hangout-edit.js
Expand Up @@ -11,8 +11,7 @@ Template.editHangoutModal.rendered = function() {
});

templateInstance.editor.setContents(
templateInstance.data.hangout.data.description_in_quill_delta ||
templateInstance.data.hangout.data.description
templateInstance.data.hangout.data.description_in_quill_delta || templateInstance.data.hangout.data.description
);

//instructions for start date time picker
Expand All @@ -36,19 +35,15 @@ Template.editHangoutModal.events({
"click #edit-hangout": function() {
var templateInstance = Template.instance();
const topic = $("#topic").val();
const description = QuillEditor.generatePlainTextFromDeltas(
templateInstance.editor.getContents()
);
const description = QuillEditor.generatePlainTextFromDeltas(templateInstance.editor.getContents());
const description_in_quill_delta = templateInstance.editor.getContents();
const start = $("#start-date-time").val();
const startDate = new Date(start);
// If date was not set, return 24 hours later. Else, return end date time
const duration = Number($("#end-date-time").val()) || 1440;
const end = new Date(startDate.getTime() + 1000 * 60 * duration);
const type = $('input[name="hangout-type"]:checked').val();
const externalCheckbox = $('input[name="externalCheckbox"]').prop(
"checked"
);
const externalCheckbox = $('input[name="externalCheckbox"]').prop("checked");
const externalButtonText = $('input[name="externalButtonText"]').val();
const externalURL = $('input[name="externalURL"]').val();

Expand Down
20 changes: 5 additions & 15 deletions client/templates/hangout/hangout-frame.js
@@ -1,8 +1,6 @@
Template.hangoutFrame.onCreated(function() {
let instance = this;
instance.room = new ReactiveVar(
`cb${instance.data._id || instance.data.hroom}`
);
instance.room = new ReactiveVar(`cb${instance.data._id || instance.data.hroom}`);

instance.autorun(() => {
instance.subscribe("hangoutParticipants", instance.room.get());
Expand Down Expand Up @@ -43,9 +41,7 @@ Template.hangoutFrame.onCreated(function() {

$("[id^=" + "jitsiConference" + "]").css("width", "100%");
//only show the launch hangout button if Jitsi is not loaded
$("[id^=" + "jitsiConference" + "]").length == 1
? $(".load-hangout").hide()
: $("#load-hangout").show();
$("[id^=" + "jitsiConference" + "]").length == 1 ? $(".load-hangout").hide() : $("#load-hangout").show();

instance.api.on("readyToClose", () => {
Bert.alert({
Expand Down Expand Up @@ -80,10 +76,7 @@ Template.hangoutFrame.onRendered(function() {
* Chrome or Firefox
*/

if (
(!!window.chrome && !!window.chrome.webstore) ||
typeof InstallTrigger !== "undefined"
) {
if ((!!window.chrome && !!window.chrome.webstore) || typeof InstallTrigger !== "undefined") {
//console.log('using firefox or chrome')
$("p.chrome-firefox-warning").hide();
} else {
Expand All @@ -92,17 +85,14 @@ Template.hangoutFrame.onRendered(function() {
}

//Google Hangout support
$("head").append(
'<script src="https://apis.google.com/js/platform.js" async defer></script>'
);
$("head").append('<script src="https://apis.google.com/js/platform.js" async defer></script>');
});

Template.hangoutFrame.events({
"click .load-hangout": function(event, template) {
const data = {
room: this._id || template.data.hroom,
username:
(Meteor.user() && Meteor.user().username) || template.data.huser,
username: (Meteor.user() && Meteor.user().username) || template.data.huser,
type: template.data.htype || this.type,
avatar: template.data.havatar || Meteor.user().profile.avatar.default
};
Expand Down
24 changes: 5 additions & 19 deletions client/templates/hangout/hangout-modal.js
Expand Up @@ -55,18 +55,11 @@ Template.createHangoutModal.onRendered(function() {
let studyGroupsKeys = [];

Object.entries(roles).forEach(([key, value]) => {
if (
value.includes("owner") ||
value.includes("admin") ||
(value.includes("moderator") && key !== "CB")
) {
if (value.includes("owner") || value.includes("admin") || (value.includes("moderator") && key !== "CB")) {
studyGroupsKeys.push(key);
} else if (value.includes("member") && key !== "CB") {
// check for exempt_from_default_permission
if (
StudyGroups.findOne({ _id: key }) &&
StudyGroups.findOne({ _id: key }).exempt_from_default_permission
) {
if (StudyGroups.findOne({ _id: key }) && StudyGroups.findOne({ _id: key }).exempt_from_default_permission) {
studyGroupsKeys.push(key);
}
}
Expand All @@ -83,10 +76,7 @@ Template.createHangoutModal.onRendered(function() {
data: studyGroups
});

if (
typeof instance.studyGroupId !== "undefined" &&
instance.studyGroupId !== ""
) {
if (typeof instance.studyGroupId !== "undefined" && instance.studyGroupId !== "") {
instance
.$(".study-group-single")
.val(instance.studyGroupId)
Expand All @@ -103,19 +93,15 @@ Template.createHangoutModal.events({
"click #create-hangout": function(e, template) {
const templateInstance = template;
const topic = $("#topic").val();
const description = QuillEditor.generatePlainTextFromDeltas(
templateInstance.editor.getContents()
);
const description = QuillEditor.generatePlainTextFromDeltas(templateInstance.editor.getContents());
const description_in_quill_delta = templateInstance.editor.getContents();
const start = $("#start-date-time").val();
const startDate = new Date(start);
// If date was not set, return 24 hours later. Else, return end date time
const duration = Number($("#end-date-time").val()) || 1440;
const end = new Date(startDate.getTime() + 1000 * 60 * duration);
const groupId = $(".study-group-single").val();
const externalCheckbox = $('input[name="externalCheckbox"]').prop(
"checked"
);
const externalCheckbox = $('input[name="externalCheckbox"]').prop("checked");
const externalButtonText = $('input[name="externalButtonText"]').val();
const externalURL = $('input[name="externalURL"]').val();

Expand Down
4 changes: 1 addition & 3 deletions client/templates/hangout/hangout.js
@@ -1,9 +1,7 @@
import QuillEditor from "../../libs/QuillEditor";

Meteor.startup(function() {
$("head").append(
'<link href="https://cdn.quilljs.com/1.0.3/quill.snow.css" rel="stylesheet">'
);
$("head").append('<link href="https://cdn.quilljs.com/1.0.3/quill.snow.css" rel="stylesheet">');
//$('head').append('<script src="https://meet.jit.si/external_api.js"></script>');
});

Expand Down

0 comments on commit c8463e0

Please sign in to comment.