mirror of
https://github.com/yang991178/fluent-reader.git
synced 2025-04-24 23:18:46 +02:00
fix group menu indexing
This commit is contained in:
parent
79d5a5861e
commit
7deb250bcc
@ -50,16 +50,16 @@ export class Menu extends React.Component<MenuProps> {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: intl.get("menu.subscriptions"),
|
name: intl.get("menu.subscriptions"),
|
||||||
links: this.props.groups.filter(g => g.sids.length > 0).map((g, i) => {
|
links: this.props.groups.filter(g => g.sids.length > 0).map(g => {
|
||||||
if (g.isMultiple) {
|
if (g.isMultiple) {
|
||||||
let sources = g.sids.map(sid => this.props.sources[sid])
|
let sources = g.sids.map(sid => this.props.sources[sid])
|
||||||
return {
|
return {
|
||||||
name: g.name,
|
name: g.name,
|
||||||
ariaLabel: this.countOverflow(sources.map(s => s.unreadCount).reduce((a, b) => a + b, 0)),
|
ariaLabel: this.countOverflow(sources.map(s => s.unreadCount).reduce((a, b) => a + b, 0)),
|
||||||
key: "g-" + i,
|
key: "g-" + g.index,
|
||||||
url: null,
|
url: null,
|
||||||
isExpanded: g.expanded,
|
isExpanded: g.expanded,
|
||||||
onClick: () => this.props.selectSourceGroup(g, "g-" + i),
|
onClick: () => this.props.selectSourceGroup(g, "g-" + g.index),
|
||||||
links: sources.map(this.getSource)
|
links: sources.map(this.getSource)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -24,7 +24,7 @@ class Settings extends React.Component<SettingsProps> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
componentDidUpdate = (prevProps: SettingsProps) => {
|
componentDidUpdate = (prevProps: SettingsProps) => {
|
||||||
if (this.props.display !== prevProps.display) {
|
if (window.utils.platform === "darwin" && this.props.display !== prevProps.display) {
|
||||||
if (this.props.display) window.utils.destroyTouchBar()
|
if (this.props.display) window.utils.destroyTouchBar()
|
||||||
else initTouchBarWithTexts()
|
else initTouchBarWithTexts()
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ const mapStateToProps = createSelector(
|
|||||||
display: app.menu,
|
display: app.menu,
|
||||||
selected: app.menuKey,
|
selected: app.menuKey,
|
||||||
sources: sources,
|
sources: sources,
|
||||||
groups: groups,
|
groups: groups.map((g, i) => ({ ...g, index: i })),
|
||||||
searchOn: searchOn,
|
searchOn: searchOn,
|
||||||
itemOn: itemOn,
|
itemOn: itemOn,
|
||||||
})
|
})
|
||||||
@ -47,7 +47,7 @@ const mapDispatchToProps = dispatch => ({
|
|||||||
dispatch(openGroupMenu(sids, event))
|
dispatch(openGroupMenu(sids, event))
|
||||||
},
|
},
|
||||||
updateGroupExpansion: (event: React.MouseEvent<HTMLElement>, key: string, selected: string) => {
|
updateGroupExpansion: (event: React.MouseEvent<HTMLElement>, key: string, selected: string) => {
|
||||||
if ((event.target as HTMLElement).tagName !== "DIV" || key === selected) {
|
if ((event.target as HTMLElement).tagName === "I" || key === selected) {
|
||||||
let [type, index] = key.split("-")
|
let [type, index] = key.split("-")
|
||||||
if (type === "g") dispatch(toggleGroupExpansion(parseInt(index)))
|
if (type === "g") dispatch(toggleGroupExpansion(parseInt(index)))
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ export class SourceGroup {
|
|||||||
sids: number[]
|
sids: number[]
|
||||||
name?: string
|
name?: string
|
||||||
expanded?: boolean
|
expanded?: boolean
|
||||||
index?: number // available only from groups tab container
|
index?: number // available only from menu or groups tab container
|
||||||
|
|
||||||
constructor(sids: number[], name: string = null) {
|
constructor(sids: number[], name: string = null) {
|
||||||
name = (name && name.trim()) || "Source group"
|
name = (name && name.trim()) || "Source group"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user