Optional VR overlay template
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
1 parent
9a3dd06fb5
commit
c226195255
2 files changed
+39
-17
No files matched your search
+30
-17
@@ -186,27 +186,40 @@ async function sendNative(ctx: Ctx, wants: { readonly desktop: boolean; readonly
|
|||||||
ctx.logger.debug(`Bridge targets not available: ${String(error)}`);
|
ctx.logger.debug(`Bridge targets not available: ${String(error)}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const sinks = pickSinks(targets, wants.desktop, wants.vr);
|
const values = ctx.settings.values;
|
||||||
if (sinks.length === 0) {
|
const desktopSinks = wants.desktop ? pickSinks(targets, true, false) : [];
|
||||||
|
const vrSinks = wants.vr ? pickSinks(targets, false, true) : [];
|
||||||
|
if (desktopSinks.length === 0 && vrSinks.length === 0) {
|
||||||
ctx.logger.debug('The bridge has no target for the enabled channels.');
|
ctx.logger.debug('The bridge has no target for the enabled channels.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
const values = ctx.settings.values;
|
// VR overlays get their own template when one is set: WayVR draws with a single font and
|
||||||
const lines = reportLines(report, values.template, (e) => { warnTemplate(ctx, e); });
|
// shows nothing for emoji, so the rich format is often wrong there.
|
||||||
const result = await ctx.native.notify({
|
const vrTemplate = values.templateVr.trim() === '' ? values.template : values.templateVr;
|
||||||
title: lines[0] ?? `${report.joiner.name} joined`,
|
const batches: { readonly sinks: readonly string[]; readonly template: string }[] =
|
||||||
content: lines.slice(1).join('\n'),
|
vrTemplate === values.template
|
||||||
timeoutSecs: values.notifyTimeoutSecs,
|
? [{ sinks: [...desktopSinks, ...vrSinks], template: values.template }]
|
||||||
icon: 'security-high',
|
: [{ sinks: desktopSinks, template: values.template }, { sinks: vrSinks, template: vrTemplate }];
|
||||||
sinks,
|
|
||||||
// Never critical: KDE ignores the expiry for critical notifications and keeps them on screen.
|
let delivered = false;
|
||||||
urgency: 'normal',
|
for (const batch of batches.filter((b) => b.sinks.length > 0)) {
|
||||||
});
|
const lines = reportLines(report, batch.template, (e) => { warnTemplate(ctx, e); });
|
||||||
for (const failure of result.failed) {
|
const result = await ctx.native.notify({
|
||||||
if (failure.sink !== 'bridge') ctx.logger.warn(`Bridge target ${failure.sink} failed: ${failure.error}`);
|
title: lines[0] ?? `${report.joiner.name} joined`,
|
||||||
|
content: lines.slice(1).join('\n'),
|
||||||
|
timeoutSecs: values.notifyTimeoutSecs,
|
||||||
|
icon: 'security-high',
|
||||||
|
sinks: batch.sinks,
|
||||||
|
// Never critical: KDE ignores the expiry for critical notifications and keeps them on screen.
|
||||||
|
urgency: 'normal',
|
||||||
|
});
|
||||||
|
for (const failure of result.failed) {
|
||||||
|
if (failure.sink !== 'bridge') ctx.logger.warn(`Bridge target ${failure.sink} failed: ${failure.error}`);
|
||||||
|
}
|
||||||
|
delivered ||= result.ok;
|
||||||
}
|
}
|
||||||
if (!result.ok) ctx.logger.debug('Bridge not reachable or every target refused; falling back.');
|
if (!delivered) ctx.logger.debug('Bridge not reachable or every target refused; falling back.');
|
||||||
return result.ok;
|
return delivered;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function sendDesktopAndVr(ctx: Ctx, values: SettingsValues<Settings>, report: Report): Promise<void> {
|
async function sendDesktopAndVr(ctx: Ctx, values: SettingsValues<Settings>, report: Report): Promise<void> {
|
||||||
|
|||||||
@@ -99,6 +99,15 @@ export const settings = {
|
|||||||
'ageVerifiedEmoji pcRankEmoji questRankEmoji platformEmoji inGroupEmoji rejoinEmoji.',
|
'ageVerifiedEmoji pcRankEmoji questRankEmoji platformEmoji inGroupEmoji rejoinEmoji.',
|
||||||
default: DEFAULT_TEMPLATE,
|
default: DEFAULT_TEMPLATE,
|
||||||
},
|
},
|
||||||
|
templateVr: {
|
||||||
|
kind: 'string',
|
||||||
|
multiline: true,
|
||||||
|
label: 'VR overlay template (optional)',
|
||||||
|
description:
|
||||||
|
'Used for VR overlay targets instead of the report template. Leave empty to use the same. WayVR draws with one ' +
|
||||||
|
'font and shows nothing for emoji and most symbols, so keep this to plain text.',
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
notifyToast: {
|
notifyToast: {
|
||||||
kind: 'boolean',
|
kind: 'boolean',
|
||||||
label: 'In-app toast',
|
label: 'In-app toast',
|
||||||
|
|||||||
Reference in new issue
Block a user