-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
247 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
use crate::{constants::MAX_TEXT_PREVIEW, types::orm_query::ClipboardWithRelations}; | ||
|
||
pub fn trim_clipboard_data( | ||
mut clipboards: Vec<ClipboardWithRelations>, | ||
) -> Vec<ClipboardWithRelations> { | ||
for clipboard in &mut clipboards { | ||
// Trim text content | ||
if let Some(text) = &mut clipboard.text { | ||
text.data = truncate_text(&text.data, MAX_TEXT_PREVIEW); | ||
} | ||
|
||
// Trim HTML content | ||
if let Some(html) = &mut clipboard.html { | ||
html.data = truncate_text(&html.data, MAX_TEXT_PREVIEW); | ||
} | ||
|
||
// Trim RTF content | ||
if let Some(rtf) = &mut clipboard.rtf { | ||
rtf.data = truncate_text(&rtf.data, MAX_TEXT_PREVIEW); | ||
} | ||
|
||
// Remove image binary data but keep metadata | ||
if let Some(image) = &mut clipboard.image { | ||
image.data = Vec::new(); // Clear binary data | ||
// Thumbnail, dimensions, size etc are preserved | ||
} | ||
|
||
// Clear file binary data but keep metadata | ||
for file in &mut clipboard.files { | ||
file.data = Vec::new(); // Clear binary data | ||
// Name, extension, size etc are preserved | ||
} | ||
} | ||
|
||
clipboards | ||
} | ||
|
||
fn truncate_text(text: &str, max_length: usize) -> String { | ||
if text.len() <= max_length { | ||
text.to_string() | ||
} else { | ||
format!("{}...", &text[..max_length]) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ pub mod keyboard; | |
pub mod language; | ||
pub mod macros; | ||
pub mod types; | ||
pub mod clipboard; | ||
pub mod constants; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.