When loading the initial history from the database, only the lastClipboardText or lastClipboardImage from the most recent item is preserved. However, if the most recent item is text, lastClipboardImage won't be initialized from the database. This could lead to duplicate entries being saved if the clipboard currently contains an image that was already in the database. Consider checking both the most recent text and image items separately.
// Find the most recent text item
const lastTextItem = this.history.find(item => item.type === "text" && item.text);
if (lastTextItem) {
this.lastClipboardText = lastTextItem.text;
}
// Find the most recent image item
const lastImageItem = this.history.find(item => item.type === "image" && item.image);
if (lastImageItem) {
this.lastClipboardImage = lastImageItem.image;
}
Originally posted by @Copilot in #19
Originally posted by @Copilot in #19