Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdoming committed Jan 18, 2025
1 parent c84628a commit 6b43e75
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 30 deletions.
4 changes: 2 additions & 2 deletions packages/desktop-client/src/components/accounts/Account.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -718,7 +718,7 @@ class AccountInternal extends PureComponent<
}

const { data } = await runQuery(
this.paged?.query
this.paged.query
.options({ splits: 'none' })
.select([{ balance: { $sumOver: '$amount' } }]),
);
Expand Down Expand Up @@ -939,7 +939,7 @@ class AccountInternal extends PureComponent<
}

const { data: amount } = await runQuery(
this.paged?.query.calculate({ $sum: '$amount' }),
this.paged.query.calculate({ $sum: '$amount' }),
);
return amount;
};
Expand Down
8 changes: 4 additions & 4 deletions packages/desktop-client/src/components/modals/EditUser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ function useSaveUser() {
user: User,
setError: (error: string) => void,
): Promise<boolean> {
const res = (await send(method, user)) || {};
if (!res['error']) {
const newId = res['id'];
const res = await send(method, user);
if (!('error' in res)) {
const newId = res.id;
if (newId) {
user.id = newId;
}
} else {
const error = res['error'];
const error = res.error;
setError(getUserDirectoryErrors(error));
if (error === 'token-expired') {
dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ export function Overview() {
const res = await send('dashboard-import', { filepath });
setIsImporting(false);

if (res.error) {
if ('error' in res) {
switch (res.error) {
case 'json-parse-error':
dispatch(
Expand Down
2 changes: 1 addition & 1 deletion packages/loot-core/src/client/actions/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function loadPrefs() {
);

// We need to load translations before the app renders
setI18NextLanguage(globalPrefs.language);
setI18NextLanguage(globalPrefs.language ?? '');

return prefs;
};
Expand Down
3 changes: 2 additions & 1 deletion packages/loot-core/src/platform/client/fetch/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ export type Unlisten = typeof unlisten;
/** Mock functions */
export function initServer(handlers: {
query: (query: { table: string; selectExpressions: unknown }) => Promise<{
data: unknown;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
data: any;
dependencies: string[];
}>;
getCell?: () => { value: number };
Expand Down
8 changes: 2 additions & 6 deletions packages/loot-core/src/server/admin/types/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ export interface AdminHandlers {

'user-add': (
user: Omit<UserEntity, 'id'>,
) => Promise<
{ error?: string; id?: undefined } | { error?: undefined; id: string }
>;
) => Promise<{ error: string } | { id: string }>;

'user-update': (
user: Omit<UserEntity, 'id'>,
) => Promise<
{ error?: string; id?: undefined } | { error?: undefined; id: string }
>;
) => Promise<{ error: string } | { id: string }>;

'access-add': (
user: NewUserAccessEntity,
Expand Down
7 changes: 2 additions & 5 deletions packages/loot-core/src/server/aql/compiler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getNormalisedString } from '../../shared/normalisation';
import { QueryState } from '../../shared/query';

// @ts-strict-ignore
let _uid = 0;
Expand Down Expand Up @@ -1005,11 +1006,7 @@ export type SchemaConfig = {
| Record<string, unknown>
| ((name: string, config: { withDead; isJoin; tableOptions }) => unknown);
tableFilters?: (name: string) => unknown[];
customizeQuery?: <
T extends { table: string; orderExpressions: readonly unknown[] },
>(
queryString: T,
) => T;
customizeQuery?: (queryString: QueryState) => QueryState;
views?: Record<
string,
{
Expand Down
4 changes: 2 additions & 2 deletions packages/loot-core/src/server/dashboard/types/handlers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ export interface DashboardHandlers {
'dashboard-import': (args: {
filepath: string;
}) => Promise<
| { error?: undefined; message?: undefined; status: 'ok' }
| { error: 'json-parse-error' | 'internal-error'; message?: undefined }
| { status: 'ok' }
| { error: 'json-parse-error' | 'internal-error' }
| { error: 'validation-error'; message: string }
>;
}
2 changes: 1 addition & 1 deletion packages/loot-core/src/server/rules/types/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export interface RulesHandlers {

'rules-get': () => Promise<RuleEntity[]>;

'rule-get': (arg: { id: string }) => Promise<RuleEntity>;
'rule-get': (arg: { id: RuleEntity['id'] }) => Promise<RuleEntity>;

'rules-run': (arg: {
transaction: TransactionEntity;
Expand Down
14 changes: 9 additions & 5 deletions packages/loot-core/src/server/schedules/types/handlers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// @ts-strict-ignore
import { DiscoverScheduleEntity } from '../../../types/models';
import { DiscoverScheduleEntity, ScheduleEntity } from '../../../types/models';

export interface SchedulesHandlers {
'schedule/create': (arg: {
Expand All @@ -15,13 +15,17 @@ export interface SchedulesHandlers {
schedule;
conditions?;
resetNextDate?: boolean;
}) => Promise<string>;
}) => Promise<ScheduleEntity['id']>;

'schedule/delete': (arg: { id: string }) => Promise<void>;
'schedule/delete': (arg: { id: ScheduleEntity['id'] }) => Promise<void>;

'schedule/skip-next-date': (arg: { id: string }) => Promise<void>;
'schedule/skip-next-date': (arg: {
id: ScheduleEntity['id'];
}) => Promise<void>;

'schedule/post-transaction': (arg: { id: string }) => Promise<void>;
'schedule/post-transaction': (arg: {
id: ScheduleEntity['id'];
}) => Promise<void>;

'schedule/force-run-service': () => Promise<unknown>;

Expand Down
5 changes: 3 additions & 2 deletions packages/loot-core/src/types/server-handlers.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export interface ServerHandlers {

'payees-get': () => Promise<PayeeEntity[]>;

'payees-get-rule-counts': () => Promise<Record<string, number>>;
'payees-get-rule-counts': () => Promise<Record<PayeeEntity['id'], number>>;

'payees-merge': (arg: { targetId; mergeIds }) => Promise<void>;

Expand Down Expand Up @@ -141,7 +141,8 @@ export interface ServerHandlers {

'create-query': (arg: { sheetName; name; query }) => Promise<unknown>;

query: (query: Query) => Promise<{ data: unknown; dependencies: string[] }>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
query: (query: Query) => Promise<{ data: any; dependencies: string[] }>;

'account-update': (arg: { id; name }) => Promise<unknown>;

Expand Down

0 comments on commit 6b43e75

Please sign in to comment.