Skip to content

Commit

Permalink
refactor: fix typescript issues
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Nov 29, 2022
1 parent 89a12b1 commit 8eb7879
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
3 changes: 1 addition & 2 deletions package/src/store/QuickSqliteClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,12 @@ export class QuickSqliteClient {
};

static executeSql = (query: string, params?: string[]) => {
this.openDB();

if (this.isQuickSqliteV4) {
return QuickSqliteClient_v4.executeSql(query, params);
}

try {
this.openDB();
const { rows } = sqlite.execute(DB_NAME, query, params);
this.closeDB();

Expand Down
3 changes: 2 additions & 1 deletion package/src/store/apis/getPendingTasks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { mapStorableToTask } from '../mappers/mapStorableToTask';
import { QuickSqliteClient } from '../QuickSqliteClient';
import { createSelectQuery } from '../sqlite-utils/createSelectQuery';
import type { TableRowJoinedUser } from '../types';

export const getPendingTasks = (conditions: { messageId?: string } = {}) => {
const query = createSelectQuery('pendingTasks', ['*'], conditions, {
Expand All @@ -9,5 +10,5 @@ export const getPendingTasks = (conditions: { messageId?: string } = {}) => {

const result = QuickSqliteClient.executeSql.apply(null, query);

return result.map((r) => mapStorableToTask(r));
return result.map((r: TableRowJoinedUser<'pendingTasks'>) => mapStorableToTask(r));
};
5 changes: 4 additions & 1 deletion package/src/store/apis/queries/selectChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ export const selectChannels = ({
const result = QuickSqliteClient.executeSql.apply(null, query);

if (channelIds) {
return result.sort((a, b) => channelIds.indexOf(a.cid) - channelIds.indexOf(b.cid));
return result.sort(
(a: { cid: string }, b: { cid: string }) =>
channelIds.indexOf(a.cid) - channelIds.indexOf(b.cid),
);
} else {
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion package/src/store/apis/queries/selectMembersForChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,5 @@ export const selectMembersForChannels = (cids: string[]): TableRowJoinedUser<'me
cids,
);

return result.map((r) => JSON.parse(r.value));
return result.map((r: { value: string }) => JSON.parse(r.value));
};
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ export const selectMessagesForChannels = (cids: string[]): TableRowJoinedUser<'m
cids,
);

return result.map((r) => JSON.parse(r.value));
return result.map((r: { value: string }) => JSON.parse(r.value));
};
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ export const selectReactionsForMessages = (
messageIds,
);

return result.map((r) => JSON.parse(r.value));
return result.map((r: { value: string }) => JSON.parse(r.value));
};
2 changes: 1 addition & 1 deletion package/src/store/apis/queries/selectReadsForChannels.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ export const selectReadsForChannels = (cids: string[]): TableRowJoinedUser<'read
cids,
);

return result.map((r) => JSON.parse(r.value));
return result.map((r: { value: string }) => JSON.parse(r.value));
};

0 comments on commit 8eb7879

Please sign in to comment.