diff --git a/pages/index.vue b/pages/index.vue
index 4290ba8..b6a8464 100644
--- a/pages/index.vue
+++ b/pages/index.vue
@@ -54,7 +54,7 @@
showModifier: true,
onClick: toggleActionsMenu,
}" />
-
+
@@ -116,17 +116,21 @@ const isActionsMenuVisible = ref(false);
const topBar = ref<{ searchInput: HTMLInputElement | null } | null>(null);
const toggleActionsMenu = () => {
- nextTick(() => {
- isActionsMenuVisible.value = !isActionsMenuVisible.value;
- if (isActionsMenuVisible.value) {
- $keyboard.enableContext('actionsMenu');
- }
- });
+ isActionsMenuVisible.value = !isActionsMenuVisible.value;
+
+ if (isActionsMenuVisible.value) {
+ $keyboard.disableContext('main');
+ $keyboard.enableContext('actionsMenu');
+ } else {
+ $keyboard.disableContext('actionsMenu');
+ $keyboard.enableContext('main');
+ }
};
const closeActionsMenu = () => {
isActionsMenuVisible.value = false;
$keyboard.disableContext('actionsMenu');
+ $keyboard.enableContext('main');
};
const isSameDay = (date1: Date, date2: Date): boolean => {
@@ -430,13 +434,13 @@ const getYoutubeThumbnail = (url: string): string => {
};
const updateHistory = async (resetScroll: boolean = false): Promise => {
- const results = await $history.loadHistoryChunk(0, CHUNK_SIZE);
+ offset = 0;
+ history.value = [];
+
+ const results = await $history.loadHistoryChunk(offset, CHUNK_SIZE);
if (results.length > 0) {
- const existingIds = new Set(history.value.map((item) => item.id));
- const uniqueNewItems = results.filter((item) => !existingIds.has(item.id));
-
- const processedNewItems = await Promise.all(
- uniqueNewItems.map(async (item) => {
+ const processedItems = await Promise.all(
+ results.map(async (item) => {
const historyItem = new HistoryItem(
item.source,
item.content_type,
@@ -484,7 +488,8 @@ const updateHistory = async (resetScroll: boolean = false): Promise => {
})
);
- history.value = [...processedNewItems, ...history.value];
+ history.value = processedItems;
+ offset = results.length;
if (
resetScroll &&
@@ -554,9 +559,14 @@ const setupEventListeners = async (): Promise => {
},
onToggleActions: toggleActionsMenu,
contextName: 'main',
- priority: $keyboard.PRIORITY.LOW
+ priority: $keyboard.PRIORITY.HIGH
});
- $keyboard.enableContext('main');
+
+ if (isActionsMenuVisible.value) {
+ $keyboard.enableContext('actionsMenu');
+ } else {
+ $keyboard.enableContext('main');
+ }
});
await listen("tauri://blur", () => {
diff --git a/src-tauri/src/db/history.rs b/src-tauri/src/db/history.rs
index bc0ab87..a058eeb 100644
--- a/src-tauri/src/db/history.rs
+++ b/src-tauri/src/db/history.rs
@@ -5,6 +5,7 @@ use rand::distr::Alphanumeric;
use sqlx::{ Row, SqlitePool };
use std::fs;
use tauri_plugin_aptabase::EventTracker;
+use tauri::Emitter;
pub async fn initialize_history(pool: &SqlitePool) -> Result<(), Box> {
let id: String = rng()
@@ -106,6 +107,8 @@ pub async fn add_history_item(
"content_type": item.content_type.to_string()
}))
);
+
+ let _ = app_handle.emit("clipboard-content-updated", ());
Ok(())
}
@@ -195,6 +198,7 @@ pub async fn delete_history_item(
.map_err(|e| e.to_string())?;
let _ = app_handle.track_event("history_item_deleted", None);
+ let _ = app_handle.emit("clipboard-content-updated", ());
Ok(())
}
@@ -210,6 +214,7 @@ pub async fn clear_history(
.map_err(|e| e.to_string())?;
let _ = app_handle.track_event("history_cleared", None);
+ let _ = app_handle.emit("clipboard-content-updated", ());
Ok(())
}