Skip to content

Commit

Permalink
Merge pull request #158 from PasteBar/fix-for-quick-paste-window-auto…
Browse files Browse the repository at this point in the history
…-generate-link-preview-option

Fix for quick paste window auto generate link preview option
  • Loading branch information
kurdin authored Aug 30, 2024
2 parents 3601002 + cf24d8f commit 72fa0b9
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-camels-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'pastebar-app-ui': patch
---

Fix: Autogenerate link settings not working in Quick Paste Window
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { UniqueIdentifier } from '@dnd-kit/core'
import { listen } from '@tauri-apps/api/event'
import { invoke } from '@tauri-apps/api/tauri'
import { appWindow } from '@tauri-apps/api/window'
import { isKeyAltPressed, isKeyCtrlPressed } from '~/store'
import { isKeyAltPressed, isKeyCtrlPressed, settingsStoreAtom } from '~/store'
import { useAtomValue } from 'jotai'
import { throttle } from 'lodash-es'
import { ArrowDownFromLine, ArrowUpToLine, Search } from 'lucide-react'
Expand Down Expand Up @@ -102,6 +102,9 @@ export default function ClipboardHistoryQuickPastePage() {
const isShowSearch = useSignal(false)
const { movePinnedClipboardHistoryUpDown } = useMovePinnedClipboardHistoryUpDown()

const { isAutoPreviewLinkCardsEnabled, isAutoGenerateLinkCardsEnabled } =
useAtomValue(settingsStoreAtom)

const [historyFilters, setHistoryFilters] = useState<string[]>([])
const [codeFilters, setCodeFilters] = useState<string[]>([])
const [appFilters, setAppFilters] = useState<string[]>([])
Expand Down Expand Up @@ -651,6 +654,10 @@ export default function ClipboardHistoryQuickPastePage() {
addToClipboardHistoryIdsURLErrors={
addToClipboardHistoryIdsURLErrors
}
isLinkCardPreviewEnabled={isAutoPreviewLinkCardsEnabled}
isAutoGenerateLinkCardsEnabled={
isAutoGenerateLinkCardsEnabled
}
addToGenerateLinkMetaDataInProgress={
addToGenerateLinkMetaDataInProgress
}
Expand Down Expand Up @@ -834,6 +841,10 @@ export default function ClipboardHistoryQuickPastePage() {
addToGenerateLinkMetaDataInProgress={
addToGenerateLinkMetaDataInProgress
}
isLinkCardPreviewEnabled={isAutoPreviewLinkCardsEnabled}
isAutoGenerateLinkCardsEnabled={
isAutoGenerateLinkCardsEnabled
}
isScrolling={isScrolling}
removeToGenerateLinkMetaDataInProgress={
removeToGenerateLinkMetaDataInProgress
Expand Down
5 changes: 4 additions & 1 deletion src-tauri/src/commands/link_metadata_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::services::link_metadata_service::{
delete_link_metadata_by_item_id, insert_or_update_link_metadata, AudioInfo,
};

use crate::services::utils::{decode_html_entities, ensure_url_prefix};
use crate::services::utils::{debug_output, decode_html_entities, ensure_url_prefix};
use linkify::{LinkFinder, LinkKind};

use nanoid::nanoid;
Expand Down Expand Up @@ -248,6 +248,9 @@ pub async fn fetch_link_metadata(
item_id: Option<String>,
is_preview_only: Option<bool>,
) -> Result<LinkMetadata, String> {
debug_output(|| {
println!("Fetching metadata for URL: {}", url);
});
if url.is_empty() {
return Err("URL is empty".to_string());
}
Expand Down

0 comments on commit 72fa0b9

Please sign in to comment.