wip add apps to clipboard history ignore list
This commit is contained in:
parent
d8c0c09112
commit
4ca78f601e
@ -1,4 +1,3 @@
|
||||
-- Rollback for clipboard_history table
|
||||
CREATE TABLE clipboard_history_new (
|
||||
history_id VARCHAR(50) PRIMARY KEY NOT NULL,
|
||||
title VARCHAR(255),
|
||||
|
@ -1,2 +1,2 @@
|
||||
-- Adding new column to items table
|
||||
-- Adding new column to clipboard_history table
|
||||
ALTER TABLE clipboard_history ADD COLUMN history_options TEXT;
|
||||
|
49
migrations/2024-07-30-220029_adding_copied_from_app/down.sql
Normal file
49
migrations/2024-07-30-220029_adding_copied_from_app/down.sql
Normal file
@ -0,0 +1,49 @@
|
||||
-- down.sql
|
||||
CREATE TABLE clipboard_history_new (
|
||||
history_id VARCHAR(50) PRIMARY KEY NOT NULL,
|
||||
title VARCHAR(255),
|
||||
value VARCHAR(255),
|
||||
value_preview VARCHAR(150),
|
||||
value_more_preview_lines INT DEFAULT 0,
|
||||
value_more_preview_chars INT DEFAULT 0,
|
||||
value_hash VARCHAR(255),
|
||||
is_image BOOLEAN DEFAULT FALSE,
|
||||
image_path_full_res VARCHAR(255),
|
||||
image_data_low_res BLOB,
|
||||
image_preview_height INT DEFAULT 0,
|
||||
image_height INT DEFAULT 0,
|
||||
image_width INT DEFAULT 0,
|
||||
image_data_url VARCHAR(255),
|
||||
image_hash VARCHAR(255),
|
||||
is_image_data BOOLEAN DEFAULT FALSE,
|
||||
is_masked BOOLEAN DEFAULT FALSE,
|
||||
is_text BOOLEAN DEFAULT FALSE,
|
||||
is_code BOOLEAN DEFAULT FALSE,
|
||||
is_link BOOLEAN DEFAULT FALSE,
|
||||
is_video BOOLEAN DEFAULT FALSE,
|
||||
has_emoji BOOLEAN DEFAULT FALSE,
|
||||
has_masked_words BOOLEAN DEFAULT FALSE,
|
||||
is_pinned BOOLEAN DEFAULT FALSE,
|
||||
is_favorite BOOLEAN DEFAULT FALSE,
|
||||
links TEXT,
|
||||
detected_language VARCHAR(20),
|
||||
pinned_order_number INT DEFAULT 0,
|
||||
created_at BIGINT NOT NULL,
|
||||
updated_at BIGINT NOT NULL,
|
||||
created_date TIMESTAMP NOT NULL,
|
||||
updated_date TIMESTAMP NOT NULL,
|
||||
history_options TEXT
|
||||
);
|
||||
|
||||
INSERT INTO clipboard_history_new SELECT
|
||||
history_id, title, value, value_preview, value_more_preview_lines,
|
||||
value_more_preview_chars, value_hash, is_image, image_path_full_res,
|
||||
image_data_low_res, image_preview_height, image_height, image_width,
|
||||
image_data_url, image_hash, is_image_data, is_masked, is_text, is_code,
|
||||
is_link, is_video, has_emoji, has_masked_words, is_pinned, is_favorite,
|
||||
links, detected_language, pinned_order_number, created_at, updated_at,
|
||||
created_date, updated_date, history_options
|
||||
FROM clipboard_history;
|
||||
|
||||
DROP TABLE clipboard_history;
|
||||
ALTER TABLE clipboard_history_new RENAME TO clipboard_history;
|
@ -0,0 +1,3 @@
|
||||
|
||||
-- Adding new column to clipboard_history table
|
||||
ALTER TABLE clipboard_history ADD COLUMN copied_from_app VARCHAR(255);
|
@ -234,6 +234,7 @@ Set: Set
|
||||
Set Password: Set Password
|
||||
Show Large View: Show Large View
|
||||
Show all: Show all
|
||||
'Source:': 'Source:'
|
||||
Split History Window: Split History Window
|
||||
Star: Star
|
||||
Star Selected: Star Selected
|
||||
|
@ -11,6 +11,7 @@ Add Tab: Add Tab
|
||||
Add to: Add to
|
||||
Add to Menu: Add to Menu
|
||||
AddTo:
|
||||
Add to Ignore: Add to Ignore
|
||||
Clip on Board: Clip on Board
|
||||
Paste Menu: Paste Menu
|
||||
After: After
|
||||
|
@ -320,6 +320,11 @@ export function ClipboardHistoryRowComponent({
|
||||
: undefined,
|
||||
}}
|
||||
ref={isDragPreview && !(isHovering || isSelected) ? null : setNodeRef}
|
||||
title={
|
||||
clipboard?.copiedFromApp && isHovering
|
||||
? `${t('Source:')} ${clipboard?.copiedFromApp}`
|
||||
: ''
|
||||
}
|
||||
{...(isSelected || isHovering ? listeners : {})}
|
||||
>
|
||||
<Box ref={rowRef}>
|
||||
@ -1014,6 +1019,7 @@ export function ClipboardHistoryRowComponent({
|
||||
</ContextMenuTrigger>
|
||||
<ClipboardHistoryRowContextMenu
|
||||
historyId={clipboard.historyId}
|
||||
copiedFromApp={clipboard.copiedFromApp}
|
||||
isMasked={clipboard.isMasked}
|
||||
setSavingItem={setSavingItem}
|
||||
value={clipboard.value}
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
ArrowDownToLine,
|
||||
CheckSquare,
|
||||
ClipboardPaste,
|
||||
ClipboardX,
|
||||
EqualNot,
|
||||
Expand,
|
||||
GalleryVertical,
|
||||
@ -64,6 +65,7 @@ interface ClipboardHistoryRowContextMenuProps {
|
||||
arrLinks: string[]
|
||||
isImage: boolean
|
||||
isText: boolean
|
||||
copiedFromApp: string | null
|
||||
isMasked: boolean
|
||||
isImageData: boolean
|
||||
isMp3: boolean | undefined
|
||||
@ -88,6 +90,7 @@ interface ClipboardHistoryRowContextMenuProps {
|
||||
export default function ClipboardHistoryRowContextMenu({
|
||||
historyId,
|
||||
value,
|
||||
copiedFromApp,
|
||||
arrLinks,
|
||||
isImage,
|
||||
isText,
|
||||
@ -354,6 +357,25 @@ export default function ClipboardHistoryRowContextMenu({
|
||||
</ContextMenuSubContent>
|
||||
</ContextMenuSub>
|
||||
|
||||
{copiedFromApp && (
|
||||
<ContextMenuSub>
|
||||
<ContextMenuSubTrigger>{copiedFromApp} ...</ContextMenuSubTrigger>
|
||||
<ContextMenuSubContent>
|
||||
<ContextMenuItem
|
||||
onClick={() => {
|
||||
hasDashboardItemCreate.value = CreateDashboardItemType.CLIP
|
||||
createClipHistoryItemIds.value = [historyId]
|
||||
}}
|
||||
>
|
||||
{t('AddTo:::Add to Ignore', { ns: 'contextMenus' })}
|
||||
<div className="ml-auto pl-2">
|
||||
<ClipboardX size={15} />
|
||||
</div>
|
||||
</ContextMenuItem>
|
||||
</ContextMenuSubContent>
|
||||
</ContextMenuSub>
|
||||
)}
|
||||
|
||||
<ContextMenuSeparator />
|
||||
{(arrLinks?.length > 0 && !detectedLanguage) ||
|
||||
(isText && (
|
||||
|
@ -21,6 +21,7 @@ export type ClipboardHistoryItem = {
|
||||
noLinkCard: boolean
|
||||
} | null
|
||||
historyOptions: string | null
|
||||
copiedFromApp: string | null
|
||||
|
||||
title: string | null
|
||||
value: string | null
|
||||
|
@ -95,19 +95,15 @@ where
|
||||
.and_then(|s| s.value_bool)
|
||||
.unwrap_or(true);
|
||||
|
||||
let copied_from_app = match get_active_window() {
|
||||
Ok(active_window) => Some(active_window.app_name),
|
||||
Err(()) => None,
|
||||
};
|
||||
|
||||
if let Ok(mut text) = clipboard_text {
|
||||
text = text.trim().to_string();
|
||||
|
||||
if !text.is_empty() {
|
||||
match get_active_window() {
|
||||
Ok(active_window) => {
|
||||
println!("active window: {:#?}", active_window);
|
||||
}
|
||||
Err(()) => {
|
||||
println!("error occurred while getting the active window");
|
||||
}
|
||||
}
|
||||
|
||||
let mut is_excluded = false;
|
||||
if let Some(setting) = settings_map.get("isExclusionListEnabled") {
|
||||
if let Some(value_bool) = setting.value_bool {
|
||||
@ -185,6 +181,7 @@ where
|
||||
text,
|
||||
detect_options,
|
||||
should_auto_star_on_double_copy,
|
||||
copied_from_app,
|
||||
));
|
||||
}
|
||||
}
|
||||
@ -192,6 +189,7 @@ where
|
||||
do_refresh_clipboard = Some(history_service::add_clipboard_history_from_image(
|
||||
image_binary,
|
||||
should_auto_star_on_double_copy,
|
||||
copied_from_app,
|
||||
));
|
||||
}
|
||||
|
||||
|
@ -115,6 +115,7 @@ pub struct UpdatedItemData {
|
||||
pub struct UpdatedHistoryData {
|
||||
pub history_id: Option<String>,
|
||||
pub history_options: Option<String>,
|
||||
pub copied_from_app: Option<String>,
|
||||
pub title: Option<String>,
|
||||
pub value: Option<String>,
|
||||
pub is_text: Option<bool>,
|
||||
@ -274,6 +275,7 @@ pub struct ClipboardHistory {
|
||||
pub created_date: NaiveDateTime,
|
||||
pub updated_date: NaiveDateTime,
|
||||
pub history_options: Option<String>,
|
||||
pub copied_from_app: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(
|
||||
|
@ -35,6 +35,7 @@ diesel::table! {
|
||||
created_date -> Timestamp,
|
||||
updated_date -> Timestamp,
|
||||
history_options -> Nullable<Text>,
|
||||
copied_from_app -> Nullable<Text>,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +102,7 @@ pub struct RecentClipboardHistoryData {
|
||||
pub struct ClipboardHistoryWithMetaData {
|
||||
pub history_id: String,
|
||||
pub history_options: Option<String>,
|
||||
pub copied_from_app: Option<String>,
|
||||
pub title: Option<String>,
|
||||
pub value: Option<String>,
|
||||
pub value_preview: Option<String>,
|
||||
@ -177,6 +178,7 @@ impl ClipboardHistoryWithMetaData {
|
||||
created_date: history.created_date,
|
||||
updated_date: history.updated_date,
|
||||
history_options: history.history_options,
|
||||
copied_from_app: history.copied_from_app,
|
||||
link_metadata,
|
||||
};
|
||||
|
||||
@ -188,6 +190,7 @@ impl ClipboardHistoryWithMetaData {
|
||||
pub fn add_clipboard_history_from_image(
|
||||
image_data: ImageData,
|
||||
should_auto_star_on_double_copy: bool,
|
||||
_copied_from_app: Option<String>,
|
||||
) -> String {
|
||||
let image = match ImageBuffer::from_raw(
|
||||
image_data
|
||||
@ -277,6 +280,7 @@ pub fn add_clipboard_history_from_image(
|
||||
_preview_height.try_into().unwrap(),
|
||||
_image_height.try_into().unwrap(),
|
||||
_image_width.try_into().unwrap(),
|
||||
_copied_from_app,
|
||||
);
|
||||
|
||||
let _ = insert_clipboard_history(&new_history);
|
||||
@ -320,10 +324,12 @@ fn create_new_history(
|
||||
_image_preview_height: i32,
|
||||
_image_height: i32,
|
||||
_image_width: i32,
|
||||
_copied_from_app: Option<String>,
|
||||
) -> ClipboardHistory {
|
||||
ClipboardHistory {
|
||||
history_id: _history_id,
|
||||
history_options: None,
|
||||
copied_from_app: _copied_from_app,
|
||||
title: None,
|
||||
value: None,
|
||||
value_preview: None,
|
||||
@ -362,6 +368,7 @@ pub fn add_clipboard_history_from_text(
|
||||
text: String,
|
||||
detect_options: LanguageDetectOptions,
|
||||
should_auto_star_on_double_copy: bool,
|
||||
_copied_from_app: Option<String>,
|
||||
) -> String {
|
||||
let mut _is_image_data = is_base64_image(&text);
|
||||
let mut _text_as_json = String::new();
|
||||
@ -498,6 +505,7 @@ pub fn add_clipboard_history_from_text(
|
||||
let new_history = ClipboardHistory {
|
||||
history_id: new_history_id,
|
||||
history_options: None,
|
||||
copied_from_app: _copied_from_app,
|
||||
title: None,
|
||||
value: if !_text_as_json.is_empty() {
|
||||
Some(_text_as_json)
|
||||
|
Loading…
x
Reference in New Issue
Block a user