Improved alert notifications.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { graphql } from '../api';
|
||||
import { releaseFields, actorStashesFields } from '../fragments';
|
||||
import { curateRelease, curateActor } from '../curate';
|
||||
import { curateRelease, curateActor, curateNotification } from '../curate';
|
||||
|
||||
function initUiActions(store, _router) {
|
||||
function setTagFilter({ commit }, filter) {
|
||||
@@ -29,6 +29,53 @@ function initUiActions(store, _router) {
|
||||
localStorage.setItem('sfw', sfw);
|
||||
}
|
||||
|
||||
async function fetchNotifications({ commit }) {
|
||||
if (!store.state.auth.user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const { notifications } = await graphql(`
|
||||
query Notifications(
|
||||
$hasAuth: Boolean!
|
||||
$userId: Int
|
||||
) {
|
||||
notifications {
|
||||
id
|
||||
sceneId
|
||||
userId
|
||||
createdAt
|
||||
scene {
|
||||
${releaseFields}
|
||||
}
|
||||
alert {
|
||||
tags: alertsTags {
|
||||
tag {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
}
|
||||
actors: alertsActors {
|
||||
actor {
|
||||
id
|
||||
name
|
||||
slug
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`, {
|
||||
hasAuth: !!store.state.auth.user,
|
||||
userId: store.state.auth.user?.id,
|
||||
});
|
||||
|
||||
const curatedNotifications = notifications.map(notification => curateNotification(notification));
|
||||
|
||||
commit('setNotifications', curatedNotifications);
|
||||
return curatedNotifications;
|
||||
}
|
||||
|
||||
async function search({ _commit }, { query, limit = 20 }) {
|
||||
const res = await graphql(`
|
||||
query SearchReleases(
|
||||
@@ -176,6 +223,7 @@ function initUiActions(store, _router) {
|
||||
setBatch,
|
||||
setSfw,
|
||||
setTheme,
|
||||
fetchNotifications,
|
||||
fetchStats,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user