Skip to content
This repository has been archived by the owner on Jun 5, 2024. It is now read-only.

Commit

Permalink
Adjust State Helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Apr 4, 2023
1 parent a06179b commit d2642d1
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
- AthenaClient.systems.inventory.get.onToolbarChange
- AthenaClient.systems.inventory.get.onWeightChange
- import * as state from '@ViewUtility/state'
- This allows you to get character, or account info in the view easily.
- Alternatively use a Vue Prop with 'state' or 'accountData'.
- state.get
- state.set
- state.getAccountData
- state.getAccountPermissions
- state.getCharacterData
- state.getCharacterPermissions
--------------------------------------
--- Everything Below is Before April 2
--------------------------------------
Expand Down
1 change: 1 addition & 0 deletions src-webviews/src/pages/stateTest/StateTest.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

<script lang="ts">
import { defineComponent } from 'vue';
import * as state from '@ViewUtility/state';
const ComponentName = 'StateTest';
export default defineComponent({
Expand Down
36 changes: 36 additions & 0 deletions src-webviews/src/utility/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,39 @@ export function getCharacterData<T = Character>(): T | undefined {
export function getAccountData<T = Partial<Account>>(): T | undefined {
return state['accountState'];
}

/**
* Return a list of character permissions.
*
* @export
* @return {Array<string>}
*/
export function getCharacterPermissions(): Array<string> {
if (!state['characterState']) {
return [];
}

if (!state['characterState'].permissions) {
return [];
}

return state['characterState'].permissions;
}

/**
* Return a list of account permissions.
*
* @export
* @return {Array<string>}
*/
export function getAccountPermissions(): Array<string> {
if (!state['accountState']) {
return [];
}

if (!state['accountState'].permissions) {
return [];
}

return state['accountState'].permissions;
}

0 comments on commit d2642d1

Please sign in to comment.