feat: tipc showShareMenu and saveToEagle
This commit is contained in:
@@ -2,6 +2,7 @@ import { useToast } from "@renderer/components/ui/use-toast"
|
||||
import { useCallback } from "react"
|
||||
import { ofetch } from "ofetch"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { client } from "@renderer/lib/client"
|
||||
|
||||
export const useCheckEagle = () =>
|
||||
useQuery({
|
||||
@@ -57,7 +58,7 @@ export const useEntryActions = ({
|
||||
const { toast } = useToast()
|
||||
|
||||
const execAction = useCallback(
|
||||
(action: string) => {
|
||||
async (action: string) => {
|
||||
switch (action) {
|
||||
case "copyLink":
|
||||
navigator.clipboard.writeText(url)
|
||||
@@ -70,29 +71,22 @@ export const useEntryActions = ({
|
||||
window.open(url, "_blank")
|
||||
break
|
||||
case "share":
|
||||
window.electron.ipcRenderer.send("share-url", url)
|
||||
client.showShareMenu(url)
|
||||
break
|
||||
case "save-to-eagle":
|
||||
window.electron.ipcRenderer.once(
|
||||
"save-to-eagle-reply",
|
||||
(_, response) => {
|
||||
if (response?.status === "success") {
|
||||
toast({
|
||||
duration: 3000,
|
||||
description: "Saved to Eagle.",
|
||||
})
|
||||
} else {
|
||||
toast({
|
||||
duration: 3000,
|
||||
description: "Failed to save to Eagle.",
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
window.electron.ipcRenderer.send("save-to-eagle", {
|
||||
url,
|
||||
images,
|
||||
})
|
||||
if (!images?.length) return
|
||||
const response = await client.saveToEagle({ url, images })
|
||||
if (response?.status === "success") {
|
||||
toast({
|
||||
duration: 3000,
|
||||
description: "Saved to Eagle.",
|
||||
})
|
||||
} else {
|
||||
toast({
|
||||
duration: 3000,
|
||||
description: "Failed to save to Eagle.",
|
||||
})
|
||||
}
|
||||
break
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user