Added dedicated notifications page.

This commit is contained in:
DebaucheryLibrarian
2021-05-09 00:23:10 +02:00
parent 3f55b90ab8
commit 83ed793e39
17 changed files with 220 additions and 77 deletions

View File

@@ -29,7 +29,7 @@ function initUiActions(store, _router) {
localStorage.setItem('sfw', sfw);
}
async function fetchNotifications({ commit }) {
async function fetchNotifications(_context, { page = 1, limit = 10 } = {}) {
if (!store.state.auth.user) {
return [];
}
@@ -38,44 +38,50 @@ function initUiActions(store, _router) {
query Notifications(
$hasAuth: Boolean!
$userId: Int
$limit: Int = 10
$offset: Int = 0
) {
notifications(
first: 10
notifications: notificationsConnection(
first: $limit
offset: $offset
orderBy: CREATED_AT_DESC
) {
id
sceneId
userId
seen
createdAt
scene {
${releaseFields}
}
alert {
tags: alertsTags {
tag {
id
name
slug
}
nodes {
id
sceneId
userId
seen
createdAt
scene {
${releaseFields}
}
actors: alertsActors {
actor {
id
name
slug
alert {
tags: alertsTags {
tag {
id
name
slug
}
}
}
entity: alertsEntityByAlertId {
entity {
id
name
slug
independent
actors: alertsActors {
actor {
id
name
slug
}
}
entity: alertsEntityByAlertId {
entity {
id
name
slug
independent
}
}
}
}
}
totalCount
}
unseenNotifications: notificationsConnection(
filter: { seen: { equalTo: false } }
) {
@@ -85,15 +91,15 @@ function initUiActions(store, _router) {
`, {
hasAuth: !!store.state.auth.user,
userId: store.state.auth.user?.id,
limit,
offset: (page - 1) * limit,
});
const curatedNotifications = notifications.map(notification => curateNotification(notification));
commit('setNotifications', curatedNotifications);
commit('setUnseenNotificationsCount', unseenNotifications.totalCount);
const curatedNotifications = notifications.nodes.map(notification => curateNotification(notification));
return {
notifications: curatedNotifications,
totalCount: notifications.totalCount,
unseenCount: unseenNotifications.totalCount,
};
}
@@ -207,6 +213,8 @@ function initUiActions(store, _router) {
userId: store.state.auth.user?.id,
});
console.log(res.results);
return {
releases: res?.results.map(result => curateRelease(result.release)) || [],
actors: res?.actors.map(actor => curateActor(actor)) || [],