2017-03-18 17:33:08 +00:00
|
|
|
import { loadAsyncResource } from 'client/libs/asyncResource';
|
Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette
* add secondary menu component and style it
* add box shadow to secondary menu
* misc css, fixes for secondary menu
* client: add equipment page with grouping, css: add some styles
* add typography
* more equipment
* stable: fix linting
* equipment: add styles (lots of general styles too)
* remove duplicate google fonts loading
* add dropdowns
* design: white search input background, remove gray from items
* start adding drawer and selected indicator
* wip equipment
* fix equipment
* equipment: correctly bind new properties on items.gear.equipped
* equipment: fix vue binding. version 2
* equipment: fix vue binding. version 3
* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed
* checkboxes and radio buttons
* correctly renders selected items in first postion during the first render
* add search
* general changes, constants part of app state, add popovers
* add toggle switch, rename css
* correct offset
* upgrade deps
* upgrade deps
* drawer and lot of other work
* update equipping mechanism
* finish equipment
* fix compilation and upgrade deps
* use v-show in place of v-if to fix ui issues
* v-show -> v-if
* fix linting in test/client
* fix es6 compilation in test/client
* fix babel compilation for tests
* fix groupsUtilities mixin tests
* client: buttons
* client: buttons: fix colors
* client: finish buttons and dropdowns
* upgrade bootstrap-vue, finish buttons and dropdowns
* fix tasks page layout
* misc fixes for buttons
* add textareas
* fix app menu
* add inputs
* fixes for toggleSwitch
* typography
* checkboxes and radio buttons
* add checkbox icon
* fix equip.js
* extract strings to newClient.json
* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active
* show "you have disabled your costume" error above the drawer items
* check errorMessage for null
* hide star if costume not enabled
* fix errorMessage (!errorMessage seems not to work for string)
* show minimize / expand icon - always centered by css
* drawer test
* drawer: fix centering on large screens
* fix show more button
* add margin when two dropdowns are next to each other
* adjust the page padding based on the drawer, misc fixes
* drawer fixes
2017-05-16 19:09:55 +00:00
|
|
|
import setProps from 'lodash/set';
|
|
|
|
|
import axios from 'axios';
|
2016-12-07 01:11:40 +00:00
|
|
|
|
2017-08-14 17:15:32 +00:00
|
|
|
import { togglePinnedItem as togglePinnedItemOp } from 'common/script/ops/pinnedGearUtils';
|
2017-08-22 22:59:18 +00:00
|
|
|
import changeClassOp from 'common/script/ops/changeClass';
|
|
|
|
|
import disableClassesOp from 'common/script/ops/disableClasses';
|
|
|
|
|
|
2017-09-07 12:16:39 +00:00
|
|
|
export function fetch (store, options = {}) { // eslint-disable-line no-shadow
|
2017-03-18 17:33:08 +00:00
|
|
|
return loadAsyncResource({
|
|
|
|
|
store,
|
|
|
|
|
path: 'user',
|
2018-06-21 19:25:27 +00:00
|
|
|
url: '/api/v4/user',
|
2017-03-18 17:33:08 +00:00
|
|
|
deserialize (response) {
|
|
|
|
|
return response.data.data;
|
|
|
|
|
},
|
2017-09-07 12:16:39 +00:00
|
|
|
forceLoad: options.forceLoad,
|
2017-03-18 17:33:08 +00:00
|
|
|
});
|
Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette
* add secondary menu component and style it
* add box shadow to secondary menu
* misc css, fixes for secondary menu
* client: add equipment page with grouping, css: add some styles
* add typography
* more equipment
* stable: fix linting
* equipment: add styles (lots of general styles too)
* remove duplicate google fonts loading
* add dropdowns
* design: white search input background, remove gray from items
* start adding drawer and selected indicator
* wip equipment
* fix equipment
* equipment: correctly bind new properties on items.gear.equipped
* equipment: fix vue binding. version 2
* equipment: fix vue binding. version 3
* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed
* checkboxes and radio buttons
* correctly renders selected items in first postion during the first render
* add search
* general changes, constants part of app state, add popovers
* add toggle switch, rename css
* correct offset
* upgrade deps
* upgrade deps
* drawer and lot of other work
* update equipping mechanism
* finish equipment
* fix compilation and upgrade deps
* use v-show in place of v-if to fix ui issues
* v-show -> v-if
* fix linting in test/client
* fix es6 compilation in test/client
* fix babel compilation for tests
* fix groupsUtilities mixin tests
* client: buttons
* client: buttons: fix colors
* client: finish buttons and dropdowns
* upgrade bootstrap-vue, finish buttons and dropdowns
* fix tasks page layout
* misc fixes for buttons
* add textareas
* fix app menu
* add inputs
* fixes for toggleSwitch
* typography
* checkboxes and radio buttons
* add checkbox icon
* fix equip.js
* extract strings to newClient.json
* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active
* show "you have disabled your costume" error above the drawer items
* check errorMessage for null
* hide star if costume not enabled
* fix errorMessage (!errorMessage seems not to work for string)
* show minimize / expand icon - always centered by css
* drawer test
* drawer: fix centering on large screens
* fix show more button
* add margin when two dropdowns are next to each other
* adjust the page padding based on the drawer, misc fixes
* drawer fixes
2017-05-16 19:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
2017-09-02 16:08:32 +00:00
|
|
|
export async function set (store, changes) {
|
Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette
* add secondary menu component and style it
* add box shadow to secondary menu
* misc css, fixes for secondary menu
* client: add equipment page with grouping, css: add some styles
* add typography
* more equipment
* stable: fix linting
* equipment: add styles (lots of general styles too)
* remove duplicate google fonts loading
* add dropdowns
* design: white search input background, remove gray from items
* start adding drawer and selected indicator
* wip equipment
* fix equipment
* equipment: correctly bind new properties on items.gear.equipped
* equipment: fix vue binding. version 2
* equipment: fix vue binding. version 3
* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed
* checkboxes and radio buttons
* correctly renders selected items in first postion during the first render
* add search
* general changes, constants part of app state, add popovers
* add toggle switch, rename css
* correct offset
* upgrade deps
* upgrade deps
* drawer and lot of other work
* update equipping mechanism
* finish equipment
* fix compilation and upgrade deps
* use v-show in place of v-if to fix ui issues
* v-show -> v-if
* fix linting in test/client
* fix es6 compilation in test/client
* fix babel compilation for tests
* fix groupsUtilities mixin tests
* client: buttons
* client: buttons: fix colors
* client: finish buttons and dropdowns
* upgrade bootstrap-vue, finish buttons and dropdowns
* fix tasks page layout
* misc fixes for buttons
* add textareas
* fix app menu
* add inputs
* fixes for toggleSwitch
* typography
* checkboxes and radio buttons
* add checkbox icon
* fix equip.js
* extract strings to newClient.json
* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active
* show "you have disabled your costume" error above the drawer items
* check errorMessage for null
* hide star if costume not enabled
* fix errorMessage (!errorMessage seems not to work for string)
* show minimize / expand icon - always centered by css
* drawer test
* drawer: fix centering on large screens
* fix show more button
* add margin when two dropdowns are next to each other
* adjust the page padding based on the drawer, misc fixes
* drawer fixes
2017-05-16 19:09:55 +00:00
|
|
|
const user = store.state.user.data;
|
|
|
|
|
|
2018-02-23 14:21:00 +00:00
|
|
|
for (let key in changes) {
|
2017-08-09 15:13:40 +00:00
|
|
|
if (key === 'tags') {
|
|
|
|
|
// Keep challenge and group tags
|
|
|
|
|
const oldTags = user.tags.filter(t => {
|
2017-10-01 04:54:12 +00:00
|
|
|
return t.group;
|
2017-08-09 15:13:40 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
user.tags = changes[key].concat(oldTags);
|
2017-09-02 16:08:32 +00:00
|
|
|
|
|
|
|
|
// Remove deleted tags from tasks
|
2018-02-23 14:21:00 +00:00
|
|
|
const userTasksByType = (await store.dispatch('tasks:fetchUserTasks')).data; // eslint-disable-line no-await-in-loop
|
2017-09-02 16:08:32 +00:00
|
|
|
|
|
|
|
|
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));
|
|
|
|
|
});
|
|
|
|
|
});
|
2017-08-09 15:13:40 +00:00
|
|
|
} else {
|
|
|
|
|
setProps(user, key, changes[key]);
|
|
|
|
|
}
|
Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette
* add secondary menu component and style it
* add box shadow to secondary menu
* misc css, fixes for secondary menu
* client: add equipment page with grouping, css: add some styles
* add typography
* more equipment
* stable: fix linting
* equipment: add styles (lots of general styles too)
* remove duplicate google fonts loading
* add dropdowns
* design: white search input background, remove gray from items
* start adding drawer and selected indicator
* wip equipment
* fix equipment
* equipment: correctly bind new properties on items.gear.equipped
* equipment: fix vue binding. version 2
* equipment: fix vue binding. version 3
* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed
* checkboxes and radio buttons
* correctly renders selected items in first postion during the first render
* add search
* general changes, constants part of app state, add popovers
* add toggle switch, rename css
* correct offset
* upgrade deps
* upgrade deps
* drawer and lot of other work
* update equipping mechanism
* finish equipment
* fix compilation and upgrade deps
* use v-show in place of v-if to fix ui issues
* v-show -> v-if
* fix linting in test/client
* fix es6 compilation in test/client
* fix babel compilation for tests
* fix groupsUtilities mixin tests
* client: buttons
* client: buttons: fix colors
* client: finish buttons and dropdowns
* upgrade bootstrap-vue, finish buttons and dropdowns
* fix tasks page layout
* misc fixes for buttons
* add textareas
* fix app menu
* add inputs
* fixes for toggleSwitch
* typography
* checkboxes and radio buttons
* add checkbox icon
* fix equip.js
* extract strings to newClient.json
* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active
* show "you have disabled your costume" error above the drawer items
* check errorMessage for null
* hide star if costume not enabled
* fix errorMessage (!errorMessage seems not to work for string)
* show minimize / expand icon - always centered by css
* drawer test
* drawer: fix centering on large screens
* fix show more button
* add margin when two dropdowns are next to each other
* adjust the page padding based on the drawer, misc fixes
* drawer fixes
2017-05-16 19:09:55 +00:00
|
|
|
}
|
|
|
|
|
|
2018-06-21 19:25:27 +00:00
|
|
|
axios.put('/api/v4/user', changes);
|
Client Redesign: Inventory pages, secondary menu, misc css and design items (#8631)
* add colors palette
* add secondary menu component and style it
* add box shadow to secondary menu
* misc css, fixes for secondary menu
* client: add equipment page with grouping, css: add some styles
* add typography
* more equipment
* stable: fix linting
* equipment: add styles (lots of general styles too)
* remove duplicate google fonts loading
* add dropdowns
* design: white search input background, remove gray from items
* start adding drawer and selected indicator
* wip equipment
* fix equipment
* equipment: correctly bind new properties on items.gear.equipped
* equipment: fix vue binding. version 2
* equipment: fix vue binding. version 3
* back to first fix for equip op, fix for sourcemaps, send http request when an item is equipped, load bootstrap-vue components where needed
* checkboxes and radio buttons
* correctly renders selected items in first postion during the first render
* add search
* general changes, constants part of app state, add popovers
* add toggle switch, rename css
* correct offset
* upgrade deps
* upgrade deps
* drawer and lot of other work
* update equipping mechanism
* finish equipment
* fix compilation and upgrade deps
* use v-show in place of v-if to fix ui issues
* v-show -> v-if
* fix linting in test/client
* fix es6 compilation in test/client
* fix babel compilation for tests
* fix groupsUtilities mixin tests
* client: buttons
* client: buttons: fix colors
* client: finish buttons and dropdowns
* upgrade bootstrap-vue, finish buttons and dropdowns
* fix tasks page layout
* misc fixes for buttons
* add textareas
* fix app menu
* add inputs
* fixes for toggleSwitch
* typography
* checkboxes and radio buttons
* add checkbox icon
* fix equip.js
* extract strings to newClient.json
* add Popover above 'Use Costume' / 'Auto Equip' slider - disable item select if costume-mode and 'useCostume' isn't active
* show "you have disabled your costume" error above the drawer items
* check errorMessage for null
* hide star if costume not enabled
* fix errorMessage (!errorMessage seems not to work for string)
* show minimize / expand icon - always centered by css
* drawer test
* drawer: fix centering on large screens
* fix show more button
* add margin when two dropdowns are next to each other
* adjust the page padding based on the drawer, misc fixes
* drawer fixes
2017-05-16 19:09:55 +00:00
|
|
|
// TODO
|
|
|
|
|
// .then((res) => console.log('set', res))
|
|
|
|
|
// .catch((err) => console.error('set', err));
|
2017-07-06 15:38:52 +00:00
|
|
|
}
|
|
|
|
|
|
2018-03-17 20:12:25 +00:00
|
|
|
export async function sleep (store) {
|
|
|
|
|
const user = store.state.user.data;
|
|
|
|
|
|
|
|
|
|
user.preferences.sleep = !user.preferences.sleep;
|
|
|
|
|
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.post('/api/v4/user/sleep');
|
2017-07-29 22:08:36 +00:00
|
|
|
return response.data.data;
|
2017-07-06 15:38:52 +00:00
|
|
|
}
|
2017-07-20 18:01:00 +00:00
|
|
|
|
|
|
|
|
export async function addWebhook (store, payload) {
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.post('/api/v4/user/webhook', payload.webhookInfo);
|
2017-07-20 18:01:00 +00:00
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateWebhook (store, payload) {
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.put(`/api/v4/user/webhook/${payload.webhook.id}`, payload.webhook);
|
2017-07-20 18:01:00 +00:00
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteWebhook (store, payload) {
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.delete(`/api/v4/user/webhook/${payload.webhook.id}`);
|
2017-07-20 18:01:00 +00:00
|
|
|
return response.data.data;
|
|
|
|
|
}
|
2017-08-14 17:15:32 +00:00
|
|
|
|
2017-08-22 22:59:18 +00:00
|
|
|
export async function changeClass (store, params) {
|
|
|
|
|
const user = store.state.user.data;
|
|
|
|
|
|
|
|
|
|
changeClassOp(user, params);
|
2017-11-20 21:57:33 +00:00
|
|
|
user.flags.classSelected = true;
|
|
|
|
|
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.post(`/api/v4/user/change-class?class=${params.query.class}`);
|
2017-08-22 22:59:18 +00:00
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function disableClasses (store) {
|
|
|
|
|
const user = store.state.user.data;
|
|
|
|
|
|
|
|
|
|
disableClassesOp(user);
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.post('/api/v4/user/disable-classes');
|
2017-08-22 22:59:18 +00:00
|
|
|
return response.data.data;
|
|
|
|
|
}
|
2017-08-14 17:15:32 +00:00
|
|
|
|
|
|
|
|
export function togglePinnedItem (store, params) {
|
|
|
|
|
const user = store.state.user.data;
|
|
|
|
|
|
|
|
|
|
let addedItem = togglePinnedItemOp(user, params);
|
|
|
|
|
|
2018-06-21 19:25:27 +00:00
|
|
|
axios.get(`/api/v4/user/toggle-pinned-item/${params.type}/${params.path}`);
|
2017-08-14 17:15:32 +00:00
|
|
|
// TODO
|
|
|
|
|
// .then((res) => console.log('equip', res))
|
|
|
|
|
// .catch((err) => console.error('equip', err));
|
|
|
|
|
|
|
|
|
|
return addedItem;
|
|
|
|
|
}
|
2017-08-20 22:32:32 +00:00
|
|
|
|
Feature/sortable reward area (#9930)
* Client POC
We need to wrap each draggable region it its own div or else the
"draggable" element will conflict with each other. This screws up the
styling but that is totally fixable
* Ah that ref was being used after all, changing back
* Scaffold out a new callback for when we drag these things
Next is going to be the hard part: I need to save the sort order for
these to the database. I don't even know if there is a schema but hey
this is the best place to start
* Firefox caching is the problem: don't actually need the wrapper div
So I guess I should try this in chrome and see how it works then come
back to firefox and figure out what the heck is going on
* Scaffolding out our API call to save the sort order
The endpoint doesn't exist yet so we will need to add that
* Ok we are now calling our API endpoint to reorder these things
Of course it doesn't exist yet so you get a 404 when you try, but that
is ok
* Defining api endpoint, a work in progress
In particular I really had ought to use _id for these too, it appears
that the primary way we detect order doesn't even use "key" at all.
* Switching to using the pinned item UUID
This has much better results, but of course the server and client logic
don't match now. Will have to keep working on my splice to make sure
that they are the same
* I thought this would fix our server/client mismatch but it is not it
Something is really wrong with my logic somewhere, maybe I need to
update the db step?
* Moving this logic to the "user" rather than "tasks" and key off path
Path is unique and is less finiky than dealing with string comparisons
with ids. Unfortunately everything is still not working... I suppose
user.update() doesn't care about the position?
* This client code caused quite a lot of problems if you dragged fast
We don't really need it it seems, so off it goes
* Updating markup and CSS so it actually looks good.
Everything is working horray!!
I did just notice the following bug: the popover text sometimes makes it
very annoying to drag because you can't drop over it@
* Cleaning up my comments in the API section user.js
I had a lot of TODOS that are mostly done now
* Fixing a spacing code standards thing
* Turns out we never use type, so we should remove this from the API call
* Adding pinnedItemsOrder into the user schema
And disabling my call in the frontend before I do any more damage
* Halfway to using pinnedItemsOrder
This isn't working yet but it is not going to break it horribly like it
was before.
* Hooking up inAppRewards to always produce sorted information
It is suspicially working right now even though I have not added the
seasonal stuff logic yet...
* Updating the comments in user.js in movedPinnedItem
It turns out that my bandaid fix to just get the ball rolling perfectly
does what I need it to do when we have a length discrepancy. So we are
getting much closer to the final product, just need lots of testing
* Cleaning up code standards kinds of things
* Yay, this fixes the popover issue
I hope this is the right "vue" way to do things, because I tried a bunch
of other things that definately were not the right way to do it. And
this appears to work too
* ** Partial Work ** Starting tests on api call for draggable items
Doesn't work, doesn't compile so don't include in PR!
* Test failing still...
This is worth a save. The api call grabs the seasonal items too, so we
can't get away from using the common functions and calls here to get the
actual list of items
* Okay have the first test passing
Need to clean up my linter problems though
* Planning out the next two tests and fixing my format problems
* 2nd Test case written, this time with the "more" odd case
* Making sure that we didn't mess with pinned items
* Huh... this test doesn't give me the expected result
Drat, I guess I found a bug
* Throw an error when we put garbage in our api call.
Well, before we got user.pinnedItemsOrder filled with a bunch of "null"
entries which is not ideal. it still worked, but isn't this confusing
enough already?
* Cleaning up the multitude of linting problems thanks gulp :)
* Writing tests for inAppRewards.js, but something is wrong
* Fixing my linting errors in inAppRewards tests
These tests still do not run though, so they may fail and I would not
know
* Applying Negue's fixes to inAppRewards.js test
It never occured to me that we shouldn't try to reach the database while
in the common tests. Well, we shouldn't do that, we should use the
common.helpers instead. Thanks!
2018-04-13 13:22:06 +00:00
|
|
|
export async function movePinnedItem (store, params) {
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.post(`/api/v4/user/move-pinned-item/${params.path}/move/to/${params.position}`);
|
Feature/sortable reward area (#9930)
* Client POC
We need to wrap each draggable region it its own div or else the
"draggable" element will conflict with each other. This screws up the
styling but that is totally fixable
* Ah that ref was being used after all, changing back
* Scaffold out a new callback for when we drag these things
Next is going to be the hard part: I need to save the sort order for
these to the database. I don't even know if there is a schema but hey
this is the best place to start
* Firefox caching is the problem: don't actually need the wrapper div
So I guess I should try this in chrome and see how it works then come
back to firefox and figure out what the heck is going on
* Scaffolding out our API call to save the sort order
The endpoint doesn't exist yet so we will need to add that
* Ok we are now calling our API endpoint to reorder these things
Of course it doesn't exist yet so you get a 404 when you try, but that
is ok
* Defining api endpoint, a work in progress
In particular I really had ought to use _id for these too, it appears
that the primary way we detect order doesn't even use "key" at all.
* Switching to using the pinned item UUID
This has much better results, but of course the server and client logic
don't match now. Will have to keep working on my splice to make sure
that they are the same
* I thought this would fix our server/client mismatch but it is not it
Something is really wrong with my logic somewhere, maybe I need to
update the db step?
* Moving this logic to the "user" rather than "tasks" and key off path
Path is unique and is less finiky than dealing with string comparisons
with ids. Unfortunately everything is still not working... I suppose
user.update() doesn't care about the position?
* This client code caused quite a lot of problems if you dragged fast
We don't really need it it seems, so off it goes
* Updating markup and CSS so it actually looks good.
Everything is working horray!!
I did just notice the following bug: the popover text sometimes makes it
very annoying to drag because you can't drop over it@
* Cleaning up my comments in the API section user.js
I had a lot of TODOS that are mostly done now
* Fixing a spacing code standards thing
* Turns out we never use type, so we should remove this from the API call
* Adding pinnedItemsOrder into the user schema
And disabling my call in the frontend before I do any more damage
* Halfway to using pinnedItemsOrder
This isn't working yet but it is not going to break it horribly like it
was before.
* Hooking up inAppRewards to always produce sorted information
It is suspicially working right now even though I have not added the
seasonal stuff logic yet...
* Updating the comments in user.js in movedPinnedItem
It turns out that my bandaid fix to just get the ball rolling perfectly
does what I need it to do when we have a length discrepancy. So we are
getting much closer to the final product, just need lots of testing
* Cleaning up code standards kinds of things
* Yay, this fixes the popover issue
I hope this is the right "vue" way to do things, because I tried a bunch
of other things that definately were not the right way to do it. And
this appears to work too
* ** Partial Work ** Starting tests on api call for draggable items
Doesn't work, doesn't compile so don't include in PR!
* Test failing still...
This is worth a save. The api call grabs the seasonal items too, so we
can't get away from using the common functions and calls here to get the
actual list of items
* Okay have the first test passing
Need to clean up my linter problems though
* Planning out the next two tests and fixing my format problems
* 2nd Test case written, this time with the "more" odd case
* Making sure that we didn't mess with pinned items
* Huh... this test doesn't give me the expected result
Drat, I guess I found a bug
* Throw an error when we put garbage in our api call.
Well, before we got user.pinnedItemsOrder filled with a bunch of "null"
entries which is not ideal. it still worked, but isn't this confusing
enough already?
* Cleaning up the multitude of linting problems thanks gulp :)
* Writing tests for inAppRewards.js, but something is wrong
* Fixing my linting errors in inAppRewards tests
These tests still do not run though, so they may fail and I would not
know
* Applying Negue's fixes to inAppRewards.js test
It never occured to me that we shouldn't try to reach the database while
in the common tests. Well, we shouldn't do that, we should use the
common.helpers instead. Thanks!
2018-04-13 13:22:06 +00:00
|
|
|
return response.data.data;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-20 22:32:32 +00:00
|
|
|
export function castSpell (store, params) {
|
2018-06-21 19:25:27 +00:00
|
|
|
let spellUrl = `/api/v4/user/class/cast/${params.key}`;
|
2017-12-21 16:27:09 +00:00
|
|
|
|
2018-04-24 01:30:55 +00:00
|
|
|
const data = {};
|
|
|
|
|
|
2017-08-20 22:32:32 +00:00
|
|
|
if (params.targetId) spellUrl += `?targetId=${params.targetId}`;
|
2018-04-24 01:30:55 +00:00
|
|
|
if (params.quantity) data.quantity = params.quantity;
|
2017-08-20 22:32:32 +00:00
|
|
|
|
2018-04-24 01:30:55 +00:00
|
|
|
return axios.post(spellUrl, data);
|
2017-08-20 22:32:32 +00:00
|
|
|
}
|
2017-08-26 10:18:55 +00:00
|
|
|
|
|
|
|
|
export function openMysteryItem () {
|
2018-06-21 19:25:27 +00:00
|
|
|
return axios.post('/api/v4/user/open-mystery-item');
|
2017-08-26 10:18:55 +00:00
|
|
|
}
|
|
|
|
|
|
2018-02-26 19:07:54 +00:00
|
|
|
export function newStuffLater (store) {
|
|
|
|
|
store.state.user.data.flags.newStuff = false;
|
2018-06-21 19:25:27 +00:00
|
|
|
return axios.post('/api/v4/news/tell-me-later');
|
2018-01-31 10:55:39 +00:00
|
|
|
}
|
|
|
|
|
|
2017-08-31 20:56:53 +00:00
|
|
|
export async function rebirth () {
|
2018-06-21 19:25:27 +00:00
|
|
|
let result = await axios.post('/api/v4/user/rebirth');
|
2017-08-31 20:56:53 +00:00
|
|
|
|
|
|
|
|
return result;
|
2017-08-26 10:18:55 +00:00
|
|
|
}
|
2018-04-29 13:48:10 +00:00
|
|
|
|
|
|
|
|
export async function togglePrivateMessagesOpt (store) {
|
2018-06-21 19:25:27 +00:00
|
|
|
let response = await axios.put('/api/v4/user',
|
2018-04-29 13:48:10 +00:00
|
|
|
{
|
|
|
|
|
'inbox.optOut': !store.state.user.data.inbox.optOut,
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
store.state.user.data.inbox.optOut = !store.state.user.data.inbox.optOut;
|
|
|
|
|
return response;
|
|
|
|
|
}
|