[AI] Remove grouped option from api/categories-get

The categories-get API now always returns a flat list of categories.
Use category-groups-get for grouped data instead.
This commit is contained in:
github-actions[bot]
2026-07-05 20:35:33 +01:00
parent af799718f8
commit f059a8e2a8
6 changed files with 13 additions and 17 deletions

View File

@@ -220,7 +220,7 @@ export function deleteCategoryGroup(
}
export function getCategories(options: { hidden?: boolean } = {}) {
return send('api/categories-get', { grouped: false, ...options });
return send('api/categories-get', options);
}
export function createCategory(category: Omit<APICategoryEntity, 'id'>) {

View File

@@ -649,14 +649,11 @@ handlers['api/account-balance'] = withMutation(async function ({
});
handlers['api/categories-get'] = async function ({
grouped,
hidden,
}: { grouped?: boolean; hidden?: boolean } = {}) {
}: { hidden?: boolean } = {}) {
checkFileOpen();
const result = await handlers['get-categories']({ hidden });
return grouped
? result.grouped.map(group => categoryGroupModel.toExternal(group))
: result.list.map(category => categoryModel.toExternal(category));
return result.list.map(category => categoryModel.toExternal(category));
};
handlers['api/category-groups-get'] = async function ({

View File

@@ -133,9 +133,7 @@ async function importTransactions(
data: YNAB4.YFull,
entityIdMap: Map<string, string>,
) {
const categories = await send('api/categories-get', {
grouped: false,
});
const categories = await send('api/categories-get');
const incomeCategoryId: string = categories.find(
cat => cat.name === 'Income',
).id;

View File

@@ -291,9 +291,7 @@ async function importCategories(
// Hidden categories are put in its own group by YNAB,
// so it's already handled.
const categories = await send('api/categories-get', {
grouped: false,
});
const categories = await send('api/categories-get');
const incomeCatId = findIdByName(categories, 'Income');
const ynabIncomeCategories = ['To be Budgeted', 'Inflow: Ready to Assign'];
@@ -572,9 +570,7 @@ async function importTransactions(
flagNameConflicts: Set<string>,
) {
const payees = await send('api/payees-get');
const categories = await send('api/categories-get', {
grouped: false,
});
const categories = await send('api/categories-get');
const incomeCatId = findIdByName(categories, 'Income');
const startingBalanceCatId = findIdByName(categories, 'Starting Balances'); //better way to do it?

View File

@@ -165,9 +165,8 @@ export type ApiHandlers = {
}) => Promise<number>;
'api/categories-get': (arg: {
grouped?: boolean;
hidden?: boolean;
}) => Promise<Array<APICategoryGroupEntity | APICategoryEntity>>;
}) => Promise<APICategoryEntity[]>;
'api/category-groups-get': (arg?: {
hidden?: boolean;

View File

@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [MatissJanis]
---
Simplify the getCategories API to always return a flat list of categories.