Skip to content

Commit

Permalink
Merge pull request #27 from kavisherlock/master
Browse files Browse the repository at this point in the history
BugFix for two clippings get removed instead of one when removing clip
  • Loading branch information
saifabusaleh committed Oct 28, 2021
2 parents 90567db + 7814968 commit 3a31776
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/bg/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const getClippings = (request, sendResponse) => {
chrome.storage.sync.get("clippings", (result) => {
let clippings = result.clippings || [];
if (request.selection) {
clippings = [...clippings, { text: request.selection, creationDate: new Date().toLocaleString() }];
clippings = [...clippings, { text: request.selection, creationDate: new Date().getTime() }];
}
chrome.storage.sync.set({ clippings }, () => {
sendResponse({ clippings });
Expand Down
12 changes: 7 additions & 5 deletions src/browser_actions/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const createClipTextElement = (text) => {

const createClipDateElement = (creationDate) => {
const dateDiv = document.createElement("div");
dateDiv.textContent = creationDate;
dateDiv.textContent = new Date(creationDate).toLocaleString();
dateDiv.className = "creation-date";
return dateDiv;
}
Expand Down Expand Up @@ -182,11 +182,12 @@ const setDarkTheme = () => {

const exportJson = () => {
let clipboardHistory = []
const readableClippingsList = clippingsList.map(clip => ({ ...clip, creationDate: new Date(clip.creationDate).toLocaleString() }))
if (!searchText) {
clipboardHistory = JSON.stringify(clippingsList);
clipboardHistory = JSON.stringify(readableClippingsList, null, 2);
} else {
const filteredList = filterClippingsList(clippingsList, searchText);
clipboardHistory = JSON.stringify(filteredList);
const filteredList = filterClippingsList(readableClippingsList, searchText);
clipboardHistory = JSON.stringify(filteredList, null, 2);
}
const exportLink = document.createElement("a");
var exportBlob = new Blob([clipboardHistory], { type: "octet/stream" });
Expand All @@ -196,4 +197,5 @@ const exportJson = () => {
exportLink.setAttribute("href", exportUrl);
exportLink.setAttribute("download", exportFileName);
exportLink.click();
}
}

0 comments on commit 3a31776

Please sign in to comment.