mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-16 22:27:26 +01:00
* 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
137 lines
4.2 KiB
JavaScript
137 lines
4.2 KiB
JavaScript
import Store from 'client/libs/store';
|
|
import deepFreeze from 'client/libs/deepFreeze';
|
|
import content from 'common/script/content/index';
|
|
import * as commonConstants from 'common/script/constants';
|
|
import { DAY_MAPPING } from 'common/script/cron';
|
|
import { asyncResourceFactory } from 'client/libs/asyncResource';
|
|
import axios from 'axios';
|
|
import moment from 'moment';
|
|
|
|
import actions from './actions';
|
|
import getters from './getters';
|
|
|
|
const IS_TEST = process.env.NODE_ENV === 'test'; // eslint-disable-line no-process-env
|
|
|
|
// Load user auth parameters and determine if it's logged in
|
|
// before trying to load data
|
|
let isUserLoggedIn = false;
|
|
let browserTimezoneOffset = moment().zone(); // eg, 240 - this will be converted on server as -(offset/60)
|
|
axios.defaults.headers.common['x-client'] = 'habitica-web';
|
|
|
|
let AUTH_SETTINGS = localStorage.getItem('habit-mobile-settings');
|
|
|
|
if (AUTH_SETTINGS) {
|
|
AUTH_SETTINGS = JSON.parse(AUTH_SETTINGS);
|
|
|
|
if (AUTH_SETTINGS.auth && AUTH_SETTINGS.auth.apiId && AUTH_SETTINGS.auth.apiToken) {
|
|
axios.defaults.headers.common['x-api-user'] = AUTH_SETTINGS.auth.apiId;
|
|
axios.defaults.headers.common['x-api-key'] = AUTH_SETTINGS.auth.apiToken;
|
|
|
|
axios.defaults.headers.common['x-user-timezoneOffset'] = browserTimezoneOffset;
|
|
|
|
isUserLoggedIn = true;
|
|
}
|
|
}
|
|
|
|
const i18nData = window && window['habitica-i18n'];
|
|
|
|
let availableLanguages = [];
|
|
let selectedLanguage = {};
|
|
|
|
if (i18nData) {
|
|
availableLanguages = i18nData.availableLanguages;
|
|
selectedLanguage = i18nData.language;
|
|
}
|
|
|
|
// Export a function that generates the store and not the store directly
|
|
// so that we can regenerate it multiple times for testing, when not testing
|
|
// always export the same route
|
|
|
|
let existingStore;
|
|
export default function () {
|
|
if (!IS_TEST && existingStore) return existingStore;
|
|
|
|
existingStore = new Store({
|
|
actions,
|
|
getters,
|
|
state: {
|
|
serverAppVersion: '',
|
|
title: 'Habitica',
|
|
isUserLoggedIn,
|
|
isUserLoaded: false, // Means the user and the user's tasks are ready
|
|
isAmazonReady: false, // Whether the Amazon Payments lib can be used
|
|
user: asyncResourceFactory(),
|
|
credentials: isUserLoggedIn ? {
|
|
API_ID: AUTH_SETTINGS.auth.apiId,
|
|
API_TOKEN: AUTH_SETTINGS.auth.apiToken,
|
|
} : {},
|
|
// store the timezone offset in case it's different than the one in
|
|
// user.preferences.timezoneOffset and change it after the user is synced
|
|
// in app.vue
|
|
browserTimezoneOffset,
|
|
tasks: asyncResourceFactory(), // user tasks
|
|
completedTodosStatus: 'NOT_LOADED',
|
|
party: asyncResourceFactory(),
|
|
partyMembers: asyncResourceFactory(),
|
|
shops: {
|
|
market: asyncResourceFactory(),
|
|
quests: asyncResourceFactory(),
|
|
seasonal: asyncResourceFactory(),
|
|
'time-travelers': asyncResourceFactory(),
|
|
},
|
|
myGuilds: [],
|
|
groupFormOptions: {
|
|
creatingParty: false,
|
|
groupId: '',
|
|
},
|
|
avatarEditorOptions: {
|
|
editingUser: false,
|
|
startingPage: '',
|
|
subPage: '',
|
|
},
|
|
challengeOptions: {
|
|
cloning: false,
|
|
tasksToClone: {},
|
|
workingChallenge: {},
|
|
},
|
|
editingGroup: {}, // @TODO move to local state
|
|
// content data, frozen to prevent Vue from modifying it since it's static and never changes
|
|
// @TODO apply freezing to the entire codebase (the server) and not only to the client side?
|
|
// NOTE this takes about 10-15ms on a fast computer
|
|
content: deepFreeze(content),
|
|
constants: deepFreeze({...commonConstants, DAY_MAPPING}),
|
|
i18n: deepFreeze({
|
|
availableLanguages,
|
|
selectedLanguage,
|
|
}),
|
|
hideHeader: false,
|
|
memberModalOptions: {
|
|
viewingMembers: [],
|
|
groupId: '',
|
|
challengeId: '',
|
|
group: {},
|
|
},
|
|
openedItemRows: [],
|
|
spellOptions: {
|
|
castingSpell: false,
|
|
spellDrawOpen: true,
|
|
},
|
|
profileOptions: {
|
|
startingPage: '',
|
|
},
|
|
gemModalOptions: {
|
|
startingPage: '',
|
|
},
|
|
profileUser: {},
|
|
upgradingGroup: {},
|
|
notificationStore: [],
|
|
modalStack: [],
|
|
equipmentDrawerOpen: true,
|
|
groupPlans: [],
|
|
isRunningYesterdailies: false,
|
|
},
|
|
});
|
|
|
|
return existingStore;
|
|
}
|