Merge pull request #3790 from gitbutlerapp/update-ipc-code

Update IPC imports and remove old logic
This commit is contained in:
Kiril Videlov 2024-05-19 23:16:47 +02:00 committed by GitHub
commit e3cb98d1ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 3 additions and 28 deletions

View File

@ -1,4 +1,4 @@
import { invoke } from './ipc';
import { invoke } from '$lib/backend/ipc';
export type GitCredentialCheck = {
error?: string;

View File

@ -1,4 +1,4 @@
import { invoke } from '@tauri-apps/api/tauri';
import { invoke } from '$lib/backend/ipc';
export class GitConfigService {
async get<T extends string>(key: string): Promise<T | undefined> {

View File

@ -1,6 +1,5 @@
import { listen as listenTauri } from '@tauri-apps/api/event';
import { invoke as invokeTauri } from '@tauri-apps/api/tauri';
import { writable } from 'svelte/store';
import type { EventCallback, EventName } from '@tauri-apps/api/event';
export enum Code {
@ -31,26 +30,6 @@ export class UserError extends Error {
}
}
interface LoadItem {
name: string;
startedAt: Date;
}
const loadingStore = writable(false);
export const loadStack: LoadItem[] = [];
export const isLoading = {
...loadingStore,
loadStack,
push: (item: LoadItem) => {
loadStack.push(item);
loadingStore.set(true);
},
pop: (item: LoadItem) => {
const i = loadStack.indexOf(item);
loadStack.splice(i, 1);
if (loadStack.length == 0) loadingStore.set(false);
}
};
export async function invoke<T>(command: string, params: Record<string, unknown> = {}): Promise<T> {
// This commented out code can be used to delay/reject an api call
// return new Promise<T>((resolve, reject) => {
@ -66,8 +45,6 @@ export async function invoke<T>(command: string, params: Record<string, unknown>
// console.error(`ipc->${command}: ${JSON.stringify(params)}`, userError);
// throw userError;
// });
const loadingItem = { name: command, startedAt: new Date() };
isLoading.push(loadingItem);
try {
return await invokeTauri<T>(command, params);
@ -75,8 +52,6 @@ export async function invoke<T>(command: string, params: Record<string, unknown>
const userError = UserError.fromError(reason);
console.error(`ipc->${command}: ${JSON.stringify(params)}`, userError, reason);
throw userError;
} finally {
isLoading.pop(loadingItem);
}
}

View File

@ -3,8 +3,8 @@
* it's here is because the type is in this package.
*/
import { RemoteFile } from './types';
import { invoke } from '$lib/backend/ipc';
import { ContentSection, HunkSection, parseFileSections } from '$lib/utils/fileSections';
import { invoke } from '@tauri-apps/api/tauri';
import { plainToInstance } from 'class-transformer';
export async function listRemoteCommitFiles(projectId: string, commitOid: string) {