33b249d078
* Added initial bailey api
* wip
* implement new panel header
* Fixed lint
* add ability to mark notification as seen
* add notification count, remove top badge from user and add ability to mark multiple notifications as seen
* add support dismissall and mark all as read
* do not dismiss actionable notif
* mark as seen when menu is opened instead of closed
* implement ordering, list of actionable notifications
* add groups messages and fix badges count
* add notifications for received cards
* send card received notification to target not sender
* rename notificaion field
* fix integration tests
* mark cards notifications as read and update tests
* add mystery items notifications
* add unallocated stats points notifications
* fix linting
* simplify code
* refactoring and fixes
* fix dropdown opening
* start splitting notifications into their own component
* add notifications for inbox messages
* fix unit tests
* fix default buttons styles
* add initial bailey support
* add title and tests to new stuff notification
* add notification if a group task needs more work
* add tests and fixes for marking a task as needing more work
* make sure user._v is updated
* remove console.log
* notification: hover status and margins
* start styling notifications, add separate files and basic functionalities
* fix tests
* start adding mystery items notification
* wip card notification
* fix cards text
* initial implementation inbox messages
* initial implementation group messages
* disable inbox notifications until mobile is ready
* wip group chat messages
* finish mystery and card notifications
* add bailey notification and fix a lot of stuff
* start adding guilds and parties invitations
* misc invitation fixes
* fix lint issues
* remove old code and add key to notifications
* fix tests
* remove unused code
* add link for public guilds invite
* starts to implement needs work notification design and feature
* fixes to needs work, add group task approved notification
* finish needs work feature
* lots of fixes
* implement quest notification
* bailey fixes and static page
* routing fixes
* fixes # this.$store.dispatch(guilds:join, {groupId: group.id, type: party});
* read notifications on click
* chat notifications
* fix tests for chat notifications
* fix chat notification test
* fix tests
* fix tests (again)
* try awaiting
* remove only
* more sleep
* add bailey tests
* fix icons alignment
* fix issue with multiple points notifications
* remove merge code
* fix rejecting guild invitation
* make remove area bigger
* fix error with notifications and add migration
* fix migration
* fix typos
* add cleanup migration too
* notifications empty state, new counter color, fix marking messages as seen in guilds
* fixes
* add image and install correct packages
* fix mongoose version
* update bailey
* typo
* make sure chat is marked as read after other requests
134 lines
3.7 KiB
JavaScript
134 lines
3.7 KiB
JavaScript
import { loadAsyncResource } from 'client/libs/asyncResource';
|
|
import setProps from 'lodash/set';
|
|
import axios from 'axios';
|
|
|
|
import { togglePinnedItem as togglePinnedItemOp } from 'common/script/ops/pinnedGearUtils';
|
|
import changeClassOp from 'common/script/ops/changeClass';
|
|
import disableClassesOp from 'common/script/ops/disableClasses';
|
|
|
|
|
|
export function fetch (store, options = {}) { // eslint-disable-line no-shadow
|
|
return loadAsyncResource({
|
|
store,
|
|
path: 'user',
|
|
url: '/api/v3/user',
|
|
deserialize (response) {
|
|
return response.data.data;
|
|
},
|
|
forceLoad: options.forceLoad,
|
|
});
|
|
}
|
|
|
|
export async function set (store, changes) {
|
|
const user = store.state.user.data;
|
|
|
|
for (let key in changes) {
|
|
if (key === 'tags') {
|
|
// Keep challenge and group tags
|
|
const oldTags = user.tags.filter(t => {
|
|
return t.group;
|
|
});
|
|
|
|
user.tags = changes[key].concat(oldTags);
|
|
|
|
// Remove deleted tags from tasks
|
|
const userTasksByType = (await store.dispatch('tasks:fetchUserTasks')).data; // eslint-disable-line no-await-in-loop
|
|
|
|
Object.keys(userTasksByType).forEach(taskType => {
|
|
userTasksByType[taskType].forEach(task => {
|
|
const tagsIndexesToRemove = [];
|
|
|
|
task.tags.forEach((tagId, tagIndex) => {
|
|
if (user.tags.find(tag => tag.id === tagId)) return; // eslint-disable-line max-nested-callbacks
|
|
tagsIndexesToRemove.push(tagIndex);
|
|
});
|
|
|
|
tagsIndexesToRemove.forEach(i => task.tags.splice(i, 1));
|
|
});
|
|
});
|
|
} else {
|
|
setProps(user, key, changes[key]);
|
|
}
|
|
}
|
|
|
|
axios.put('/api/v3/user', changes);
|
|
// TODO
|
|
// .then((res) => console.log('set', res))
|
|
// .catch((err) => console.error('set', err));
|
|
}
|
|
|
|
export async function sleep () {
|
|
let response = await axios.post('/api/v3/user/sleep');
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function addWebhook (store, payload) {
|
|
let response = await axios.post('/api/v3/user/webhook', payload.webhookInfo);
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function updateWebhook (store, payload) {
|
|
let response = await axios.put(`/api/v3/user/webhook/${payload.webhook.id}`, payload.webhook);
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function deleteWebhook (store, payload) {
|
|
let response = await axios.delete(`/api/v3/user/webhook/${payload.webhook.id}`);
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function changeClass (store, params) {
|
|
const user = store.state.user.data;
|
|
|
|
changeClassOp(user, params);
|
|
user.flags.classSelected = true;
|
|
|
|
let response = await axios.post(`/api/v3/user/change-class?class=${params.query.class}`);
|
|
return response.data.data;
|
|
}
|
|
|
|
export async function disableClasses (store) {
|
|
const user = store.state.user.data;
|
|
|
|
disableClassesOp(user);
|
|
let response = await axios.post('/api/v3/user/disable-classes');
|
|
return response.data.data;
|
|
}
|
|
|
|
export function togglePinnedItem (store, params) {
|
|
const user = store.state.user.data;
|
|
|
|
let addedItem = togglePinnedItemOp(user, params);
|
|
|
|
axios.get(`/api/v3/user/toggle-pinned-item/${params.type}/${params.path}`);
|
|
// TODO
|
|
// .then((res) => console.log('equip', res))
|
|
// .catch((err) => console.error('equip', err));
|
|
|
|
return addedItem;
|
|
}
|
|
|
|
export function castSpell (store, params) {
|
|
let spellUrl = `/api/v3/user/class/cast/${params.key}`;
|
|
|
|
if (params.targetId) spellUrl += `?targetId=${params.targetId}`;
|
|
|
|
return axios.post(spellUrl);
|
|
}
|
|
|
|
export function openMysteryItem () {
|
|
return axios.post('/api/v3/user/open-mystery-item');
|
|
}
|
|
|
|
export function newStuffLater () {
|
|
return axios.post('/api/v3/news/tell-me-later');
|
|
}
|
|
|
|
export async function rebirth () {
|
|
let result = await axios.post('/api/v3/user/rebirth');
|
|
|
|
window.location.reload(true);
|
|
|
|
return result;
|
|
}
|