fix(ui): align the subUpdates limit with the backend and show the range

The hand-written settings schema capped subUpdates at 168 while the
backend (and the generated schema mirrored from it) accepts 0-525600.
Anyone upgrading from 2.x with a stored value above 168 could no longer
save any settings tab: the whole settings object is validated on every
save, so the stale field blocked everything with an unexplained
"Invalid input". Match the backend bounds and put them on the input so
the limit is discoverable.

Closes #5821
This commit is contained in:
MHSanaei
2026-07-05 20:12:21 +02:00
parent b6d1caf95d
commit 0add63984f
3 changed files with 19 additions and 2 deletions
@@ -79,7 +79,7 @@ export default function SubscriptionGeneralTab({ allSetting, updateSetting }: Su
</SettingListItem>
<SettingListItem paddings="small" title={t('pages.settings.subUpdates')} description={t('pages.settings.subUpdatesDesc')}>
<InputNumber value={allSetting.subUpdates} min={1} style={{ width: '100%' }}
<InputNumber value={allSetting.subUpdates} min={0} max={525600} style={{ width: '100%' }}
onChange={(v) => updateSetting({ subUpdates: Number(v) || 0 })} />
</SettingListItem>
</>
+1 -1
View File
@@ -53,7 +53,7 @@ export const AllSettingSchema = z.object({
restartXrayOnClientDisable: z.boolean().optional(),
subCertFile: z.string().optional(),
subKeyFile: z.string().optional(),
subUpdates: z.number().int().min(1).max(168).optional(),
subUpdates: z.number().int().min(0).max(525600).optional(),
subEncrypt: z.boolean().optional(),
subURI: z.string().optional(),
subJsonURI: z.string().optional(),
@@ -0,0 +1,17 @@
import { describe, it, expect } from 'vitest';
import { AllSettingSchema } from '@/schemas/setting';
describe('subUpdates range', () => {
it('accepts values the backend allows (gte=0, lte=525600)', () => {
for (const v of [0, 12, 168, 720, 525600]) {
const r = AllSettingSchema.safeParse({ subUpdates: v });
expect(r.success, `subUpdates=${v} should be valid`).toBe(true);
}
});
it('rejects values outside the backend range', () => {
for (const v of [-1, 525601, 1.5]) {
expect(AllSettingSchema.safeParse({ subUpdates: v }).success, `subUpdates=${v} should be invalid`).toBe(false);
}
});
});