Skip to content

Commit

Permalink
added window version open quick paste window with async required func…
Browse files Browse the repository at this point in the history
…tion in rust
  • Loading branch information
skurdindev committed Aug 21, 2024
1 parent 044b4fb commit cd50ce6
Show file tree
Hide file tree
Showing 5 changed files with 119 additions and 147 deletions.
8 changes: 8 additions & 0 deletions packages/pastebar-app-ui/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ function App() {
}

if (settings.hotKeysShowHideMainAppWindow?.valueText) {
console.log(
'settings.hotKeysShowHideMainAppWindow?.valueText',
settings.hotKeysShowHideMainAppWindow?.valueText
)
try {
register(settings.hotKeysShowHideMainAppWindow?.valueText, async () => {
if (document.hasFocus()) {
Expand All @@ -228,6 +232,10 @@ function App() {
}

if (settings.hotKeysShowHideQuickPasteWindow?.valueText) {
console.log(
'settings.hotKeysShowHideMainAppWindow?.valueText',
settings.hotKeysShowHideQuickPasteWindow?.valueText
)
try {
register(settings.hotKeysShowHideQuickPasteWindow?.valueText, async () => {
await uiStore.toggleHistoryQuickPasteWindow()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ const loadPrismComponents = async () => {

async function invokeCopyPasteHistoryItem(historyId: UniqueIdentifier) {
try {
await invoke('set_focus_to_previous_window')
await new Promise(resolve => setTimeout(resolve, 200))
invoke('copy_paste_history_item', { historyId, delay: 0 })
appWindow?.close()
await invoke('quickpaste_hide_paste_close', { historyId })
} catch (error) {
console.error('Error copying history item:', error)
}
Expand Down Expand Up @@ -578,7 +575,7 @@ export default function ClipboardHistoryQuickPastePage() {
movePinnedClipboardHistoryUpDown(move)
}}
setSelectHistoryItem={() => {}}
onCopy={setCopiedItem}
onCopy={invokeCopyPasteHistoryItem}
onCopyPaste={invokeCopyPasteHistoryItem}
pastingCountDown={
historyId === pastedItemValue
Expand Down Expand Up @@ -750,7 +747,7 @@ export default function ClipboardHistoryQuickPastePage() {
setHistoryFilters={setHistoryFilters}
setAppFilters={setAppFilters}
setSelectHistoryItem={() => {}}
onCopy={setCopiedItem}
onCopy={invokeCopyPasteHistoryItem}
onCopyPaste={invokeCopyPasteHistoryItem}
isKeyboardSelected={keyboardSelectedItemId === historyId}
setKeyboardSelected={id => {
Expand Down
46 changes: 13 additions & 33 deletions src-tauri/Cargo.lock

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

5 changes: 3 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,13 @@ rust-version = "1.75.0"
version = "1.4"
features = []

[target.'cfg(windows)'.dependencies]
[target.'cfg(target_os = "windows")'.dependencies]
winapi = { version = "0.3", features = ["winuser", "windef"] }
winreg = "0.52.0"

[dependencies]
fns = "0"
enigo = "0.1.2"
mouse_position = "0.1.4"
keyring = "2.3.2"
dotenv = "0.15.0"
bcrypt = "0.15.1"
Expand Down
Loading

0 comments on commit cd50ce6

Please sign in to comment.