Performance optimization: Removed creature document from injection to prevent uneccessary Vue re-rendering
This commit is contained in:
@@ -95,7 +95,7 @@
|
|||||||
},
|
},
|
||||||
reactiveProvide: {
|
reactiveProvide: {
|
||||||
name: 'context',
|
name: 'context',
|
||||||
include: ['creature', 'editPermission'],
|
include: ['creatureId', 'editPermission'],
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
activeTab: {
|
activeTab: {
|
||||||
@@ -150,9 +150,6 @@
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
snackbars(){
|
|
||||||
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<column-layout wide-columns>
|
<column-layout wide-columns>
|
||||||
<div>
|
<div>
|
||||||
<toolbar-card
|
<toolbar-card
|
||||||
:color="context.creature.color"
|
:color="creature.color"
|
||||||
>
|
>
|
||||||
<v-toolbar-title slot="toolbar">
|
<v-toolbar-title slot="toolbar">
|
||||||
Equipped
|
Equipped
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<toolbar-card
|
<toolbar-card
|
||||||
:color="context.creature.color"
|
:color="creature.color"
|
||||||
>
|
>
|
||||||
<v-toolbar-title slot="toolbar">
|
<v-toolbar-title slot="toolbar">
|
||||||
Carried
|
Carried
|
||||||
@@ -46,6 +46,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
||||||
import ContainerCard from '/imports/ui/properties/components/inventory/ContainerCard.vue';
|
import ContainerCard from '/imports/ui/properties/components/inventory/ContainerCard.vue';
|
||||||
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
||||||
@@ -60,9 +61,6 @@ export default {
|
|||||||
ToolbarCard,
|
ToolbarCard,
|
||||||
ItemList,
|
ItemList,
|
||||||
},
|
},
|
||||||
inject: {
|
|
||||||
context: { default: {} }
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
creatureId: {
|
creatureId: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -83,6 +81,9 @@ export default {
|
|||||||
sort: {order: 1},
|
sort: {order: 1},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
creature(){
|
||||||
|
return Creatures.findOne(this.creatureId, {fields: {color: 1}});
|
||||||
|
},
|
||||||
containersWithoutAncestorContainers(){
|
containersWithoutAncestorContainers(){
|
||||||
return CreatureProperties.find({
|
return CreatureProperties.find({
|
||||||
'ancestors.id': {
|
'ancestors.id': {
|
||||||
|
|||||||
@@ -34,9 +34,6 @@ export default {
|
|||||||
SpellList,
|
SpellList,
|
||||||
SpellListCard,
|
SpellListCard,
|
||||||
},
|
},
|
||||||
inject: {
|
|
||||||
context: { default: {} }
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
creatureId: {
|
creatureId: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -129,11 +129,14 @@ export default {
|
|||||||
);
|
);
|
||||||
if (!nearestCreatureAncestor) return;
|
if (!nearestCreatureAncestor) return;
|
||||||
return Creatures.findOne(nearestCreatureAncestor.id);
|
return Creatures.findOne(nearestCreatureAncestor.id);
|
||||||
}
|
},
|
||||||
|
creatureId(){
|
||||||
|
return this.creature && this.creature._id;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
reactiveProvide: {
|
reactiveProvide: {
|
||||||
name: 'context',
|
name: 'context',
|
||||||
include: ['creature', 'editPermission'],
|
include: ['creatureId', 'editPermission'],
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getPropertyName,
|
getPropertyName,
|
||||||
|
|||||||
@@ -28,13 +28,8 @@ export default {
|
|||||||
},
|
},
|
||||||
reactiveProvide: {
|
reactiveProvide: {
|
||||||
name: 'context',
|
name: 'context',
|
||||||
include: ['creature'],
|
include: ['creatureId'],
|
||||||
},
|
},
|
||||||
meteor: {
|
|
||||||
creature(){
|
|
||||||
return Creatures.findOne(this.creatureId);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -168,7 +168,7 @@ export default {
|
|||||||
},
|
},
|
||||||
reactiveProvide: {
|
reactiveProvide: {
|
||||||
name: 'context',
|
name: 'context',
|
||||||
include: ['creature'],
|
include: ['creatureId'],
|
||||||
},
|
},
|
||||||
methods:{
|
methods:{
|
||||||
getTitle(model){
|
getTitle(model){
|
||||||
|
|||||||
@@ -63,9 +63,6 @@ export default {
|
|||||||
components: {
|
components: {
|
||||||
TreeNodeView,
|
TreeNodeView,
|
||||||
},
|
},
|
||||||
inject: {
|
|
||||||
context: { default: {} }
|
|
||||||
},
|
|
||||||
props: {
|
props: {
|
||||||
creatureId: {
|
creatureId: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
}"
|
}"
|
||||||
>
|
>
|
||||||
<v-menu
|
<v-menu
|
||||||
v-if="context.creature"
|
v-if="context.creatureId"
|
||||||
transition="slide-y-transition"
|
transition="slide-y-transition"
|
||||||
lazy
|
lazy
|
||||||
:disabled="!context.editPermission"
|
:disabled="!context.editPermission"
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
style="height: 100%;"
|
style="height: 100%;"
|
||||||
:class="{
|
:class="{
|
||||||
'error--text': insufficient,
|
'error--text': insufficient,
|
||||||
'clickable': context.creature && context.editPermission,
|
'clickable': context.creatureId && context.editPermission,
|
||||||
'left-pad': leftPad,
|
'left-pad': leftPad,
|
||||||
}"
|
}"
|
||||||
v-on="on"
|
v-on="on"
|
||||||
|
|||||||
@@ -75,9 +75,6 @@ import IncrementMenu from '/imports/ui/components/IncrementMenu.vue';
|
|||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
IncrementMenu
|
IncrementMenu
|
||||||
},
|
|
||||||
inject: {
|
|
||||||
context: { default: {} }
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
value: Number,
|
value: Number,
|
||||||
|
|||||||
@@ -17,9 +17,6 @@
|
|||||||
import HealthBar from '/imports/ui/properties/components/attributes/HealthBar.vue';
|
import HealthBar from '/imports/ui/properties/components/attributes/HealthBar.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: {
|
|
||||||
context: { default: {} }
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
HealthBar,
|
HealthBar,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -65,9 +65,6 @@ export default {
|
|||||||
dark: Boolean,
|
dark: Boolean,
|
||||||
hideCastButton: Boolean,
|
hideCastButton: Boolean,
|
||||||
},
|
},
|
||||||
inject: {
|
|
||||||
context: { default: {} }
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
currentValue(){
|
currentValue(){
|
||||||
return this.value - this.damage;
|
return this.value - this.damage;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
</v-list-tile-content>
|
</v-list-tile-content>
|
||||||
<v-list-tile-action>
|
<v-list-tile-action>
|
||||||
<increment-button
|
<increment-button
|
||||||
v-if="context.creature && model.showIncrement"
|
v-if="context.creatureId && model.showIncrement"
|
||||||
icon
|
icon
|
||||||
flat
|
flat
|
||||||
color="primary"
|
color="primary"
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="layout row align-center justify-space-around">
|
<div class="layout row align-center justify-space-around">
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="context.creature"
|
v-if="context.creatureId"
|
||||||
flat
|
flat
|
||||||
outline
|
outline
|
||||||
style="font-size: 18px;"
|
style="font-size: 18px;"
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="model.uses">
|
<div v-if="model.uses">
|
||||||
<span
|
<span
|
||||||
v-if="context.creature"
|
v-if="context.creatureId"
|
||||||
class="uses mx-2"
|
class="uses mx-2"
|
||||||
>
|
>
|
||||||
{{ usesLeft }}/{{ model.usesResult }} uses
|
{{ usesLeft }}/{{ model.usesResult }} uses
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
{{ reset }}
|
{{ reset }}
|
||||||
</span>
|
</span>
|
||||||
<v-btn
|
<v-btn
|
||||||
v-if="context.creature"
|
v-if="context.creatureId"
|
||||||
outline
|
outline
|
||||||
color="primary"
|
color="primary"
|
||||||
:disabled="!model.usesUsed || !context.editPermission"
|
:disabled="!model.usesUsed || !context.editPermission"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<effect-viewer
|
<effect-viewer
|
||||||
v-if="context.creature && model.baseValueCalculation"
|
v-if="context.creatureId && model.baseValueCalculation"
|
||||||
:model="{
|
:model="{
|
||||||
name: 'Base value',
|
name: 'Base value',
|
||||||
result: model.baseValue,
|
result: model.baseValue,
|
||||||
@@ -89,8 +89,8 @@
|
|||||||
},
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
effects(){
|
effects(){
|
||||||
if (this.context.creature){
|
if (this.context.creatureId){
|
||||||
let creatureId = this.context.creature._id;
|
let creatureId = this.context.creatureId;
|
||||||
return CreatureProperties.find({
|
return CreatureProperties.find({
|
||||||
'ancestors.id': creatureId,
|
'ancestors.id': creatureId,
|
||||||
'stats': this.model.variableName,
|
'stats': this.model.variableName,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
{{ model.quantity }}
|
{{ model.quantity }}
|
||||||
</div>
|
</div>
|
||||||
<increment-button
|
<increment-button
|
||||||
v-if="context.creature && model.showIncrement"
|
v-if="context.creatureId && model.showIncrement"
|
||||||
icon
|
icon
|
||||||
large
|
large
|
||||||
outline
|
outline
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<effect-viewer
|
<effect-viewer
|
||||||
v-if="context.creature && model.baseValue"
|
v-if="context.creatureId && model.baseValue"
|
||||||
:model="{
|
:model="{
|
||||||
name: 'Base value',
|
name: 'Base value',
|
||||||
result: model.baseValue,
|
result: model.baseValue,
|
||||||
@@ -96,8 +96,8 @@ export default {
|
|||||||
},
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
effects(){
|
effects(){
|
||||||
if (this.context.creature){
|
if (this.context.creatureId){
|
||||||
let creatureId = this.context.creature._id;
|
let creatureId = this.context.creatureId;
|
||||||
return CreatureProperties.find({
|
return CreatureProperties.find({
|
||||||
'ancestors.id': creatureId,
|
'ancestors.id': creatureId,
|
||||||
stats: this.model.variableName,
|
stats: this.model.variableName,
|
||||||
|
|||||||
Reference in New Issue
Block a user