Skip to content

Commit

Permalink
πŸš€ Release/1.3.1 (#206)
Browse files Browse the repository at this point in the history
πŸš€ Release/1.3.1
  • Loading branch information
yjkwon07 authored Jun 28, 2022
2 parents cbb0fbe + dc92ebc commit 1ec25e8
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 9 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "urlink-chrome-extension",
"version": "1.3.0",
"version": "1.3.1",
"private": true,
"dependencies": {
"@date-io/moment": "^1.3.13",
Expand Down
4 changes: 2 additions & 2 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "urLink",
"version": "1.3.0",
"version": "1.3.1",
"manifest_version": 2,
"description": "λΆλ§ˆν¬λ³΄λ‹€ μ†μ‰½κ²Œ μ›Ήμ‚¬μ΄νŠΈλ₯Ό λ³΄κ΄€ν•˜κ³  μ •λ¦¬ν•˜μ„Έμš”.",
"permissions": ["<all_urls>", "identity", "history", "notifications"],
"permissions": ["<all_urls>", "identity", "history", "notifications", "bookmarks"],
"icons": {
"16": "images/logo/logo16.png",
"24": "images/logo/logo24.png",
Expand Down
79 changes: 75 additions & 4 deletions src/main/pages/Home/AppBar/index.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import React, { useEffect, useCallback, memo, useState, useMemo, useRef } from 'react'

import OutboxIcon from '@mui/icons-material/Outbox'
import { Badge, List, Popover, Drawer } from '@mui/material'
import clsx from 'clsx'
import { useDispatch, useSelector } from 'react-redux'

import { AlertModal } from '@/main/components/modals'
import { alarmNoticeSelector } from '@/modules/alarmNotice'
import { categorySelector } from '@/modules/category'
import { categorySelector, useCategories } from '@/modules/category'
import { useHistoryLinks } from '@/modules/historyLink'
import { uiSelector } from '@/modules/ui'
import { createBookmark, createBookmarkFolder } from '@/utils/chromeApis/bookmarks'
import alarmImg from '@assets/images/alarm.png'
import historyImg from '@assets/images/history.png'
import personImg from '@assets/images/person.png'
import useDebounce from '@hooks/useDebounce'
import SearchBar from '@main/components/SearchBar'
import { linkSearchFilterChangeState } from '@modules/link'
import { linkSearchFilterChangeState, linkSelector, linksReadThunk, useLinks } from '@modules/link'
import { uiSelector, useToast, useDialog, MODAL_NAME } from '@modules/ui'
import { GAEvent } from '@utils/ga'

import AlarmList from './AlarmList'
Expand All @@ -33,7 +36,15 @@ function AppBar() {
const category = useSelector(categorySelector.selectedCategory)
const alarmList = useSelector(alarmNoticeSelector.listData)
const isAppBarInversion = useSelector(uiSelector.isAppBarInversion)

const { categories } = useCategories()
const links = useSelector((state) => linkSelector.linksData(state))
const { openToast } = useToast()

const {
open: migrateBookmarksOpen,
toggle: migrateBookmarksToggle,
close: migrateBookmarksClose,
} = useDialog(MODAL_NAME.BOOKMARKS_MIGRATION_MODAL)
const { reload } = useHistoryLinks()

const notReadAlarmList = useMemo(() => {
Expand All @@ -46,6 +57,7 @@ function AppBar() {
const [isHistoryOpen, setIsHistoryOpen] = useState(false)
const [isAlarmOpen, setIsAlarmOpen] = useState(false)
const [isProfileOpen, setIsProfileOpen] = useState(false)
const [isReadyForMigration, setIsReadyForMigration] = useState(false)

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

const fetchAllLinkData = async () => {
//λ‘œλ”© 처리 ν•„μš”
migrateBookmarksClose()
if (categories.length) {
for (const category of categories) {
await dispatch(linksReadThunk({ categoryId: category.id }, { key: category.id }))
}
}
setIsReadyForMigration(true)
}

const handleMigrateBookmarks = useCallback(() => {
const callback = (urlinkFolderId) => {
for (const category of categories) {
//μΉ΄ν…Œκ³ λ¦¬ λ³„λ‘œ 뢁마크 폴더 생성
createBookmarkFolder({ id: urlinkFolderId, title: category.name }, (id) => {
for (const link of links[category.id]) {
//μΉ΄ν…Œκ³ λ¦¬ 뢁마크 폴더 내에 링크 μ‚½μž…
createBookmark({
id,
title: link.title,
url: link.path,
})
}
})
}

setIsReadyForMigration(false)
openToast({ type: 'success', message: '이동이 μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. 뢁마크λ₯Ό ν™•μΈν•΄μ£Όμ„Έμš”.' })
}
//μœ μ–΄λ§ν¬ 뢁마크 폴더 생성
createBookmarkFolder({ id: '1', title: 'urLink Bookmarks' }, callback)
}, [links, categories, openToast])

useEffect(() => {
dispatch(linkSearchFilterChangeState({ selectedName, keyword: debouncedKeyword }))
}, [dispatch, selectedName, debouncedKeyword])

useEffect(() => {
if (isReadyForMigration) handleMigrateBookmarks()
}, [isReadyForMigration, handleMigrateBookmarks])

return (
<>
<div
Expand All @@ -91,6 +141,17 @@ function AppBar() {
disabled={!category?.id || isHistoryOpen}
/>
<List className={classes.iconButtonGroup}>
<StyledListItem
button
aria-describedby="bookmarks"
onClick={() => {
migrateBookmarksToggle()
GAEvent('μ•±λ°”', '뢁마크 이동 λ²„νŠΌ 클릭')
}}
>
<OutboxIcon />
</StyledListItem>

<StyledListItem
button
aria-describedby="history-drawer"
Expand Down Expand Up @@ -155,6 +216,16 @@ function AppBar() {
</List>
</div>

{migrateBookmarksOpen && (
<AlertModal
openBool={migrateBookmarksOpen}
btnYesText="이동"
contentText="λͺ¨λ“  링크λ₯Ό 뢁마크둜 μ΄λ™ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?"
handleClose={migrateBookmarksClose}
handleYesClick={fetchAllLinkData}
/>
)}

<Drawer
className={classes.drawer}
variant="persistent"
Expand Down
1 change: 1 addition & 0 deletions src/main/pages/Home/AppBar/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const StyledListItem = withStyles((theme) => ({

backgroundColor: 'white',
borderRadius: 8,
justifyContent: 'center',

'&:hover': {
backgroundColor: '#d6e4f5',
Expand Down
1 change: 1 addition & 0 deletions src/modules/link/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createRequestAction, createRequestThunk } from '../helpers'
export const LINK = 'LINK'

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

export const linkCreate = createRequestAction(`${LINK}/CREATE`)
export const linkCreateThunk = createRequestThunk(linkCreate)
Expand Down
1 change: 1 addition & 0 deletions src/modules/ui/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const MODAL_NAME = {
DELETE_CATEGORY_ALERT_MODAL: 'DELETE_CATEGORY_ALERT_MODAL',
UPDATE_CATEGORY_MODAL: 'UPDATE_CATEGORY_MODAL',
ADD_CATEGORY_MODAL: 'ADD_CATEGORY_MODAL',
BOOKMARKS_MIGRATION_MODAL: 'BOOKMARKS_MIGRATION_MODAL',
}

export const DRAG = {
Expand Down
30 changes: 30 additions & 0 deletions src/utils/chromeApis/bookmarks.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
export function getBookmarks() {
chrome.bookmarks.getTree((data) => console.log(data))
}

const onBookmarkFolderAdded = (newFolder, fn) => {
fn(newFolder.id)
}

export function createBookmark(data) {
const { id, title, url } = data
chrome.bookmarks.create({
parentId: id,
title,
url,
})
}

export function createBookmarkFolder(data, fn) {
const { id, title } = data
const idCheck = chrome.runtime?.id
if (idCheck) {
chrome.bookmarks.create(
{
parentId: id,
title: title,
},
(newFolder) => onBookmarkFolderAdded(newFolder, fn)
)
}
}

0 comments on commit 1ec25e8

Please sign in to comment.