Skip to content

Commit 13d96cd

Browse files
committed
chore: add and remove buttons
new checkbox component to select keys to remove new buttons and handlers for add and remove new content script listeners for add and remove cleaned some logs from theme and edit udpated styles in viewgrid new popup for removing items
1 parent 117968d commit 13d96cd

File tree

12 files changed

+192
-21
lines changed

12 files changed

+192
-21
lines changed

dist/assets/types-68586616.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

dist/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
<meta charset="UTF-8" />
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Session Storage Hub</title>
8-
<script type="module" crossorigin src="/assets/index.html-896f7110.js"></script>
9-
<link rel="modulepreload" crossorigin href="/assets/types-68586616.js">
10-
<link rel="stylesheet" href="/assets/index-25f7160f.css">
8+
<script type="module" crossorigin src="/assets/index.html-11f36aec.js"></script>
9+
<link rel="modulepreload" crossorigin href="/assets/types-62e912eb.js">
10+
<link rel="stylesheet" href="/assets/index-fa5528e0.css">
1111
</head>
1212

1313
<body>

dist/manifest.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"content_scripts": [
2020
{
2121
"js": [
22-
"assets/content.ts-loader-34a4c4a9.js"
22+
"assets/content.ts-loader-45f7e850.js"
2323
],
2424
"matches": [
2525
"<all_urls>"
@@ -41,8 +41,8 @@
4141
"<all_urls>"
4242
],
4343
"resources": [
44-
"assets/types-68586616.js",
45-
"assets/content.ts-2447e755.js"
44+
"assets/types-62e912eb.js",
45+
"assets/content.ts-95edae96.js"
4646
],
4747
"use_dynamic_url": true
4848
}

src/chromeServices/content.ts

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,58 @@ export const copyStorageToClipboard = (
228228
return false; // do not expect a response
229229
}
230230

231+
const addMessageListener = (
232+
message: IChromeMessage,
233+
sender: chrome.runtime.MessageSender,
234+
response: TResponse
235+
) => {
236+
if (validateSender(Sender.Extension, Action.Add, message, sender)) {
237+
try {
238+
const itemKey = new Date().getTime().toString();
239+
sessionStorage.setItem(itemKey, '{}');
240+
241+
const data = {
242+
obj: Object.assign({}, sessionStorage),
243+
itemKey: itemKey,
244+
}
245+
246+
response({ error: null, data: data });
247+
} catch {
248+
response({
249+
error: 'Error adding session storage item',
250+
data: null,
251+
});
252+
}
253+
return true; // we will eventually return a response
254+
}
255+
return false; // do not expect a response
256+
};
257+
258+
const deleteMessageListener = (
259+
message: IChromeMessage,
260+
sender: chrome.runtime.MessageSender,
261+
response: TResponse
262+
) => {
263+
if (validateSender(Sender.Extension, Action.Delete, message, sender)) {
264+
try {
265+
console.log('deleteMessageListener', message);
266+
message.message?.data.forEach((k: string) => {
267+
sessionStorage.removeItem(k);
268+
});
269+
270+
const data = Object.assign({}, sessionStorage);
271+
response({ error: null, data: data });
272+
} catch {
273+
response({
274+
error: 'Error adding session storage item',
275+
data: null,
276+
});
277+
}
278+
return true; // we will eventually return a response
279+
}
280+
return false; // do not expect a response
281+
};
282+
231283
const main = () => {
232284
// prevent duplicate listeners
233285
chrome.runtime.onMessage.removeListener(requestMessageListener);
@@ -237,6 +289,8 @@ const main = () => {
237289
chrome.runtime.onMessage.removeListener(fillStorageMessageListener);
238290
chrome.runtime.onMessage.removeListener(checkReleaseListener);
239291
chrome.runtime.onMessage.removeListener(copyStorageToClipboard);
292+
chrome.runtime.onMessage.removeListener(addMessageListener);
293+
chrome.runtime.onMessage.removeListener(deleteMessageListener);
240294

241295
// Fired when a message is sent from either an extension process or a content script.
242296
chrome.runtime.onMessage.addListener(requestMessageListener);
@@ -246,6 +300,8 @@ const main = () => {
246300
chrome.runtime.onMessage.addListener(fillStorageMessageListener);
247301
chrome.runtime.onMessage.addListener(checkReleaseListener);
248302
chrome.runtime.onMessage.addListener(copyStorageToClipboard);
303+
chrome.runtime.onMessage.addListener(addMessageListener);
304+
chrome.runtime.onMessage.addListener(deleteMessageListener);
249305
};
250306

251307
main();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { HTMLProps, forwardRef } from "react";
2+
3+
interface ICheckboxProps extends HTMLProps<HTMLInputElement> {
4+
className?: string;
5+
label?: string;
6+
}
7+
8+
const Checkbox = forwardRef(function checkbox(props: ICheckboxProps, ref: any) {
9+
return (
10+
<label className={`flex items-center justify-around ${props.className}`} htmlFor={props.label}>
11+
{props.label ?? 'checkbox'}
12+
<input ref={ref} id={props.label} type={'checkbox'} />
13+
</label>
14+
);
15+
});
16+
17+
export default Checkbox;

src/components/Editor/Editor.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,6 @@ const Editor = () => {
6767
const { editorTheme } = useTheme();
6868
const [code, setCode] = useState<string>('');
6969

70-
71-
console.log('theme', editorTheme);
7270
const customLinter = () => {
7371
return (view: EditorView): Diagnostic[] => {
7472
try {

src/components/ViewGrid/ViewGrid.css

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
.ViewGrid {
2-
/* display: grid;
3-
grid-template-columns: 3fr 9fr;
4-
grid-template-areas: 'key value'; */
52
border: 0.0625rem solid var(--borderColor);
63
padding: 0.325rem;
74
max-height: 21rem;
@@ -19,14 +16,9 @@
1916

2017
.ViewGrid__30 {
2118
border-right: 0.0125rem solid var(--borderColor);
22-
/* grid-area: key; */
2319
flex-direction: column;
2420
word-wrap: break-word;
2521
word-break: break-all;
2622
overflow-x: clip;
2723
padding: 0 0.125rem;
28-
}
29-
30-
.ViewGrid__70 {
31-
/* grid-area: value; */
3224
}

src/providers/useStorageData.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ interface IExtendedDataProps extends IDataProps {
2626

2727
function reducer(state: any, action: { type: string; data: any }) {
2828
switch (action.type) {
29+
// use for add and delete
2930
case 'setSessionStorageData': {
3031
const d = action.data.sessionStorageData;
3132
const k = Object.keys(d);

src/providers/useTheme.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,6 @@ function getStylesFromTheme(name: Themes) {
7777
}
7878

7979
function getEditorTheme(name: Themes) {
80-
console.log('getting theme:', name);
81-
console.log('theme val: ', githubLight);
8280
switch (name) {
8381
case 'light': return githubLight;
8482
case 'dark': return githubDark;

src/types/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ export enum Action {
1414
Check,
1515
FillStorage,
1616
Copy,
17+
Add,
18+
Delete
1719
}
1820

1921
export enum Themes {

0 commit comments

Comments
 (0)