Skip to content

Commit

Permalink
Improving performance on the mythic equip upgrade page
Browse files Browse the repository at this point in the history
  • Loading branch information
Numbers committed Jan 11, 2023
1 parent 40ba39d commit bd48e64
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
1.28.20: Improving performance on the mythic equip upgrade page
1.28.19: Fixing more missing tooltips
1.28.18: Fixing missing tooltips
1.28.17: Pre-empting new tooltips update
Expand Down
4 changes: 2 additions & 2 deletions dist/hh-plus-plus.dev.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/hh-plus-plus.meta.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name Hentai Heroes++ BDSM version
// @description Adding things here and there in the Hentai Heroes game. Also supports HHCore-based games such as GH and CxH.
// @version 1.28.19
// @version 1.28.20
// @match https://*.hentaiheroes.com/*
// @match https://nutaku.haremheroes.com/*
// @match https://*.gayharem.com/*
Expand Down
4 changes: 2 additions & 2 deletions dist/hh-plus-plus.user.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "hh-plus-plus",
"version": "1.28.19",
"version": "1.28.20",
"description": "Adding things here and there in the Hentai Heroes game. Also supports HHCore-based games such as GH and CxH.",
"private": "true",
"scripts": {
Expand Down
45 changes: 23 additions & 22 deletions src/modules/MarketEquipsFilterModule/EquipManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class EquipManager {

this.reconsileAfterNextDOMChange()
})
const collectFromLazyLoad = (response) => {
const collectFromLazyLoad = (response, annotateOnly) => {
const { items } = response

if (!items || !items.length) { return }
Expand All @@ -128,10 +128,10 @@ class EquipManager {
this.keysForIds[item.id_member_armor] = key
})

this.reconsileAfterNextDOMChange()
this.reconsileAfterNextDOMChange(null, annotateOnly)
}
Helpers.onAjaxResponse(/action=market_get_armor/, collectFromLazyLoad)
Helpers.onAjaxResponse(/action=mythic_armor_load_material_items/, collectFromLazyLoad)
Helpers.onAjaxResponse(/action=market_get_armor/, (response) => collectFromLazyLoad(response, false))
Helpers.onAjaxResponse(/action=mythic_armor_load_material_items/, (response) => collectFromLazyLoad(response, true))

Helpers.onAjaxResponse(/action=market_sell/, (response, opt) => {
const searchParams = new URLSearchParams(opt.data)
Expand Down Expand Up @@ -231,8 +231,8 @@ class EquipManager {
}
}

reconsileAfterNextDOMChange(extraCallback) {
this.doAfterNextDOMChange(extraCallback, () => this.reconcileElements())
reconsileAfterNextDOMChange(extraCallback, annotateOnly) {
this.doAfterNextDOMChange(extraCallback, () => this.reconcileElements(annotateOnly))
}

doAfterNextDOMChange(...callbacks) {
Expand Down Expand Up @@ -332,36 +332,37 @@ class EquipManager {
return this.$container.find(`[data-equip-key="${key}"]`)
}

reconcileElements() {
reconcileElements(annotateOnly) {
// const $content = this.$container.find('.player-inventory-content')
this.$content.find('.slot:not(.empty)').each((i, slot) => {
const $slot = $(slot)

const { key } = this.assertEquipAnnotatedWithKey($slot)

const $parent = $slot.parent()
if (!annotateOnly) {
const $parent = $slot.parent()

this.elementCache[key] = $parent
this.elementCache[key] = $parent

if (!this.visibleEquipIds.includes(key)) {
$parent.detach()
if (!this.visibleEquipIds.includes(key)) {
$parent.detach()
}
}
})

if (!annotateOnly) {
this.allEquipIdsInOrder.forEach(key => {
if (!this.visibleEquipIds.includes(key)) { return }
const $slot = this.elementCache[key]

this.allEquipIdsInOrder.forEach(key => {
if (!this.visibleEquipIds.includes(key)) { return }
const $slot = this.elementCache[key]

if (!$slot || !$slot.length) {
console.log('no cache entry for key', key)
return
}
if (!$slot || !$slot.length) {
console.log('no cache entry for key', key)
return
}

this.$content.append($slot)
})
this.$content.append($slot)
})

if (this.name !== 'upgrade') {
this.$content.append(this.$content.find('.slot-container.empty'))
this.padWithEmptySlots()
this.$content.getNiceScroll().resize()
Expand Down

0 comments on commit bd48e64

Please sign in to comment.