Skip to content

Commit

Permalink
Merge pull request #78 from breeze2/release/v2.2.2
Browse files Browse the repository at this point in the history
Release/v2.2.2
  • Loading branch information
breeze2 committed Dec 1, 2019
2 parents c343206 + 369431a commit 19b303e
Show file tree
Hide file tree
Showing 10 changed files with 158 additions and 31 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [2.2.2](https://github.com/breeze2/breader/compare/v2.2.1...v2.2.2) (2019-12-01)

### Bug Fixes

- **feed:** feed icon display ([58da4cf](https://github.com/breeze2/breader/commit/58da4cfdcadfbda430b9055fd73f338f3db0cb90)), closes [#75](https://github.com/breeze2/breader/issues/75)

### [2.2.1](https://github.com/breeze2/breader/compare/v2.2.0...v2.2.1) (2019-11-30)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "breader",
"version": "2.2.1",
"version": "2.2.2",
"private": true,
"description": "A simple RSS reader.",
"homepage": "https://breeze2.github.io/breader",
Expand Down
1 change: 1 addition & 0 deletions src/__test__/SettingsModal.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ describe('SettingsModal Testing', () => {
const mockProps: ISettingsModalProps = {
asyncDeleteFeeds: jest.fn(),
feeds: Immutable.List<IFeed>([feed]),
feedsMap: Immutable.Map<IFeed>({ [feed._id]: feed }),
language: 'en-US',
onClose: jest.fn(),
onLanguageChange: jest.fn(),
Expand Down
88 changes: 88 additions & 0 deletions src/__test__/__snapshots__/SettingsModal.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,28 @@ exports[`SettingsModal Testing snapshot testing 1`] = `
},
]
}
feedsMap={
Immutable.Map {
"https://breeze2.github.io/blog/atom.xml": Object {
"_id": "https://breeze2.github.io/blog/atom.xml",
"_rev": "2-0af48b1987682ae7d7128fecbd0feb4a",
"author": "Linyifeng",
"categories": Array [],
"createTime": 1575123471750,
"deleteTime": 0,
"description": "林柏格",
"etag": "5d91672a-72e58\\"",
"favicon": "https://breeze2.github.io/favicon.ico",
"generator": "Hexo (http://hexo.io/)",
"language": "",
"link": "https://breeze2.github.io/blog/",
"publishTime": 1569810157082,
"time": 1569810157082,
"title": "Lin Blog",
"url": "https://breeze2.github.io/blog/atom.xml",
},
}
}
language="en-US"
onClose={
[MockFunction] {
Expand Down Expand Up @@ -172,6 +194,28 @@ exports[`SettingsModal Testing snapshot testing 1`] = `
},
]
}
feedsMap={
Immutable.Map {
"https://breeze2.github.io/blog/atom.xml": Object {
"_id": "https://breeze2.github.io/blog/atom.xml",
"_rev": "2-0af48b1987682ae7d7128fecbd0feb4a",
"author": "Linyifeng",
"categories": Array [],
"createTime": 1575123471750,
"deleteTime": 0,
"description": "林柏格",
"etag": "5d91672a-72e58\\"",
"favicon": "https://breeze2.github.io/favicon.ico",
"generator": "Hexo (http://hexo.io/)",
"language": "",
"link": "https://breeze2.github.io/blog/",
"publishTime": 1569810157082,
"time": 1569810157082,
"title": "Lin Blog",
"url": "https://breeze2.github.io/blog/atom.xml",
},
}
}
intl={
Object {
"defaultFormats": Object {},
Expand Down Expand Up @@ -1245,6 +1289,28 @@ exports[`SettingsModal Testing snapshot testing 1`] = `
},
]
}
feedsMap={
Immutable.Map {
"https://breeze2.github.io/blog/atom.xml": Object {
"_id": "https://breeze2.github.io/blog/atom.xml",
"_rev": "2-0af48b1987682ae7d7128fecbd0feb4a",
"author": "Linyifeng",
"categories": Array [],
"createTime": 1575123471750,
"deleteTime": 0,
"description": "林柏格",
"etag": "5d91672a-72e58\\"",
"favicon": "https://breeze2.github.io/favicon.ico",
"generator": "Hexo (http://hexo.io/)",
"language": "",
"link": "https://breeze2.github.io/blog/",
"publishTime": 1569810157082,
"time": 1569810157082,
"title": "Lin Blog",
"url": "https://breeze2.github.io/blog/atom.xml",
},
}
}
onDeleteFeed={[Function]}
>
<SettingFeedListComponent
Expand All @@ -1270,6 +1336,28 @@ exports[`SettingsModal Testing snapshot testing 1`] = `
},
]
}
feedsMap={
Immutable.Map {
"https://breeze2.github.io/blog/atom.xml": Object {
"_id": "https://breeze2.github.io/blog/atom.xml",
"_rev": "2-0af48b1987682ae7d7128fecbd0feb4a",
"author": "Linyifeng",
"categories": Array [],
"createTime": 1575123471750,
"deleteTime": 0,
"description": "林柏格",
"etag": "5d91672a-72e58\\"",
"favicon": "https://breeze2.github.io/favicon.ico",
"generator": "Hexo (http://hexo.io/)",
"language": "",
"link": "https://breeze2.github.io/blog/",
"publishTime": 1569810157082,
"time": 1569810157082,
"title": "Lin Blog",
"url": "https://breeze2.github.io/blog/atom.xml",
},
}
}
intl={
Object {
"defaultFormats": Object {},
Expand Down
19 changes: 18 additions & 1 deletion src/components/AppMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export interface IAppMenuProps

export interface IAppMenuState {
isAddFeedModalVisible: boolean
openedSubmenuKeys: string[]
}

export class AppMenuComponent extends Component<
Expand All @@ -54,6 +55,7 @@ export class AppMenuComponent extends Component<
super(props)
this.state = {
isAddFeedModalVisible: false,
openedSubmenuKeys: ['subscriptions'],
}
}
public handleAddFeedClick = () => {
Expand Down Expand Up @@ -105,8 +107,12 @@ export class AppMenuComponent extends Component<
this.props.asyncSelectMenuKey(param.key)
}
public setFeedFaviconDefault = (id: string) => {
const { feedsMap, setFeedFavicon } = this.props
if (id) {
this.props.setFeedFavicon(id, defaultFavicon)
const ifeed = feedsMap.get(id)
if (ifeed && ifeed.favicon !== defaultFavicon) {
setFeedFavicon(id, defaultFavicon)
}
}
return true
}
Expand All @@ -119,9 +125,18 @@ export class AppMenuComponent extends Component<
this.props.updateOnlineStatus()
}
public handleSubscriptionsClick = () => {
const { openedSubmenuKeys } = this.state
const index = openedSubmenuKeys.indexOf('subscriptions')
if (index > -1) {
openedSubmenuKeys.splice(index, 1)
}
if (this.props.feeds.size === 0) {
this.handleAddFeedClick()
openedSubmenuKeys.push('subscriptions')
} else if (index === -1) {
openedSubmenuKeys.push('subscriptions')
}
this.setState({ openedSubmenuKeys })
}
public componentDidMount() {
this.props.setIsFetchingArticles(true)
Expand All @@ -146,6 +161,7 @@ export class AppMenuComponent extends Component<
onlineStatus,
selectedMenuKey,
} = this.props
const { openedSubmenuKeys } = this.state
const feedsCount = feeds.size
return (
<div className="app-menu">
Expand All @@ -158,6 +174,7 @@ export class AppMenuComponent extends Component<
<Menu
defaultSelectedKeys={[selectedMenuKey]}
defaultOpenKeys={['subscriptions']}
openKeys={openedSubmenuKeys}
mode="inline"
onSelect={this.handleSelect}>
<MenuItem key={EMenuKey.ALL_ITEMS}>
Expand Down
50 changes: 30 additions & 20 deletions src/components/SettingFeedList.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { Avatar, Button, List as AntdList } from 'antd'
import Immutable from 'immutable'
import React, { PureComponent } from 'react'
import { Scrollbars } from 'react-custom-scrollbars'
import { FormattedMessage, injectIntl, WrappedComponentProps } from 'react-intl'
import defaultFavicon from '../images/rss.png'
import { IFeed } from '../schemas'
import '../styles/SettingFeedList.less'
import Utils from '../utils'

export interface ISettingFeedListProps {
feedsMap: Immutable.Map<string, IFeed>
feeds: IFeed[]
onDeleteFeed?: (feedId: string, feedIndex: number) => void
}
Expand Down Expand Up @@ -37,7 +40,7 @@ export class SettingFeedListComponent extends PureComponent<
}
}
public render() {
const { feeds } = this.props
const { feeds, feedsMap } = this.props
return (
<div className="ant-list ant-list-sm ant-list-split ant-list-bordered setting-feed-list">
<Scrollbars
Expand All @@ -46,25 +49,32 @@ export class SettingFeedListComponent extends PureComponent<
autoHeightMax={`calc(${Utils.getClientHightForCalc()} - 332px)`}
onScrollStart={this.handleScrollStart}>
<ul className="ant-list-items setting-feed-items">
{feeds.map((feed, index) => (
<AntdList.Item
className="setting-feed-item"
key={feed._id}
actions={[
<Button
key={feed._id}
size="small"
type="danger"
onClick={() => this.handleDeleteClick(feed._id, index)}>
<FormattedMessage id="delete" />
</Button>,
]}>
<p title={feed.url} className="feed-item-content">
<Avatar shape="square" size={16} src={feed.favicon} />{' '}
{feed.title}
</p>
</AntdList.Item>
))}
{feeds.map((feed, index) => {
const ifeed = feedsMap.get(feed._id)
return (
<AntdList.Item
className="setting-feed-item"
key={feed._id}
actions={[
<Button
key={feed._id}
size="small"
type="danger"
onClick={() => this.handleDeleteClick(feed._id, index)}>
<FormattedMessage id="delete" />
</Button>,
]}>
<p title={feed.url} className="feed-item-content">
<Avatar
shape="square"
size={16}
src={ifeed ? ifeed.favicon : defaultFavicon}
/>{' '}
{feed.title}
</p>
</AntdList.Item>
)
})}
</ul>
</Scrollbars>
{!feeds.length && (
Expand Down
2 changes: 2 additions & 0 deletions src/components/SettingsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export interface ISettingsModalDispatchProps {

export interface ISettingsModalStateProps {
feeds: Immutable.List<IFeed>
feedsMap: Immutable.Map<string, IFeed>
language: string
}

Expand Down Expand Up @@ -120,6 +121,7 @@ export class SettingsModalComponent extends Component<
</p>
<SettingFeedList
feeds={this.state.allFeeds}
feedsMap={this.props.feedsMap}
onDeleteFeed={this.handleDeleteFeed}
/>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/containers/SettingsModal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const mapStateToProps: MapStateToProps<
IReduxState
> = (state: IReduxState) => ({
feeds: state.feeds.list,
feedsMap: state.feeds.map,
language: state.menu.language,
})

Expand Down
16 changes: 7 additions & 9 deletions src/redux/reducers/feeds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,13 @@ function handleSetFeedFavicon(
state: IIFeedsState,
payload: ISetFeedFaviconPayload
) {
return state.update('map', (map: Immutable.Map<string, IFeed>) => {
const feed = map.get(payload.feedId)
if (feed) {
feed.favicon = payload.favicon
return map.set(payload.feedId, feed)
} else {
return map
}
})
return state.update('map', (map: Immutable.Map<string, IFeed>) =>
map.update(payload.feedId, (feed: IFeed) => {
const newFeed = { ...feed }
newFeed.favicon = payload.favicon
return newFeed
})
)
}

function handleAddFeed(state: IIFeedsState, payload: IAddFeedPayload) {
Expand Down
4 changes: 4 additions & 0 deletions src/styles/ArticleView.less
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@
iframe {
max-width: 100%;
}
figure {
max-width: 100%;
overflow-x: scroll;
}
}
}
}

0 comments on commit 19b303e

Please sign in to comment.