Skip to content

Commit

Permalink
chore: merge branch 'master' of github.com:massCodeIO/massCode
Browse files Browse the repository at this point in the history
  • Loading branch information
antonreshetov committed Apr 11, 2022
2 parents ab799d5 + ab37606 commit ec962ab
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/main/services/ipc/context-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { createMenu } from '../../components/menu'
import type { MenuItemConstructorOptions } from 'electron'
import { BrowserWindow, MenuItem, dialog, ipcMain } from 'electron'
import type {
ContextMenuPayload,
ContextMenuRequest,
ContextMenuResponse
} from '@shared/types/main'
import { languages } from '../../../renderer/components/editor/languages'

export const subscribeToContextMenu = () => {
ipcMain.handle<ContextMenuPayload, ContextMenuResponse>(
ipcMain.handle<ContextMenuRequest, ContextMenuResponse>(
'context-menu:snippet-fragment',
async (event, payload) => {
const { name, type } = payload
Expand Down Expand Up @@ -51,7 +51,7 @@ export const subscribeToContextMenu = () => {
}
)

ipcMain.handle<ContextMenuPayload, ContextMenuResponse>(
ipcMain.handle<ContextMenuRequest, ContextMenuResponse>(
'context-menu:snippet',
async (event, payload) => {
const { name, type, selectedCount } = payload
Expand Down Expand Up @@ -180,7 +180,7 @@ export const subscribeToContextMenu = () => {
}
)

ipcMain.handle<ContextMenuPayload, ContextMenuResponse>(
ipcMain.handle<ContextMenuRequest, ContextMenuResponse>(
'context-menu:library',
async (event, payload) => {
const { name, type, data } = payload
Expand Down
4 changes: 2 additions & 2 deletions src/main/services/ipc/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { NotificationPayload } from '@shared/types/main'
import type { NotificationRequest } from '@shared/types/main'
import { ipcMain, Notification } from 'electron'

export const subscribeToNotification = () => {
if (!Notification.isSupported()) return

ipcMain.handle<NotificationPayload>('main:notification', (event, payload) => {
ipcMain.handle<NotificationRequest>('main:notification', (event, payload) => {
return new Promise(resolve => {
const { body } = payload
const notification = new Notification({
Expand Down
8 changes: 4 additions & 4 deletions src/renderer/components/preferences/Storage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const folderStore = useFolderStore()
const storagePath = ref(store.preferences.get('storagePath'))
const onClickMove = async () => {
const path = await ipc.invoke<string>('main:open-dialog', {})
const path = await ipc.invoke<any, string>('main:open-dialog', {})
if (!path) return
Expand All @@ -64,7 +64,7 @@ const onClickMove = async () => {
}
const onClickOpen = async () => {
const path = await ipc.invoke<string>('main:open-dialog', {})
const path = await ipc.invoke<any, string>('main:open-dialog', {})
const isExist = db.isExist(path)
if (isExist) {
Expand All @@ -81,7 +81,7 @@ const onClickOpen = async () => {
}
const onClickMigrate = async () => {
const state = await ipc.invoke<boolean, MessageBoxRequest>(
const state = await ipc.invoke<MessageBoxRequest, boolean>(
'main:open-message-box',
{
message: 'Are you sure you want to migrate from v1',
Expand All @@ -94,7 +94,7 @@ const onClickMigrate = async () => {
if (!state) return
try {
const path = await ipc.invoke<string>('main:open-dialog', {})
const path = await ipc.invoke<any, string>('main:open-dialog', {})
await db.migrate(path)
ipc.invoke('main:restart-api', {})
ipc.invoke('main:notification', {
Expand Down
16 changes: 8 additions & 8 deletions src/renderer/components/sidebar/SidebarListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import AngleRight from '~icons/unicons/angle-right'
import { onClickOutside } from '@vueuse/core'
import { ipc, track } from '@/electron'
import type {
ContextMenuPayload,
ContextMenuRequest,
ContextMenuResponse,
ContextMenuType
} from '@shared/types/main'
Expand Down Expand Up @@ -70,8 +70,8 @@ const itemRef = ref()
const onClickContextMenu = async () => {
if (props.isFolder) {
const { action, type, data } = await ipc.invoke<
ContextMenuResponse,
ContextMenuPayload
ContextMenuRequest,
ContextMenuResponse
>('context-menu:library', {
name: props.model?.name,
type: 'folder',
Expand All @@ -96,10 +96,10 @@ const onClickContextMenu = async () => {
if (props.alias) {
const { action, type, data } = await ipc.invoke<
ContextMenuResponse,
ContextMenuPayload
ContextMenuRequest,
ContextMenuResponse
>('context-menu:library', {
name: props.name,
name2: props.name,
type: 'trash',
data: {}
})
Expand All @@ -117,8 +117,8 @@ const onClickContextMenu = async () => {
if (props.isTag) {
const { action, type, data } = await ipc.invoke<
ContextMenuResponse,
ContextMenuPayload
ContextMenuRequest,
ContextMenuResponse
>('context-menu:library', {
name: props.name,
type: 'tag',
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/snippets/SnippetHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import { ipc, track } from '@/electron'
import { useSnippetStore } from '@/store/snippets'
import { useClipboard, useDebounceFn } from '@vueuse/core'
import { computed, ref } from 'vue'
import type { NotificationPayload } from '@shared/types/main'
import type { NotificationRequest } from '@shared/types/main'
import { useAppStore } from '@/store/app'
const snippetStore = useSnippetStore()
Expand Down Expand Up @@ -66,7 +66,7 @@ const onAddNewFragment = () => {
const onCopySnippet = () => {
const { copy } = useClipboard({ source: snippetStore.currentContent })
copy()
ipc.invoke<any, NotificationPayload>('main:notification', {
ipc.invoke<any, NotificationRequest>('main:notification', {
body: 'Snippet copied'
})
track('snippets/copy')
Expand Down
6 changes: 3 additions & 3 deletions src/renderer/components/snippets/SnippetListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { ipc, track } from '@/electron'
import { useFolderStore } from '@/store/folders'
import { useSnippetStore } from '@/store/snippets'
import type {
ContextMenuPayload,
ContextMenuRequest,
ContextMenuResponse
} from '@shared/types/main'
import { onClickOutside } from '@vueuse/core'
Expand Down Expand Up @@ -116,8 +116,8 @@ const onClickContextMenu = async () => {
})
const { action, data, type } = await ipc.invoke<
ContextMenuResponse,
ContextMenuPayload
ContextMenuRequest,
ContextMenuResponse
>('context-menu:snippet', {
name: props.name,
type: folderStore.selectedAlias ?? 'folder',
Expand Down
4 changes: 2 additions & 2 deletions src/renderer/components/snippets/SnippetsFragmentsInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { useSnippetStore } from '@/store/snippets'
import { onClickOutside, useDebounceFn } from '@vueuse/core'
import { ipc, track } from '@/electron'
import type {
ContextMenuPayload,
ContextMenuRequest,
ContextMenuResponse
} from '@shared/types/main'
Expand Down Expand Up @@ -59,7 +59,7 @@ onClickOutside(inputRef, async () => {
})
const onClickContext = async () => {
const { action } = await ipc.invoke<ContextMenuResponse, ContextMenuPayload>(
const { action } = await ipc.invoke<ContextMenuRequest, ContextMenuResponse>(
'context-menu:snippet-fragment',
{
name: props.name,
Expand Down
6 changes: 3 additions & 3 deletions src/shared/types/main/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export type MainMenuChannel = CombineWith<MainMenuAction, 'main-menu'>
export type MainChannel = CombineWith<MainAction, 'main'>

export type Channel = ContextMenuChannel | MainMenuChannel | MainChannel
export interface ContextMenuPayload {
export interface ContextMenuRequest {
name?: string
type: ContextMenuType
data?: any
Expand All @@ -59,7 +59,7 @@ export interface ContextMenuResponse {
data: any
}

export interface NotificationPayload {
export interface NotificationRequest {
body: string
}

Expand Down Expand Up @@ -89,7 +89,7 @@ interface StoreProperties<T> {

export interface ElectronBridge {
ipc: {
invoke<T, U = any>(channel: Channel, payload: U): Promise<T>
invoke<T, U = any>(channel: Channel, payload: T): Promise<U>
on(channel: Channel, cb: EventCallback): void
once(channel: Channel, cb: EventCallback): void
}
Expand Down

0 comments on commit ec962ab

Please sign in to comment.