Fix notifications
This commit is contained in:
parent
334aa22362
commit
6b9d8042fe
|
@ -132,9 +132,12 @@
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$count = (int) $this->input->post('count');
|
||||||
|
$offset = (int) $this->input->post('offset');
|
||||||
|
|
||||||
$returnData = ['status' => 'success', 'notifications' => []];
|
$returnData = ['status' => 'success', 'notifications' => []];
|
||||||
|
|
||||||
$notifications = $this->NotificationModel->getUserNotifications($_SESSION['user']['ID']);
|
$notifications = $this->NotificationModel->getUserNotifications($_SESSION['user']['ID'], $count, $count * $offset);
|
||||||
$returnData['notifications'] = $notifications;
|
$returnData['notifications'] = $notifications;
|
||||||
|
|
||||||
echo json_encode($returnData);
|
echo json_encode($returnData);
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
// Mark as read
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function add(Notification $notification) {
|
private function add(Notification $notification) {
|
||||||
|
@ -115,6 +114,9 @@
|
||||||
case 'admin.feedback':
|
case 'admin.feedback':
|
||||||
$items[] = new \Notification\Admin\NewFeedbackNotification($item);
|
$items[] = new \Notification\Admin\NewFeedbackNotification($item);
|
||||||
break;
|
break;
|
||||||
|
case 'admin.reportedPost':
|
||||||
|
$items[] = new \Notification\Users\PostReportNotification($item);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$groups[] = new NotificationGroup($items, $group['count']);
|
$groups[] = new NotificationGroup($items, $group['count']);
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
public function __get($attribute)
|
public function __get($attribute)
|
||||||
{
|
{
|
||||||
return $this->notifications[0]->{$attribute};
|
return !empty($this->notifications) ? $this->notifications[0]->{$attribute} : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function __call($name, $arguments)
|
public function __call($name, $arguments)
|
||||||
|
|
|
@ -90,7 +90,9 @@
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="notificationMenuButton" id="notificationMenu">
|
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="notificationMenuButton" id="notificationMenu">
|
||||||
<div class="list-group list-group-flush">
|
<div class="list-group list-group-flush">
|
||||||
|
<div class="text-center">
|
||||||
|
<i class="fa fa-cog fa-spin fa-4x my-4"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -291,18 +291,23 @@ $('#notificationMenuButton').click(() => {
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
loadNotificationsAsync();
|
loadNotificationsAsync();
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
error: console.log
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const notificationCount = 5;
|
||||||
|
let notificationOffset = 0;
|
||||||
|
|
||||||
function loadNotificationsAsync() {
|
function loadNotificationsAsync() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/Main/getNotifications',
|
url: '/Main/getNotifications',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
count: notificationCount,
|
||||||
|
offset: notificationOffset
|
||||||
|
},
|
||||||
beforeSend: () => {
|
beforeSend: () => {
|
||||||
$('#notificationMenu').prepend('<div class="text-center"><i class="fa fa-cog fa-spin fa-4x my-4"></i></div>');
|
$('#notificationMenu').find('.fa').removeClass('fa-frown text-danger').addClass('fa-spin fa-cog');
|
||||||
$('#notificationMenu').find('.list-group').empty();
|
|
||||||
},
|
},
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
$('#notificationMenu').find('.text-center').remove();
|
$('#notificationMenu').find('.text-center').remove();
|
||||||
|
@ -325,9 +330,12 @@ function loadNotificationsAsync() {
|
||||||
$('#notificationCount').text(unread.length);
|
$('#notificationCount').text(unread.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
notificationOffset++;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: console.log
|
error: () => {
|
||||||
|
$('#notificationMenu').find('.fa').removeClass('fa-spin fa-cog').addClass('fa-frown text-danger');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
function showFullPost(uuid, username) {
|
function showFullPost(uuid, username) {
|
||||||
console.log(uuid, username);
|
|
||||||
let defaultUrl = window.location.pathname;
|
let defaultUrl = window.location.pathname;
|
||||||
if(window.location.pathname.indexOf('user') === -1)
|
if(window.location.pathname.indexOf('user') === -1)
|
||||||
defaultUrl += window.location.search;
|
defaultUrl += window.location.search;
|
||||||
|
@ -7,8 +6,9 @@ function showFullPost(uuid, username) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: "/user/single_post_data/" + username + "/" + uuid,
|
url: "/user/single_post_data/" + username + "/" + uuid,
|
||||||
beforeSend: () => {
|
beforeSend: () => {
|
||||||
const origin = encodeURI(btoa(window.location.href));
|
const origin = encodeURI(btoa(window.location.href.split('/post')[0]));
|
||||||
window.history.pushState('', '', '/user/' + username + '/post/' + uuid + '?o=' + origin);
|
window.history.pushState('', '', '/user/' + username + '/post/' + uuid + '?o=' + origin);
|
||||||
|
|
||||||
$('body').append(`
|
$('body').append(`
|
||||||
<div class="modal fade postFullviewModal" role="dialog" tabindex="-1" id="postFullviewModal">
|
<div class="modal fade postFullviewModal" role="dialog" tabindex="-1" id="postFullviewModal">
|
||||||
<div class="modal-dialog modal-lg" role="document">
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
@ -32,17 +32,13 @@ function showFullPost(uuid, username) {
|
||||||
modal.modal('show');
|
modal.modal('show');
|
||||||
|
|
||||||
modal.on('hidden.bs.modal', () => {
|
modal.on('hidden.bs.modal', () => {
|
||||||
console.log('test');
|
|
||||||
$('.postFullviewModal').remove();
|
$('.postFullviewModal').remove();
|
||||||
|
window.history.replaceState('', '', defaultUrl);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
$('#postFullviewModal .modal-body').empty().append(data);
|
$('#postFullviewModal .modal-body').empty().append(data);
|
||||||
registerPostEvents();
|
registerPostEvents();
|
||||||
|
|
||||||
$('#postFullviewModal').on('hide.bs.modal', (e) => {
|
|
||||||
window.history.replaceState('', '', defaultUrl);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue
Block a user