diff --git a/packages/main/src/index.ts b/packages/main/src/index.ts index 68cab958..20f16bd3 100644 --- a/packages/main/src/index.ts +++ b/packages/main/src/index.ts @@ -53,6 +53,7 @@ const initCore = async () => { process.env['PATH'] += process_path_separator + [process.resourcesPath,'git-binaries','mac',architecture].join(PATH.sep); } ipcMain.handle('CORE.getVersion', ()=>app.getVersion()); + ipcMain.handle('CORE.getTempPath', ()=>app.getPath('temp')); } /** diff --git a/packages/preload/src/ipc.ts b/packages/preload/src/ipc.ts index f10428f8..f1b2d2e5 100644 --- a/packages/preload/src/ipc.ts +++ b/packages/preload/src/ipc.ts @@ -12,10 +12,9 @@ exposeInMainWorld( // From main to render. // eslint-disable-next-line @typescript-eslint/ban-types on: (channel: string, listener: Function) => { - ipcRenderer.on(channel, (event, ...args) => listener(...args)); - }, - off: (channel: string, listener: Function) => { - ipcRenderer.removeListener(channel, (event, ...args) => listener(...args)); + const listener_ = (event, ...args) => listener(...args); + ipcRenderer.on(channel, listener_); + return ()=>ipcRenderer.removeListener(channel, listener_); }, // From render to main and back again. // eslint-disable-next-line @typescript-eslint/no-explicit-any diff --git a/packages/renderer/src/dialogs/GitDialog.vue b/packages/renderer/src/dialogs/GitDialog.vue index 34fa5e26..e9c98e27 100644 --- a/packages/renderer/src/dialogs/GitDialog.vue +++ b/packages/renderer/src/dialogs/GitDialog.vue @@ -14,7 +14,8 @@ const props = defineProps(); const iProps = reactive({ height: 0, - rows: [''] + rows: [''], + git_listener: null }); const scrollarea = ref(null); @@ -53,9 +54,9 @@ const processGitStream = async row=>{ onMounted( ()=>{ iProps.rows = ['']; - window.ipc.on('GitService.MSG', processGitStream); + iProps.git_listener = window.ipc.on('GitService.MSG', processGitStream); }); -onUnmounted( ()=>window.ipc.off('GitService.MSG', processGitStream) ); +onUnmounted( ()=>iProps.git_listener() ); const { dialogRef, onDialogHide, onDialogOK, onDialogCancel } = useDialogPluginComponent(); diff --git a/packages/renderer/src/views/ArcTreeView.vue b/packages/renderer/src/views/ArcTreeView.vue index a2bfb7e6..ffdffddf 100644 --- a/packages/renderer/src/views/ArcTreeView.vue +++ b/packages/renderer/src/views/ArcTreeView.vue @@ -46,6 +46,8 @@ let init: { const emit = defineEmits(['openArc']); +let update_path_listener=null; + const props = reactive(init); const arcTree = ref(null); @@ -583,8 +585,8 @@ const onCellContextMenu = async (e,node) => { // } }; -onMounted( ()=>{window.ipc.on('LocalFileSystemService.updatePath', updatePath);} ); -onUnmounted( ()=>{window.ipc.off('LocalFileSystemService.updatePath', updatePath);} ); +onMounted( ()=>{update_path_listener = window.ipc.on('LocalFileSystemService.updatePath', updatePath);} ); +onUnmounted( ()=>{update_path_listener();} ); watch(()=>AppProperties.force_lfs_update, updateLFSFiles); diff --git a/packages/renderer/src/views/DataHubView.vue b/packages/renderer/src/views/DataHubView.vue index d88fdddd..83ac31d4 100644 --- a/packages/renderer/src/views/DataHubView.vue +++ b/packages/renderer/src/views/DataHubView.vue @@ -13,7 +13,6 @@ import ArcControlService from '../ArcControlService.ts'; import { useQuasar } from 'quasar' const $q = useQuasar(); -const log = ref(null); const props = reactive({ list: [], showDialog: false, @@ -30,17 +29,6 @@ const inspectArc = url =>{ window.ipc.invoke('InternetService.openExternalURL', url); }; -const processMsg = async msgs=>{ - for(let msg of msgs.split('\n')){ - msg = msg.trim(); - if(msg) - props.msgs.push(msg); - } - await nextTick(); - if(log && log._value) - log._value.setScrollPosition('vertical',90000,0); -}; - const importArc = async url =>{ props.localUrl = ''; const destination = await window.ipc.invoke('LocalFileSystemService.selectDir',[ @@ -97,7 +85,6 @@ const init = async () => { props.error = ''; props.list = []; - window.ipc.on('ArcCommanderService.MSG', processMsg); const list = await window.ipc.invoke( 'DataHubService.getArcs', [ @@ -133,10 +120,6 @@ onMounted(init); watch(()=>AppProperties.user, init); watch(()=>props.host, init); -onUnmounted(async () => { - window.ipc.off('ArcCommanderService.MSG', processMsg); -}); - + diff --git a/packages/renderer/src/views/GitSyncView.vue b/packages/renderer/src/views/GitSyncView.vue index bfb67352..480c3ee2 100644 --- a/packages/renderer/src/views/GitSyncView.vue +++ b/packages/renderer/src/views/GitSyncView.vue @@ -149,8 +149,13 @@ const push = async()=>{ }; const merge_xlsx = async (rel_path,pointers) => { + const tempPath = await window.ipc.invoke('CORE.getTempPath'); + + console.log('merging',rel_path); + for(const pointer of pointers){ - const path = `/tmp/arc_merge/${pointer}/${rel_path}`; + const path = `${tempPath}/arc_merge/${pointer}/${rel_path}`; + console.log(' retrieving',path+'.json'); // get xlsx file await window.ipc.invoke('GitService.run', { @@ -168,17 +173,20 @@ const merge_xlsx = async (rel_path,pointers) => { } // merge json representations + console.log(' merging jsons'); const merged_json = await window.ipc.invoke('GitService.run', { args: [`merge-file`,`-p`, - `/tmp/arc_merge/${pointers[0]}/${rel_path}.json`, - `/tmp/arc_merge/${pointers[1]}/${rel_path}.json`, - `/tmp/arc_merge/${pointers[2]}/${rel_path}.json`, + `${tempPath}/arc_merge/${pointers[0]}/${rel_path}.json`, + `${tempPath}/arc_merge/${pointers[1]}/${rel_path}.json`, + `${tempPath}/arc_merge/${pointers[2]}/${rel_path}.json`, ], cwd: ArcControlService.props.arc_root, silent: true }); // write merged workbooks + console.log(' adding merged xlsx'); + console.log(merged_json[1]); const merged_wb = Json.fromRowsJsonString(merged_json[1]); const merged_buffer = await Xlsx.toBytes(merged_wb); await window.ipc.invoke( @@ -249,11 +257,6 @@ const merge = async ()=>{ await merge_xlsx(file,[local_commit,common_ancestor,iProps.remote+'/'+branches.current]); ArcControlService.props.skip_fs_updates = false; - await window.ipc.invoke('GitService.run', { - args: [`commit`,'--ammend'], - cwd: ArcControlService.props.arc_root - }); - await window.ipc.invoke('GitService.run', { args: [`-c`,`core.editor=true`,`rebase`,'--continue'], cwd: ArcControlService.props.arc_root