fix(ui): update attachment selector to use new API endpoints

- Updated AttachmentLoaderThread to fetch from separate endpoints:
  - /weaponamplifiers for amplifiers
  - /weaponvisionattachments for scopes
  - /absorbers for absorbers
- Fixed get_all_attachments() AttributeError
This commit is contained in:
LemonNexus 2026-02-09 15:49:11 +00:00
parent b8fc0a8033
commit a5f286a76b
1 changed files with 34 additions and 2 deletions

View File

@ -14,6 +14,9 @@ from PyQt6.QtGui import QColor
from typing import Optional, List
from core.nexus_full_api import get_nexus_api, NexusAttachment
import logging
logger = logging.getLogger(__name__)
class AttachmentLoaderThread(QThread):
@ -24,8 +27,37 @@ class AttachmentLoaderThread(QThread):
def run(self):
try:
api = get_nexus_api()
attachments = api.get_all_attachments()
self.attachments_loaded.emit(attachments)
# Fetch all attachment types separately
all_attachments = []
# Get amplifiers
try:
amps = api.get_all_amplifiers()
for amp in amps:
amp.attachment_type = "amplifier"
all_attachments.extend(amps)
except Exception as e:
logger.warning(f"Could not load amplifiers: {e}")
# Get scopes/sights
try:
scopes = api.get_all_scopes()
for scope in scopes:
scope.attachment_type = "scope"
all_attachments.extend(scopes)
except Exception as e:
logger.warning(f"Could not load scopes: {e}")
# Get absorbers
try:
absorbers = api.get_all_absorbers()
for absorber in absorbers:
absorber.attachment_type = "absorber"
all_attachments.extend(absorbers)
except Exception as e:
logger.warning(f"Could not load absorbers: {e}")
self.attachments_loaded.emit(all_attachments)
except Exception as e:
self.error_occurred.emit(str(e))