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:
parent
b8fc0a8033
commit
a5f286a76b
|
|
@ -14,6 +14,9 @@ from PyQt6.QtGui import QColor
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
|
|
||||||
from core.nexus_full_api import get_nexus_api, NexusAttachment
|
from core.nexus_full_api import get_nexus_api, NexusAttachment
|
||||||
|
import logging
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class AttachmentLoaderThread(QThread):
|
class AttachmentLoaderThread(QThread):
|
||||||
|
|
@ -24,8 +27,37 @@ class AttachmentLoaderThread(QThread):
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
api = get_nexus_api()
|
api = get_nexus_api()
|
||||||
attachments = api.get_all_attachments()
|
# Fetch all attachment types separately
|
||||||
self.attachments_loaded.emit(attachments)
|
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:
|
except Exception as e:
|
||||||
self.error_occurred.emit(str(e))
|
self.error_occurred.emit(str(e))
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue