feat(nodes): set refresh interval, User-Agent and cache when adding a subscription

The add dialog shows each option the backend lists in create_options: the interval as the table's presets with the default preselected, the User-Agent with the default as placeholder, and the cache switch with a line of help. Only a value that differs from the default is sent, so an untouched entry stays one line. The e2e mock backend now serves provider create and refresh.
This commit is contained in:
Zakk committed 2026-09-25 23:09:34 +10:00
1 parent df9d024e0c
commit ca2b5be0fe
12 files changed
+192 -17

No files matched your search

+3 -1
View File
@@ -123,7 +123,9 @@ it('writes subscription options as a block, checks them against create_options a
expect(await main()).toBe(before);
const created = await api.createProvider({name: 'optioned', ...base, update_interval: 3600, user_agent: 'clash.meta', cache: false});
expect(created).toMatchObject({name: 'optioned', url_redacted: 'https://example.net/sub?[redacted]'});
expect(await main()).toContain(" optioned: {\n url: 'https://example.net/sub?token=x'\n ua: 'clash.meta'\n interval: '3600s'\n cache: false\n }\n");
expect(await main()).toContain(
" optioned: {\n url: 'https://example.net/sub?token=x'\n ua: 'clash.meta'\n interval: '3600s'\n cache: false\n }\n"
);
await api.deleteProvider(created.id);
expect(await main()).toBe(before);
});
+5 -1
View File
@@ -250,7 +250,11 @@ export function createInventory(
)
throw new ApiError(422, 'unsupported_value', 'The subscription options are not supported');
// Like honk, an entry with options becomes a block; one without stays a scalar line.
const fields = [agent !== undefined && `ua: ${quote(agent)}`, interval !== undefined && `interval: '${interval}s'`, cache !== undefined && `cache: ${cache}`];
const fields = [
agent !== undefined && `ua: ${quote(agent)}`,
interval !== undefined && `interval: '${interval}s'`,
cache !== undefined && `cache: ${cache}`
];
const options = fields.filter(Boolean).map(field => ` ${field}\n`);
const line = configLine(() =>
options.length