diff --git a/app/client/game-icons.css b/app/client/game-icons.css index 8a28a3c4..d694ff66 100644 --- a/app/client/game-icons.css +++ b/app/client/game-icons.css @@ -5,8 +5,8 @@ @font-face { font-family: "game-icons"; src: url("/fonts/game-icons.eot?817af6e52c83163eb30ece54d9f7d16d?#iefix") format("embedded-opentype"), -url("/fonts/game-icons.woff?817af6e52c83163eb30ece54d9f7d16d") format("woff"), -url("/fonts/game-icons.ttf?817af6e52c83163eb30ece54d9f7d16d") format("truetype"); + url("/fonts/game-icons.woff?817af6e52c83163eb30ece54d9f7d16d") format("woff"), + url("/fonts/game-icons.ttf?817af6e52c83163eb30ece54d9f7d16d") format("truetype"); } .game-icon { diff --git a/app/imports/api/parenting/parentingFunctions.ts b/app/imports/api/parenting/parentingFunctions.ts index 758aaf13..6dc3d219 100644 --- a/app/imports/api/parenting/parentingFunctions.ts +++ b/app/imports/api/parenting/parentingFunctions.ts @@ -93,16 +93,16 @@ type FilteredDoc = { export function filterToForest( collection: Mongo.Collection, rootId: string, - filter?: Mongo.Query, + filter?: Mongo.Selector, { - options = >{}, + options = >{}, includeFilteredDocAncestors = false, includeFilteredDocDescendants = false } = {} ): TreeNode[] { if (!Meteor.isClient) throw 'Only available on the client'; // Setup the filter - let collectionFilter: Mongo.Query = { + let collectionFilter: Mongo.Selector = { 'root.id': rootId, 'removed': { $ne: true }, }; @@ -113,16 +113,17 @@ export function filterToForest( } } // Set up the options - let collectionSort = { + let collectionSort: Mongo.Options['sort'] = { left: 1 }; - if (options && options.sort) { + if (options.sort) { collectionSort = { ...collectionSort, + // @ts-expect-error go home typescript you're drunk ...options.sort, } } - let collectionOptions: Mongo.Options = { + let collectionOptions: Mongo.Options = { sort: collectionSort, } if (options) { @@ -671,8 +672,8 @@ export function setDocToLastOrder(collection: Mongo.Collection, doc: Tr doc.left = Number.MAX_SAFE_INTEGER; } -export async function rebuildNestedSets(collection: Mongo.Collection, rootId: string) { - const docs = await collection.find({ +export function rebuildNestedSets(collection: Mongo.Collection, rootId: string) { + const docs = collection.find({ 'root.id': rootId, removed: { $ne: true } }, { @@ -681,13 +682,13 @@ export async function rebuildNestedSets(collection: Mongo.Collection, r //Reverse sorting so that arrays can be used as stacks with the first item on top left: 1, }, - }).fetchAsync(); + }).fetch(); const operations = calculateNestedSetOperations(docs); return writeBulkOperations(collection, operations); } -export async function rebuildCreatureNestedSets(creatureId) { +export function rebuildCreatureNestedSets(creatureId) { const docs = getProperties(creatureId); const operations = calculateNestedSetOperations(docs); return writeBulkOperations(CreatureProperties as Mongo.Collection, operations); @@ -823,8 +824,9 @@ export function applyNestedSetProperties(docs: T[]): Forest */ -async function writeBulkOperations(collection: Mongo.Collection, operations) { - if (Meteor.isServer && operations.length) { +function writeBulkOperations(collection: Mongo.Collection, operations) { + if (Meteor.isServer) { + if (!operations.length) return Promise.resolve(); return new Promise((resolve, reject) => { collection.rawCollection().bulkWrite( operations, @@ -841,20 +843,19 @@ async function writeBulkOperations(collection: Mongo.Collection, operat } else { // Don't do latency compensation if there are too many operations, it just causes client // lag without much benefit - const promises = operations.map(op => { + operations.forEach(op => { if (op.updateOne) { - return collection.updateAsync( + collection.update( op.updateOne.filter, op.updateOne.update, ); } else if (op.updateMany) { - return collection.updateAsync( + collection.update( op.updateMany.filter, op.updateMany.update, { multi: true }, ) } }); - return Promise.all(promises); } } diff --git a/app/imports/client/ui/creature/creatureProperties/DescendantPropertiesTree.vue b/app/imports/client/ui/creature/creatureProperties/DescendantPropertiesTree.vue new file mode 100644 index 00000000..9fa92021 --- /dev/null +++ b/app/imports/client/ui/creature/creatureProperties/DescendantPropertiesTree.vue @@ -0,0 +1,78 @@ + + + diff --git a/app/imports/client/ui/properties/PropertyForm.vue b/app/imports/client/ui/properties/PropertyForm.vue index 7e1664e9..c0643a44 100644 --- a/app/imports/client/ui/properties/PropertyForm.vue +++ b/app/imports/client/ui/properties/PropertyForm.vue @@ -167,10 +167,11 @@ style="width: 100%" class="pa-2 no-hover" > - @@ -225,7 +226,7 @@ import InlineComputationField from '/imports/client/ui/properties/forms/shared/I import FormSection, { FormSections } from '/imports/client/ui/properties/forms/shared/FormSection.vue'; import propertyFormIndex from '/imports/client/ui/properties/forms/shared/propertyFormIndex'; import IconColorMenu from '/imports/client/ui/properties/forms/shared/IconColorMenu.vue'; -import CreaturePropertiesTree from '/imports/client/ui/creature/creatureProperties/CreaturePropertiesTree.vue'; +import DescendantPropertiesTree from '/imports/client/ui/creature/creatureProperties/DescendantPropertiesTree.vue'; import OutlinedInput from '/imports/client/ui/properties/viewers/shared/OutlinedInput.vue'; import { getSuggestedChildren } from '/imports/constants/PROPERTIES'; import PROPERTIES from '/imports/constants/PROPERTIES'; @@ -243,7 +244,7 @@ export default { FormSection, FormSections, IconColorMenu, - CreaturePropertiesTree, + DescendantPropertiesTree, OutlinedInput, ...propertyFormIndex, }, diff --git a/app/imports/client/ui/properties/shared/PropertyViewer.vue b/app/imports/client/ui/properties/shared/PropertyViewer.vue index 525354b3..e4340bdc 100644 --- a/app/imports/client/ui/properties/shared/PropertyViewer.vue +++ b/app/imports/client/ui/properties/shared/PropertyViewer.vue @@ -134,9 +134,9 @@ name="Child properties" :cols="{cols: 12}" > -