changes_3

This commit is contained in:
Mateusz Gruszczyński
2026-05-20 07:38:59 +02:00
parent 5bb32234d4
commit 7401feff63

View File

@@ -1,156 +1,150 @@
// Note: User-facing toast and modal copy is centralized here. export const messagesSource = `
const APP_MESSAGES = {
actions: {
raw_torrent: 'Add torrent',
add: 'Add torrent',
start: 'Start torrent',
pause: 'Pause torrent',
stop: 'Stop torrent',
resume: 'Resume torrent',
remove: 'Remove torrent',
erase: 'Delete torrent',
delete: 'Delete torrent',
move: 'Move torrent',
recheck: 'Force recheck',
reannounce: 'Reannounce',
set_label: 'Update label',
label: 'Update label'
},
toast: { const APP_MESSAGES = {
operationStarted: ({ action }) => `${actionLabel(action)} started`, actions: {
raw_torrent: 'Add torrent',
add: 'Add torrent',
start: 'Start torrent',
pause: 'Pause torrent',
stop: 'Stop torrent',
resume: 'Resume torrent',
remove: 'Remove torrent',
erase: 'Delete torrent',
delete: 'Delete torrent',
move: 'Move torrent',
recheck: 'Force recheck',
reannounce: 'Reannounce',
set_label: 'Update label',
label: 'Update label'
},
operationDone: ({ action }) => `${actionLabel(action)} done`, toast: {
operationStarted: ({ action }) => \`\${actionLabel(action)} started\`,
operationFailed: ({ action, error }) => operationDone: ({ action }) => \`\${actionLabel(action)} done\`,
`${actionLabel(action)} failed: ${error || 'unknown error'}`,
actionQueued: ({ action, parts }) => operationFailed: ({ action, error }) =>
Number(parts || 1) > 1 \`\${actionLabel(action)} failed: \${error || 'unknown error'}\`,
? `${actionLabel(action)} queued in ${parts} parts`
: `${actionLabel(action)} queued`,
moveQueued: ({ parts, physical }) => actionQueued: ({ action, parts }) =>
Number(parts || 1) > 1 Number(parts || 1) > 1
? `Move queued in ${parts} parts` ? \`\${actionLabel(action)} queued in \${parts} parts\`
: physical : \`\${actionLabel(action)} queued\`,
? 'Physical move queued'
: 'Move queued',
addQueued: () => 'Torrent add queued', moveQueued: ({ parts, physical }) =>
Number(parts || 1) > 1
? \`Move queued in \${parts} parts\`
: physical
? 'Physical move queued'
: 'Move queued',
addQueuedSkipped: ({ count }) => addQueued: () => 'Torrent add queued',
`Torrent add queued, skipped ${count} duplicate torrent(s)`,
addTooLarge: () => addQueuedSkipped: ({ count }) =>
'One or more .torrent files exceed the current rTorrent XML-RPC upload limit. Open rTorrent config and set network.xmlrpc.size_limit to e.g. 16M.', \`Torrent add queued, skipped \${count} duplicate torrent(s)\`,
dropOnlyTorrents: () => 'Drop .torrent files only', addTooLarge: () =>
'One or more .torrent files exceed the current rTorrent XML-RPC upload limit. Open rTorrent config and set network.xmlrpc.size_limit to e.g. 16M.',
droppedAddedSkipped: ({ queued, skipped }) => dropOnlyTorrents: () => 'Drop .torrent files only',
`Added ${queued} torrent(s), skipped ${skipped} duplicate(s)`,
droppedAdded: ({ queued }) => `Added ${queued} torrent(s)`, droppedAddedSkipped: ({ queued, skipped }) =>
\`Added \${queued} torrent(s), skipped \${skipped} duplicate(s)\`,
droppedSkipped: ({ skipped }) => droppedAdded: ({ queued }) => \`Added \${queued} torrent(s)\`,
`Skipped ${skipped} duplicate torrent(s)`,
droppedNone: () => 'No torrents were added', droppedSkipped: ({ skipped }) =>
\`Skipped \${skipped} duplicate torrent(s)\`,
noTorrentsSelected: () => 'No torrents selected', droppedNone: () => 'No torrents were added',
noTorrentSelected: () => 'No torrent selected', noTorrentsSelected: () => 'No torrents selected',
noFilesSelected: () => 'No files selected', noTorrentSelected: () => 'No torrent selected',
downloadStarted: () => 'Download started', noFilesSelected: () => 'No files selected',
chunkActionDone: ({ action }) => `${actionLabel(action)} done`, downloadStarted: () => 'Download started',
trackerActionDone: ({ action }) => `${actionLabel(action)} done`, chunkActionDone: ({ action }) => \`\${actionLabel(action)} done\`,
pathPickerUnavailable: () => 'Path picker is unavailable', trackerActionDone: ({ action }) => \`\${actionLabel(action)} done\`,
pathEmpty: () => 'Path is empty', pathPickerUnavailable: () => 'Path picker is unavailable',
columnsSaved: () => 'Columns saved', pathEmpty: () => 'Path is empty',
recommendedColumnsApplied: () => 'Recommended columns applied', columnsSaved: () => 'Columns saved',
jobLogsCleared: ({ deleted }) => recommendedColumnsApplied: () => 'Recommended columns applied',
`Cleared ${deleted || 0} finished job log(s)`,
emergencyJobLogsCleared: ({ deleted }) => jobLogsCleared: ({ deleted }) =>
`Emergency cleanup removed ${deleted || 0} job log(s)`, \`Cleared \${deleted || 0} finished job log(s)\`,
rtorrentConfigSaved: ({ updated }) => emergencyJobLogsCleared: ({ deleted }) =>
`rTorrent config saved (${updated || 0})`, \`Emergency cleanup removed \${deleted || 0} job log(s)\`,
rtorrentConfigReset: ({ removed }) => rtorrentConfigSaved: ({ updated }) =>
`rTorrent config reset (${removed || 0} override(s) removed)`, \`rTorrent config saved (\${updated || 0})\`,
automationLogsDeleted: ({ deleted }) => rtorrentConfigReset: ({ removed }) =>
`Automation logs deleted: ${deleted || 0}`, \`rTorrent config reset (\${removed || 0} override(s) removed)\`,
cleanupDone: ({ deleted }) => `Cleanup done (${deleted})`, automationLogsDeleted: ({ deleted }) =>
\`Automation logs deleted: \${deleted || 0}\`,
plannerApplied: ({ dryRun, paused, resumed, limitsChanged }) => cleanupDone: ({ deleted }) => \`Cleanup done (\${deleted})\`,
`${dryRun ? 'Planner dry-run' : 'Planner applied'}: paused ${
paused || 0
}, resumed ${resumed || 0}, limits ${
limitsChanged ? 'changed' : 'unchanged'
}`,
rssQueued: ({ queued }) => `RSS queued ${queued || 0} item(s)`, plannerApplied: ({ dryRun, paused, resumed, limitsChanged }) =>
\`\${dryRun ? 'Planner dry-run' : 'Planner applied'}: paused \${paused || 0}, resumed \${resumed || 0}, limits \${limitsChanged ? 'changed' : 'unchanged'}\`,
smartQueueCheckQueued: () => rssQueued: ({ queued }) => \`RSS queued \${queued || 0} item(s)\`,
'Smart Queue check queued. It will continue in the background.',
automationForceRunDone: ({ count }) => smartQueueCheckQueued: () =>
`Automation force run done (${count || 0} torrent item(s))`, 'Smart Queue check queued. It will continue in the background.',
automationsApplied: ({ count, batches }) => automationForceRunDone: ({ count }) =>
batches \`Automation force run done (\${count || 0} torrent item(s))\`,
? `Automations applied ${count || 0} torrent(s) in ${
batches || 0
} batch(es)`
: `Automations applied ${count || 0} item(s)`,
torrentStatsError: ({ error }) => `Torrent stats: ${error}`, automationsApplied: ({ count, batches }) =>
batches
? \`Automations applied \${count || 0} torrent(s) in \${batches || 0} batch(es)\`
: \`Automations applied \${count || 0} item(s)\`,
startupConfigApplied: ({ count }) => torrentStatsError: ({ error }) => \`Torrent stats: \${error}\`,
`Startup rTorrent config applied (${count || 0})`,
startupConfigFailed: ({ error }) => startupConfigApplied: ({ count }) =>
`Startup rTorrent config: ${error}`, \`Startup rTorrent config applied (\${count || 0})\`,
plannerSocketResult: ({ paused, resumed, dryRun }) => startupConfigFailed: ({ error }) =>
`Planner: paused ${paused || 0}, resumed ${resumed || 0}${ \`Startup rTorrent config: \${error}\`,
dryRun ? ' dry-run' : ''
}`
}
};
function actionLabel(action) { plannerSocketResult: ({ paused, resumed, dryRun }) =>
const key = String(action || '').trim(); \`Planner: paused \${paused || 0}, resumed \${resumed || 0}\${dryRun ? ' dry-run' : ''}\`
}
};
if (APP_MESSAGES.actions[key]) { function actionLabel(action) {
return APP_MESSAGES.actions[key]; const key = String(action || '').trim();
if (APP_MESSAGES.actions[key]) {
return APP_MESSAGES.actions[key];
}
return key
? key.replace(/[_-]+/g, ' ').replace(/\\b\\w/g, (c) => c.toUpperCase())
: 'Operation';
} }
return key function appMessage(key, params = {}) {
? key.replace(/[_-]+/g, ' ').replace(/\b\w/g, (c) => c.toUpperCase()) const fn = key
: 'Operation'; .split('.')
} .reduce((acc, part) => acc && acc[part], APP_MESSAGES);
function appMessage(key, params = {}) { return typeof fn === 'function' ? fn(params) : String(fn || key);
const fn = key }
.split('.')
.reduce((acc, part) => acc && acc[part], APP_MESSAGES);
return typeof fn === 'function' ? fn(params) : String(fn || key); function toastMessage(key, type = 'secondary', params = {}) {
} toast(appMessage(key, params), type);
}
function toastMessage(key, type = 'secondary', params = {}) { `;
toast(appMessage(key, params), type);
}