Skip to content

Commit

Permalink
Merge branch 'main' into chore/invite-event-handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cimigree committed Jan 8, 2025
2 parents a261b39 + 4448aa8 commit df6fe41
Show file tree
Hide file tree
Showing 10 changed files with 200 additions and 98 deletions.
10 changes: 5 additions & 5 deletions messages/renderer/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -212,20 +212,20 @@
"screens.PrivacyPolicy.whyCollectedDescription": {
"message": "Crash data and app errors together with the device and app info provide Awana Digital with the information we need to fix errors and bugs in the app. The performance data helps us improve the responsiveness of the app and identify errors. User counts, including total users, users per country, and users per project, help justify ongoing investment in the development of CoMapeo."
},
"screens.ProjectCreationScreen.addName": {
"message": "Create Project"
},
"screens.ProjectCreationScreen.advancedProjectSettings": {
"message": "Advanced Project Settings"
},
"screens.ProjectCreationScreen.characterCount": {
"message": "{count}/{maxLength}"
},
"screens.ProjectCreationScreen.createProject": {
"message": "Create Project"
},
"screens.ProjectCreationScreen.enterNameLabel": {
"message": "Name your project"
},
"screens.ProjectCreationScreen.errorSavingProjectName": {
"message": "An error occurred while saving your project name. Please try again."
"screens.ProjectCreationScreen.errorSavingProject": {
"message": "An error occurred while saving your project. Please try again."
},
"screens.ProjectCreationScreen.importConfig": {
"message": "Import Config"
Expand Down
64 changes: 39 additions & 25 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
"vite:build": "vite build src/renderer"
},
"dependencies": {
"@comapeo/core": "2.1.0",
"@comapeo/ipc": "2.0.2",
"@comapeo/core": "2.3.0",
"@comapeo/ipc": "2.1.0",
"@formatjs/intl": "^3.0.1",
"@mapeo/default-config": "5.0.0",
"debug": "^4.3.7",
Expand All @@ -65,7 +65,7 @@
"valibot": "^0.42.1"
},
"devDependencies": {
"@comapeo/core-react": "0.1.2",
"@comapeo/core-react": "1.1.0",
"@electron-forge/cli": "7.6.0",
"@electron-forge/maker-deb": "7.6.0",
"@electron-forge/maker-dmg": "7.6.0",
Expand Down
8 changes: 4 additions & 4 deletions patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ fixes.

## @comapeo/core

### [Do not watch fallback map patch when setting up SMP server plugin](./@comapeo+core+2.1.0+001+fix-smp-fallback-map-setup.patch)
### [Do not watch fallback map patch when setting up SMP server plugin](./@comapeo+core+2.3.0+001+fix-smp-fallback-map-setup.patch)

By default, core sets up a file watcher for the `fallbackMapPath` option that's provided when instantiating `MapeoManager`. This does not work when packaging the app as an ASAR file (via Electron Forge) because watching a file within the ASAR directory is not possible. Instead, we change the setup so that it does not try to watch the file and instead make the assumption that the file always exists on instantiation, which is generally the case in CoMapeo Desktop (for now).

## @comapeo/ipc

### [Change imports to avoid calling unavailable code](./@comapeo+ipc+2.0.2+001+fix-client-server-import.patch)
### [Change imports to avoid calling unavailable code](./@comapeo+ipc+2.1.0+001+fix-client-server-import.patch)

There was an error while running app via Expo because of exports in `rpc-reflector` package. To remove this patch, `rpc-reflector` would need to be updated not to use `encode-decode.js` file which indirect usage results in errors.
There was an error while running app because of exports in `rpc-reflector` package. To remove this patch, `rpc-reflector` would need to be updated not to use `encode-decode.js` file which indirect usage results in errors.

## rpc-reflector

### [Change imports to avoid calling unavailable code](./rpc-reflector+1.3.11+001+fix-client-duplex.patch)

There was an error while running app via Expo because of `duplex` method call in `rpc-reflector` package.
There was an error while running app because of `duplex` method call in `rpc-reflector` package.
As this feature is not used in CoMapeo, this can be safely hardcoded to `false`. To remove this patch, `rpc-reflector` would need to be updated to account for this bug.

### [Use type imports in types-only file](./rpc-reflector+1.3.11+002+fix-verbatim-module-syntax-issues.patch)
Expand Down
10 changes: 8 additions & 2 deletions src/renderer/src/hooks/mutations/projects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,14 @@ export function useCreateProject() {

return useMutation({
mutationKey: [CREATE_PROJECT_KEY],
mutationFn: (name?: string) => {
return api.createProject({ name })
mutationFn: (opts?: Parameters<typeof api.createProject>[0]) => {
if (opts) {
return api.createProject(opts)
} else {
// Have to avoid passing `undefined` explicitly
// See https://github.com/digidem/comapeo-mobile/issues/392
return api.createProject()
}
},
onSuccess: () => {
queryClient.invalidateQueries({
Expand Down
70 changes: 70 additions & 0 deletions src/renderer/src/hooks/useConfigFileImporter.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { act, renderHook } from '@testing-library/react'
import { beforeEach, describe, expect, it, vi } from 'vitest'

import { useSelectProjectConfigFile } from './mutations/file-system'

describe('useSelectProjectConfigFile', () => {
beforeEach(() => {
window.runtime = {
getLocale: vi.fn().mockResolvedValue('en'),
updateLocale: vi.fn(),
selectFile: vi.fn(),
}
})

function createWrapper() {
const queryClient = new QueryClient()
return ({ children }: { children: React.ReactNode }) => (
<QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
)
}

it('returns filename and filepath from window.runtime.selectFile', async () => {
vi.spyOn(window.runtime, 'selectFile').mockResolvedValue({
name: 'myFile.comapeocat',
path: '/Users/cindy/documents/myFile.comapeocat',
})

const { result } = renderHook(() => useSelectProjectConfigFile(), {
wrapper: createWrapper(),
})

await act(async () => {
const val = await result.current.mutateAsync(undefined)
expect(val).toEqual({
name: 'myFile.comapeocat',
path: '/Users/cindy/documents/myFile.comapeocat',
})
})
})

it('returns undefined if user cancels', async () => {
vi.spyOn(window.runtime, 'selectFile').mockResolvedValue(undefined)

const { result } = renderHook(() => useSelectProjectConfigFile(), {
wrapper: createWrapper(),
})

await act(async () => {
const val = await result.current.mutateAsync(undefined)
expect(val).toBeUndefined()
})
})

it('throws if the returned object has invalid shape', async () => {
vi.spyOn(window.runtime, 'selectFile').mockRejectedValue(
new Error('Value has invalid shape'),
)

const { result } = renderHook(() => useSelectProjectConfigFile(), {
wrapper: createWrapper(),
})

await expect(
act(async () => {
await result.current.mutateAsync()
}),
).rejects.toThrow('Value has invalid shape')
})
})
Loading

0 comments on commit df6fe41

Please sign in to comment.