Skip to content

Commit 1ec25e8

Browse files
authored
πŸš€ Release/1.3.1 (#206)
πŸš€ Release/1.3.1
2 parents cbb0fbe + dc92ebc commit 1ec25e8

File tree

8 files changed

+113
-9
lines changed

8 files changed

+113
-9
lines changed

β€Žpackage-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "urlink-chrome-extension",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"private": true,
55
"dependencies": {
66
"@date-io/moment": "^1.3.13",

β€Žpublic/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"name": "urLink",
3-
"version": "1.3.0",
3+
"version": "1.3.1",
44
"manifest_version": 2,
55
"description": "λΆλ§ˆν¬λ³΄λ‹€ μ†μ‰½κ²Œ μ›Ήμ‚¬μ΄νŠΈλ₯Ό λ³΄κ΄€ν•˜κ³  μ •λ¦¬ν•˜μ„Έμš”.",
6-
"permissions": ["<all_urls>", "identity", "history", "notifications"],
6+
"permissions": ["<all_urls>", "identity", "history", "notifications", "bookmarks"],
77
"icons": {
88
"16": "images/logo/logo16.png",
99
"24": "images/logo/logo24.png",

β€Žsrc/main/pages/Home/AppBar/index.jsx

Lines changed: 75 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
import React, { useEffect, useCallback, memo, useState, useMemo, useRef } from 'react'
22

3+
import OutboxIcon from '@mui/icons-material/Outbox'
34
import { Badge, List, Popover, Drawer } from '@mui/material'
45
import clsx from 'clsx'
56
import { useDispatch, useSelector } from 'react-redux'
67

8+
import { AlertModal } from '@/main/components/modals'
79
import { alarmNoticeSelector } from '@/modules/alarmNotice'
8-
import { categorySelector } from '@/modules/category'
10+
import { categorySelector, useCategories } from '@/modules/category'
911
import { useHistoryLinks } from '@/modules/historyLink'
10-
import { uiSelector } from '@/modules/ui'
12+
import { createBookmark, createBookmarkFolder } from '@/utils/chromeApis/bookmarks'
1113
import alarmImg from '@assets/images/alarm.png'
1214
import historyImg from '@assets/images/history.png'
1315
import personImg from '@assets/images/person.png'
1416
import useDebounce from '@hooks/useDebounce'
1517
import SearchBar from '@main/components/SearchBar'
16-
import { linkSearchFilterChangeState } from '@modules/link'
18+
import { linkSearchFilterChangeState, linkSelector, linksReadThunk, useLinks } from '@modules/link'
19+
import { uiSelector, useToast, useDialog, MODAL_NAME } from '@modules/ui'
1720
import { GAEvent } from '@utils/ga'
1821

1922
import AlarmList from './AlarmList'
@@ -33,7 +36,15 @@ function AppBar() {
3336
const category = useSelector(categorySelector.selectedCategory)
3437
const alarmList = useSelector(alarmNoticeSelector.listData)
3538
const isAppBarInversion = useSelector(uiSelector.isAppBarInversion)
36-
39+
const { categories } = useCategories()
40+
const links = useSelector((state) => linkSelector.linksData(state))
41+
const { openToast } = useToast()
42+
43+
const {
44+
open: migrateBookmarksOpen,
45+
toggle: migrateBookmarksToggle,
46+
close: migrateBookmarksClose,
47+
} = useDialog(MODAL_NAME.BOOKMARKS_MIGRATION_MODAL)
3748
const { reload } = useHistoryLinks()
3849

3950
const notReadAlarmList = useMemo(() => {
@@ -46,6 +57,7 @@ function AppBar() {
4657
const [isHistoryOpen, setIsHistoryOpen] = useState(false)
4758
const [isAlarmOpen, setIsAlarmOpen] = useState(false)
4859
const [isProfileOpen, setIsProfileOpen] = useState(false)
60+
const [isReadyForMigration, setIsReadyForMigration] = useState(false)
4961

5062
const [selectedName, setSelectedName] = useState(SEARCH_FILTER_LIST[0].search)
5163
const [keyword, setKeyword] = useState('')
@@ -68,10 +80,48 @@ function AppBar() {
6880
[handleResetInput]
6981
)
7082

83+
const fetchAllLinkData = async () => {
84+
//λ‘œλ”© 처리 ν•„μš”
85+
migrateBookmarksClose()
86+
if (categories.length) {
87+
for (const category of categories) {
88+
await dispatch(linksReadThunk({ categoryId: category.id }, { key: category.id }))
89+
}
90+
}
91+
setIsReadyForMigration(true)
92+
}
93+
94+
const handleMigrateBookmarks = useCallback(() => {
95+
const callback = (urlinkFolderId) => {
96+
for (const category of categories) {
97+
//μΉ΄ν…Œκ³ λ¦¬ λ³„λ‘œ 뢁마크 폴더 생성
98+
createBookmarkFolder({ id: urlinkFolderId, title: category.name }, (id) => {
99+
for (const link of links[category.id]) {
100+
//μΉ΄ν…Œκ³ λ¦¬ 뢁마크 폴더 내에 링크 μ‚½μž…
101+
createBookmark({
102+
id,
103+
title: link.title,
104+
url: link.path,
105+
})
106+
}
107+
})
108+
}
109+
110+
setIsReadyForMigration(false)
111+
openToast({ type: 'success', message: '이동이 μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 뢁마크λ₯Ό ν™•μΈν•΄μ£Όμ„Έμš”.' })
112+
}
113+
//μœ μ–΄λ§ν¬ 뢁마크 폴더 생성
114+
createBookmarkFolder({ id: '1', title: 'urLink Bookmarks' }, callback)
115+
}, [links, categories, openToast])
116+
71117
useEffect(() => {
72118
dispatch(linkSearchFilterChangeState({ selectedName, keyword: debouncedKeyword }))
73119
}, [dispatch, selectedName, debouncedKeyword])
74120

121+
useEffect(() => {
122+
if (isReadyForMigration) handleMigrateBookmarks()
123+
}, [isReadyForMigration, handleMigrateBookmarks])
124+
75125
return (
76126
<>
77127
<div
@@ -91,6 +141,17 @@ function AppBar() {
91141
disabled={!category?.id || isHistoryOpen}
92142
/>
93143
<List className={classes.iconButtonGroup}>
144+
<StyledListItem
145+
button
146+
aria-describedby="bookmarks"
147+
onClick={() => {
148+
migrateBookmarksToggle()
149+
GAEvent('μ•±λ°”', '뢁마크 이동 λ²„νŠΌ 클릭')
150+
}}
151+
>
152+
<OutboxIcon />
153+
</StyledListItem>
154+
94155
<StyledListItem
95156
button
96157
aria-describedby="history-drawer"
@@ -155,6 +216,16 @@ function AppBar() {
155216
</List>
156217
</div>
157218

219+
{migrateBookmarksOpen && (
220+
<AlertModal
221+
openBool={migrateBookmarksOpen}
222+
btnYesText="이동"
223+
contentText="λͺ¨λ“  링크λ₯Ό 뢁마크둜 μ΄λ™ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?"
224+
handleClose={migrateBookmarksClose}
225+
handleYesClick={fetchAllLinkData}
226+
/>
227+
)}
228+
158229
<Drawer
159230
className={classes.drawer}
160231
variant="persistent"

β€Žsrc/main/pages/Home/AppBar/style.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ export const StyledListItem = withStyles((theme) => ({
5252

5353
backgroundColor: 'white',
5454
borderRadius: 8,
55+
justifyContent: 'center',
5556

5657
'&:hover': {
5758
backgroundColor: '#d6e4f5',

β€Žsrc/modules/link/reducer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { createRequestAction, createRequestThunk } from '../helpers'
55
export const LINK = 'LINK'
66

77
export const linksRead = createRequestAction(`${LINK}/LIST/READ`)
8+
export const linksReadThunk = createRequestThunk(linksRead)
89

910
export const linkCreate = createRequestAction(`${LINK}/CREATE`)
1011
export const linkCreateThunk = createRequestThunk(linkCreate)

β€Žsrc/modules/ui/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export const MODAL_NAME = {
44
DELETE_CATEGORY_ALERT_MODAL: 'DELETE_CATEGORY_ALERT_MODAL',
55
UPDATE_CATEGORY_MODAL: 'UPDATE_CATEGORY_MODAL',
66
ADD_CATEGORY_MODAL: 'ADD_CATEGORY_MODAL',
7+
BOOKMARKS_MIGRATION_MODAL: 'BOOKMARKS_MIGRATION_MODAL',
78
}
89

910
export const DRAG = {

β€Žsrc/utils/chromeApis/bookmarks.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
export function getBookmarks() {
2+
chrome.bookmarks.getTree((data) => console.log(data))
3+
}
4+
5+
const onBookmarkFolderAdded = (newFolder, fn) => {
6+
fn(newFolder.id)
7+
}
8+
9+
export function createBookmark(data) {
10+
const { id, title, url } = data
11+
chrome.bookmarks.create({
12+
parentId: id,
13+
title,
14+
url,
15+
})
16+
}
17+
18+
export function createBookmarkFolder(data, fn) {
19+
const { id, title } = data
20+
const idCheck = chrome.runtime?.id
21+
if (idCheck) {
22+
chrome.bookmarks.create(
23+
{
24+
parentId: id,
25+
title: title,
26+
},
27+
(newFolder) => onBookmarkFolderAdded(newFolder, fn)
28+
)
29+
}
30+
}

0 commit comments

Comments
Β (0)