fix: correct Settings actions in Laya ready state and clear stale AI warning (#12)
Offer the right actions in Settings when Laya is ready/available instead of leaving irrelevant ones, and stop showing the ChannelList local-AI warning once the runtime is actually available. Derive both from layaStatusPresentation and cover the ready/available action set with tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -363,14 +363,19 @@ class ChannelList {
|
||||
const results = new Map();
|
||||
try {
|
||||
const status = await API.laya.getStatus();
|
||||
if (!status?.modelPresent || !status?.runtimeAvailable) {
|
||||
const statusWarning = LayaStatusPresentation.channelListWarning(mode, status);
|
||||
if (statusWarning) {
|
||||
if (requestId !== this._languageDetectionRequest) return;
|
||||
this.layaLanguageResults.clear();
|
||||
this.languageDetectionFallback = true;
|
||||
this.languageDetectionNotice = 'Local AI service is unavailable. Standard channel matching is being used.';
|
||||
this.languageDetectionNotice = statusWarning;
|
||||
this.render();
|
||||
return;
|
||||
}
|
||||
if (requestId !== this._languageDetectionRequest) return;
|
||||
this.languageDetectionNotice = '';
|
||||
this.languageDetectionFallback = false;
|
||||
this.render();
|
||||
for (let index = 0; index < descriptors.length; index += 64) {
|
||||
const response = await API.laya.detectLanguages(descriptors.slice(index, index + 64));
|
||||
(response.results || []).forEach(result => results.set(String(result.id), result));
|
||||
@ -383,7 +388,7 @@ class ChannelList {
|
||||
if (requestId !== this._languageDetectionRequest) return;
|
||||
this.layaLanguageResults.clear();
|
||||
this.languageDetectionFallback = true;
|
||||
this.languageDetectionNotice = 'Local AI service is unavailable. Standard channel matching is being used.';
|
||||
this.languageDetectionNotice = LayaStatusPresentation.channelListWarning(mode, {}, true);
|
||||
console.warn('[ChannelList] Local AI language detection unavailable:', err.message);
|
||||
}
|
||||
this.render();
|
||||
@ -442,6 +447,7 @@ class ChannelList {
|
||||
window.app?.navigateTo?.('settings');
|
||||
window.app?.pages?.settings?.switchTab?.('player');
|
||||
});
|
||||
notice.appendChild(document.createTextNode(' '));
|
||||
notice.appendChild(settingsButton);
|
||||
this.container.appendChild(notice);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user