Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: move Jan folder #3160

Merged
merged 35 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from 27 commits
Commits
Show all changes
35 commits
Select commit Hold shift click to select a range
9eec02e
chore: upgrade marked-katex-extension (#3049)
urmauur Jun 17, 2024
8f7f512
fix: handle long word without space to avoid right panel disappears (…
urmauur Jun 17, 2024
f460765
add time weighted retrieval (#2908)
thunhuanh Jun 20, 2024
301ddfb
fix: model dropdown search by configured model (#3047)
urmauur Jun 20, 2024
1cd3b4f
Merge pull request #3076 from janhq/main
Van-QA Jun 21, 2024
18b4c2c
bump version (#3082) (#3083)
Van-QA Jun 21, 2024
4043207
Update cortex cpp nightly to version 0.4.18 (#3072)
jan-service-account Jun 21, 2024
f94265a
chore: update download.ts (#3088)
eltociear Jun 26, 2024
655ddc0
chore: cortex version update (#3098)
namchuai Jun 26, 2024
6f5de56
fix: handle words without space (#3101)
urmauur Jun 26, 2024
0226c76
fix: handle long thread title without space (#3107)
urmauur Jun 27, 2024
023c1ca
chore: Bump-cortex-0.4.17 (#3111)
Van-QA Jun 27, 2024
5b2c03f
Update cortex cpp nightly to version 0.4.18 (#3114)
jan-service-account Jul 1, 2024
20084ed
Chore: Add stop token for Gemma 2b (#3125)
hahuyhoang411 Jul 1, 2024
e885669
fix: set specific version for terminate (#3126)
namchuai Jul 2, 2024
148c85f
feat: add claude 3.5 sonnet (#3129)
namchuai Jul 3, 2024
b9a198a
feat: add options config spell check for chat input (#3131)
urmauur Jul 3, 2024
4c8146b
fixed grammar nits (#3132)
0saurabh0 Jul 4, 2024
63e7c7b
Update cortex cpp nightly to version 0.4.20
github-actions[bot] Jul 4, 2024
b2371f5
Merge pull request #3141 from janhq/update-nightly-2024-07-04-19-31
jan-service-account Jul 4, 2024
6b490f6
fix: toggle button for expand log section on modal troubleshoot (#3130)
urmauur Jul 8, 2024
0902dd5
fix: add tooltip messages toolbar (#3138)
urmauur Jul 8, 2024
302a7fa
fix: handle error message when apikey is not setup (#3149)
urmauur Jul 9, 2024
88750fa
fix: title thread not updated on input edit title (#3148)
urmauur Jul 9, 2024
da35d27
merge dev
marknguyen1302 Jul 12, 2024
ff4adad
fix move jan folder
marknguyen1302 Jul 12, 2024
9e7b82f
Merge branch 'dev' of https://github.com/janhq/jan into fix/move-jan-…
marknguyen1302 Jul 12, 2024
2337c6f
Update electron/preload.ts
louis-jan Jul 12, 2024
abcd3ab
refactor
marknguyen1302 Jul 12, 2024
1d80cd5
Merge branch 'fix/move-jan-folder' of https://github.com/janhq/jan in…
marknguyen1302 Jul 12, 2024
8a2f837
Update electron/preload.ts
louis-jan Jul 12, 2024
ebcf3a2
fix wrong param
marknguyen1302 Jul 15, 2024
802f721
Merge branch 'fix/move-jan-folder' of https://github.com/janhq/jan in…
marknguyen1302 Jul 15, 2024
2025f62
use correct method
marknguyen1302 Jul 15, 2024
6657f38
chore: fix lint
namchuai Jul 15, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion electron/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 3,19 @@
* @module preload
*/

import { APIEvents, APIRoutes } from '@janhq/core/node'
import { APIEvents, APIRoutes, AppConfiguration, getAppConfigurations, updateAppConfiguration } from '@janhq/core/node'
import { contextBridge, ipcRenderer } from 'electron'
import {readdirSync} from 'fs'
louis-jan marked this conversation as resolved.
Show resolved Hide resolved

const interfaces: { [key: string]: (...args: any[]) => any } = {}

// Loop over each route in APIRoutes
APIRoutes.forEach((method) => {
// For each method, create a function on the interfaces object
// This function invokes the method on the ipcRenderer with any provided arguments

interfaces[method] = (...args: any[]) => ipcRenderer.invoke(method, ...args)

})

// Loop over each method in APIEvents
Expand All @@ -22,6 25,24 @@ APIEvents.forEach((method) => {
// The handler for the event is provided as an argument to the function
interfaces[method] = (handler: any) => ipcRenderer.on(method, handler)
})


interfaces['changeDataFolder'] = async path => {
const appConfiguration: AppConfiguration =
getAppConfigurations()
const currentJanDataFolder = appConfiguration.data_folder
appConfiguration.data_folder = path
const { err } = await ipcRenderer.invoke('syncFile', currentJanDataFolder, path)
if (err) throw err
await ipcRenderer.invoke('updateAppConfiguration', appConfiguration)
}

interfaces['isDirectoryEmpty'] = async path => {
const dirChildren= await readdirSync(path)
louis-jan marked this conversation as resolved.
Show resolved Hide resolved
return dirChildren.filter((x) => x !== '.DS_Store').length === 0
}

delete interfaces['syncFile']
// Expose the 'interfaces' object in the main world under the name 'electronAPI'
// This allows the renderer process to access these methods directly
contextBridge.exposeInMainWorld('electronAPI', {
Expand Down
18 changes: 4 additions & 14 deletions web/screens/Settings/Advanced/DataFolder/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
import { Fragment, useCallback, useState } from 'react'

import { fs, AppConfiguration, isSubdirectory } from '@janhq/core'

Check warning on line 3 in web/screens/Settings/Advanced/DataFolder/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-ubuntu

'fs' is defined but never used

Check warning on line 3 in web/screens/Settings/Advanced/DataFolder/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-macos

'fs' is defined but never used

Check warning on line 3 in web/screens/Settings/Advanced/DataFolder/index.tsx

View workflow job for this annotation

GitHub Actions / test-on-windows-pr

'fs' is defined but never used
import { Button, Input } from '@janhq/joi'
import { useAtomValue, useSetAtom } from 'jotai'
import { PencilIcon, FolderOpenIcon } from 'lucide-react'
Expand Down Expand Up @@ -51,11 51,10 @@
return
}

const newDestChildren: string[] = await fs.readdirSync(destFolder)
const isNotEmpty =
newDestChildren.filter((x) => x !== '.DS_Store').length > 0
const isEmpty: boolean =
await window.core?.api?.isDirectoryEmpty(destFolder)

if (isNotEmpty) {
if (!isEmpty) {
setDestinationPath(destFolder)
showDestNotEmptyConfirm(true)
return
Expand All @@ -74,16 73,7 @@
if (!destinationPath) return
try {
setShowLoader(true)
const appConfiguration: AppConfiguration =
await window.core?.api?.getAppConfigurations()
const currentJanDataFolder = appConfiguration.data_folder
appConfiguration.data_folder = destinationPath
const { err } = await fs.syncFile(currentJanDataFolder, destinationPath)
if (err) throw err
await window.core?.api?.updateAppConfiguration(appConfiguration)
console.debug(
`File sync finished from ${currentJanDataFolder} to ${destinationPath}`
)
await window.core?.api?.changeDataFolder(destinationPath)
localStorage.setItem(SUCCESS_SET_NEW_DESTINATION, 'true')
setTimeout(() => {
setShowLoader(false)
Expand Down
Loading