From 411714491b759b55af84fb379aec1baa8c8662da Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 2 Nov 2018 21:07:21 -0600 Subject: [PATCH 001/171] Add notification component --- .../assets/js/components/notifications.js | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 resources/assets/js/components/notifications.js diff --git a/resources/assets/js/components/notifications.js b/resources/assets/js/components/notifications.js new file mode 100644 index 00000000..3cf40925 --- /dev/null +++ b/resources/assets/js/components/notifications.js @@ -0,0 +1,73 @@ +$(document).ready(function() { + +$('.nav-link.nav-notification').on('click', function(e) { + e.preventDefault(); + let el = $(this); + let container = $('.navbar .nav-notification-dropdown'); + if(pixelfed.notifications) { + return; + } + axios.get('/api/v2/notifications') + .then((res) => { + $('.nav-notification-dropdown .loader').hide(); + let data = res.data; + data.forEach(function(v, k) { + let action = v.action; + let notification = $('
  • ').addClass('dropdown-item py-3') + .attr('style', 'border-bottom: 1px solid #ccc') + switch(action) { + case 'comment': + let avatar = $('') + .attr('class', 'notification-icon pr-3'); + let avatarImg = $('') + .attr('width', '32px') + .attr('height', '32px') + .attr('class', 'rounded-circle') + .attr('style', 'border: 1px solid #ccc') + .attr('src', v.actor.avatar); + avatar = avatar.append(avatarImg); + + let text = $('') + .attr('href', v.url) + .attr('class', 'font-weight-bold') + .html(v.rendered); + + notification.append(avatar); + notification.append(text); + container.append(notification); + break; + + case 'follow': + avatar = $('') + .attr('class', 'notification-icon pr-3'); + avatarImg = $('') + .attr('width', '32px') + .attr('height', '32px') + .attr('class', 'rounded-circle') + .attr('style', 'border: 1px solid #ccc') + .attr('src', v.actor.avatar); + avatar = avatar.append(avatarImg); + + text = $('') + .attr('href', v.url) + .attr('class', 'font-weight-bold') + .html(v.rendered); + + notification.append(avatar); + notification.append(text); + container.append(notification); + break; + } + }); + let all = $('') + .attr('class', 'dropdown-item py-3 text-center text-primary font-weight-bold') + .attr('href', '/account/activity') + .text('View all notifications'); + container.append(all); + pixelfed.notifications = true; + }).catch((err) => { + $('.nav-notification-dropdown .loader').addClass('font-weight-bold').text('Something went wrong. Please try again later.'); + }); +}); + +}); \ No newline at end of file From 4941a24a3ffc95bff5d80e29f7446769a0da8f6d Mon Sep 17 00:00:00 2001 From: Daniel Supernault Date: Fri, 2 Nov 2018 21:08:15 -0600 Subject: [PATCH 002/171] Update PostComments component --- .../assets/js/components/PostComments.vue | 96 ++++++++----------- 1 file changed, 40 insertions(+), 56 deletions(-) diff --git a/resources/assets/js/components/PostComments.vue b/resources/assets/js/components/PostComments.vue index 25ed738f..7b62c54f 100644 --- a/resources/assets/js/components/PostComments.vue +++ b/resources/assets/js/components/PostComments.vue @@ -1,69 +1,26 @@ - -