@@ -25,6 +25,7 @@ import { mountLottie } from "~/components/ui/lottie-container"
25
25
import {
26
26
SimpleIconsEagle ,
27
27
SimpleIconsInstapaper ,
28
+ SimpleIconsOmnivore ,
28
29
SimpleIconsReadwise ,
29
30
} from "~/components/ui/platform-icon/icons"
30
31
import { shortcuts } from "~/constants/shortcuts"
@@ -167,6 +168,9 @@ export const useEntryActions = ({
167
168
const enableInstapaper = useIntegrationSettingKey ( "enableInstapaper" )
168
169
const instapaperUsername = useIntegrationSettingKey ( "instapaperUsername" )
169
170
const instapaperPassword = useIntegrationSettingKey ( "instapaperPassword" )
171
+ const enableOmnivore = useIntegrationSettingKey ( "enableOmnivore" )
172
+ const omnivoreToken = useIntegrationSettingKey ( "omnivoreToken" )
173
+ const omnivoreEndpoint = useIntegrationSettingKey ( "omnivoreEndpoint" )
170
174
171
175
const checkEagle = useQuery ( {
172
176
queryKey : [ "check-eagle" ] ,
@@ -308,6 +312,64 @@ export const useEntryActions = ({
308
312
}
309
313
} ,
310
314
} ,
315
+ {
316
+ name : t ( "entry_actions.save_to_omnivore" ) ,
317
+ icon : < SimpleIconsOmnivore /> ,
318
+ key : "saveToomnivore" ,
319
+ hide : ! enableOmnivore || ! omnivoreToken || ! omnivoreEndpoint || ! populatedEntry . entries . url ,
320
+ onClick : async ( ) => {
321
+ const saveUrlQuery = `
322
+ mutation SaveUrl($input: SaveUrlInput!) {
323
+ saveUrl(input: $input) {
324
+ ... on SaveSuccess {
325
+ url
326
+ clientRequestId
327
+ }
328
+ ... on SaveError {
329
+ errorCodes
330
+ message
331
+ }
332
+ }
333
+ }
334
+ `
335
+
336
+ try {
337
+ const data = await ofetch ( omnivoreEndpoint , {
338
+ method : "POST" ,
339
+ headers : {
340
+ "Content-Type" : "application/json" ,
341
+ Authorization : omnivoreToken ,
342
+ } ,
343
+ body : {
344
+ query : saveUrlQuery ,
345
+ variables : {
346
+ input : {
347
+ url : populatedEntry . entries . url ,
348
+ source : "Follow" ,
349
+ clientRequestId : globalThis . crypto . randomUUID ( ) ,
350
+ publishedAt : new Date ( populatedEntry . entries . publishedAt ) ,
351
+ } ,
352
+ } ,
353
+ } ,
354
+ } )
355
+ toast . success (
356
+ < >
357
+ { t ( "entry_actions.saved_to_omnivore" ) } ,{ " " }
358
+ < a target = "_blank" className = "underline" href = { data . data . saveUrl . url } >
359
+ view
360
+ </ a >
361
+ </ > ,
362
+ {
363
+ duration : 3000 ,
364
+ } ,
365
+ )
366
+ } catch {
367
+ toast . error ( t ( "entry_actions.failed_to_save_to_omnivore" ) , {
368
+ duration : 3000 ,
369
+ } )
370
+ }
371
+ } ,
372
+ } ,
311
373
{
312
374
key : "tip" ,
313
375
shortcut : shortcuts . entry . tip . key ,
0 commit comments