@@ -24,6 +24,7 @@ import {
2424import { akashiEstimate , AKASHI_INTERVAL , NOSAKI_INTERVAL } from './functions'
2525import {
2626 checkRepairActive ,
27+ checkNosakiPresent ,
2728 REPAIR_SHIP_ID ,
2829 NOSAKI_ID_LIST ,
2930 getFleetStatus ,
@@ -132,15 +133,26 @@ const PluginAnchorageRepair: React.FC = () => {
132133
133134 // Global Nosaki timer handling
134135 // Check if ANY fleet has Nosaki present in position 1 or 2
136+ // Use lightweight checkNosakiPresent first, then full getFleetStatus only if needed
135137 let anyFleetNosakiPresent = false
136138 let anyFleetCanBoostMorale = false
137139 for ( const fleet of fleets ) {
138- const status = getFleetStatus ( fleet , ships , $ships , repairId , equips )
139- if ( status . nosakiPresent ) {
140+ // Quick check first - doesn't require $ships
141+ if ( checkNosakiPresent ( fleet , ships ) ) {
140142 anyFleetNosakiPresent = true
141- if ( status . canBoostMorale ) {
142- anyFleetCanBoostMorale = true
143- break
143+ // Only call getFleetStatus for full eligibility check when $ships is available
144+ if ( $ships && Object . keys ( $ships ) . length > 0 ) {
145+ const status = getFleetStatus (
146+ fleet ,
147+ ships ,
148+ $ships ,
149+ repairId ,
150+ equips ,
151+ )
152+ if ( status . canBoostMorale ) {
153+ anyFleetCanBoostMorale = true
154+ break
155+ }
144156 }
145157 }
146158 }
@@ -203,17 +215,11 @@ const PluginAnchorageRepair: React.FC = () => {
203215 )
204216
205217 // Helper to check if any other fleet has Nosaki in position 1 or 2
218+ // Uses lightweight checkNosakiPresent that doesn't require $ships
206219 const hasNosakiInOtherFleets = ( excludeFleetId : number ) =>
207220 fleets . some ( ( fleet ) => {
208221 if ( fleet . api_id === excludeFleetId ) return false
209- const status = getFleetStatus (
210- fleet ,
211- ships ,
212- $ships ,
213- repairId ,
214- equips ,
215- )
216- return status . nosakiPresent
222+ return checkNosakiPresent ( fleet , ships )
217223 } )
218224
219225 // Handle changes to slot 1/2 (position 0 or 1)
@@ -239,7 +245,7 @@ const PluginAnchorageRepair: React.FC = () => {
239245 // If timer hasn't started yet, start it;
240246 // otherwise, before 15 min, placing Nosaki resets timer.
241247 if ( lastNosakiRefresh === 0 ) {
242- timerState . setLastNosakiRefresh ( Date . now ( ) )
248+ timerState . setLastNosakiRefresh ( currentTime )
243249 } else if ( nosakiTimeElapsed < NOSAKI_INTERVAL / 1000 ) {
244250 timerState . resetNosakiTimer ( )
245251 }
0 commit comments