Skip to content

Commit 134a432

Browse files
committed
fix(extension): update save flow
1 parent 88f5f39 commit 134a432

File tree

9 files changed

+1917
-2550
lines changed

9 files changed

+1917
-2550
lines changed

clients/extension/action/app.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { NoteEdge } from '@common/types/pocket'
77

88
export function App() {
99
const [isOpen, setIsOpen] = useState(false)
10-
const [saveStatus, setSaveStatus] = useState('unsaved')
10+
const [saveStatus, setSaveStatus] = useState('saving')
1111
const [errorMessage, setErrorMessage] = useState<string | undefined>(undefined)
1212
const [preview, setPreview] = useState<ExtPreview | undefined>(undefined)
1313
const [tags, setTags] = useState<string[]>([])

clients/extension/background/icon-updates/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export async function setDefaultIcon() {
66
}
77

88
export async function setToolbarIcon(tabId: number, isSaved: boolean) {
9-
const imageData = isSaved ? savedIcon() : inactiveIcon()
9+
// const imageData = isSaved ? savedIcon() : inactiveIcon()
10+
const imageData = inactiveIcon()
1011
await chrome.action.setIcon({ tabId, imageData })
1112
}
1213

clients/extension/background/index.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,18 @@ let saveQueue: ExtSave | null = null
1818
chrome.runtime.onInstalled.addListener(function () {
1919
// Use SVG icons over the png for more control
2020
void setDefaultIcon()
21-
2221
// handle.setContextMenus()
2322
})
2423

2524
/* Tab Changes
2625
–––––––––––––––––––––––––––––––––––––––––––––––––– */
27-
chrome.tabs.onUpdated.addListener(tabUpdated)
28-
function tabUpdated(tabId: number, changeInfo: chrome.tabs.TabChangeInfo) {
29-
// if actively loading a new page, unset save state on icon
30-
if (changeInfo.status === 'loading' && changeInfo.url) {
31-
void setToolbarIcon(tabId, false)
32-
}
33-
}
26+
// chrome.tabs.onUpdated.addListener(tabUpdated)
27+
// function tabUpdated(tabId: number, changeInfo: chrome.tabs.TabChangeInfo) {
28+
// // if actively loading a new page, unset save state on icon
29+
// // if (changeInfo.status === 'loading' && changeInfo.url) {
30+
// // void setToolbarIcon(tabId, false)
31+
// // }
32+
// }
3433

3534
/* Message handling
3635
–––––––––––––––––––––––––––––––––––––––––––––––––– */

clients/extension/components/action-container/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export function ActionContainer({
1010
isOpen = false,
1111
errorMessage,
1212
preview,
13+
saveStatus,
1314
notes,
1415
tags
1516
}: {
@@ -23,7 +24,7 @@ export function ActionContainer({
2324
}) {
2425
return isOpen ? (
2526
<div className="extension">
26-
<ExtensionHeader />
27+
<ExtensionHeader saveStatus={saveStatus} />
2728
{preview ? (
2829
<>
2930
<SavedScreen preview={preview} notes={notes} tags={tags} />

clients/extension/components/action-footer/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function ExtensionFooter({ errorMessage }: { errorMessage?: string }) {
77
return (
88
<footer className={style.footer}>
99
<button>
10-
<NotesIcon /> Attach Notes
10+
<NotesIcon /> Notes
1111
</button>
1212
<button>
1313
<DeleteIcon />

clients/extension/components/action-header/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import style from './style.module.css'
22
import { OverflowMenuIcon } from '../icons/OverflowMenuIcon'
3+
import { SaveFilledIcon } from '../icons/SaveFilledIcon'
34
import { SaveIcon } from '../icons/SaveIcon'
45
import { SavedLoader } from '../saved-loader'
56

6-
export function ExtensionHeader() {
7+
export function ExtensionHeader({ saveStatus }: { saveStatus?: string }) {
8+
const loaded = saveStatus !== 'saving'
79
return (
810
<header className={style.header}>
9-
<SaveIcon />
10-
<SavedLoader />
11+
{loaded ? <SaveFilledIcon className={style.icon} /> : <SaveIcon className={style.icon} />}
12+
{loaded ? <div /> : <SavedLoader />}
1113
<OverflowMenuIcon />
1214
</header>
1315
)
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
.header {
2-
display: flex;
3-
justify-content: space-between;
2+
display: grid;
3+
grid-template-columns: 32px auto 32px;
44
align-items: center;
55
padding: 0.5rem 1rem;
66
font-size: 1rem;
77
font-weight: 600;
88
line-height: 19.09px;
99
letter-spacing: -0.03em;
1010
border-bottom: 1px solid var(--color-divider);
11+
min-height: 2.5rem;
12+
}
13+
14+
.icon {
15+
color: var(--color-brandPocket);
16+
width: 24px;
17+
height: 24px;
1118
}
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
import type { SVGProps } from "react"
1+
import type { SVGProps } from 'react'
22

3-
export const SaveFilledIcon = ({className, ...rest}: SVGProps<SVGSVGElement>) => {
3+
export const SaveFilledIcon = ({ className, ...rest }: SVGProps<SVGSVGElement>) => {
44
const iconClass = ['icon', className && className].join(' ')
55
return (
6-
<svg fill="currentColor" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" aria-hidden="true" className={iconClass} {...rest}><path fillRule="evenodd" d="M12 21c5.523 0 10-4.477 10-10V5a2 2 0 0 0-2-2H4c-1.105 0-2 .893-2 1.998V11c0 5.523 4.477 10 10 10M8.707 9.293a1 1 0 0 0-1.414 1.414l4 4a1 1 0 0 0 1.414 0l4-4a1 1 0 0 0-1.414-1.414L12 12.586z" clipRule="evenodd"/></svg>
7-
)}
8-
6+
<svg
7+
fill="currentColor"
8+
xmlns="http://www.w3.org/2000/svg"
9+
viewBox="0 0 24 24"
10+
aria-hidden="true"
11+
className={iconClass}
12+
{...rest}>
13+
<path
14+
fillRule="evenodd"
15+
d="M12 21c5.523 0 10-4.477 10-10V5a2 2 0 0 0-2-2H4c-1.105 0-2 .893-2 1.998V11c0 5.523 4.477 10 10 10M8.707 9.293a1 1 0 0 0-1.414 1.414l4 4a1 1 0 0 0 1.414 0l4-4a1 1 0 0 0-1.414-1.414L12 12.586z"
16+
clipRule="evenodd"
17+
/>
18+
</svg>
19+
)
20+
}

0 commit comments

Comments
 (0)