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
@ -113,7 +113,7 @@ const utilsBridge = {
|
||||
addTouchBarEventsListener: (callback: (IObjectWithKey) => any) => {
|
||||
ipcRenderer.removeAllListeners("touchbar-event")
|
||||
ipcRenderer.on("touchbar-event", (_, key: string) => {
|
||||
callback({ key: key} )
|
||||
callback({ key: key } )
|
||||
})
|
||||
},
|
||||
initTouchBar: (texts: TouchBarTexts) => {
|
||||
|
@ -50,16 +50,16 @@ export class Menu extends React.Component<MenuProps> {
|
||||
},
|
||||
{
|
||||
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) {
|
||||
let sources = g.sids.map(sid => this.props.sources[sid])
|
||||
return {
|
||||
name: g.name,
|
||||
ariaLabel: this.countOverflow(sources.map(s => s.unreadCount).reduce((a, b) => a + b, 0)),
|
||||
key: "g-" + i,
|
||||
key: "g-" + g.index,
|
||||
url: null,
|
||||
isExpanded: g.expanded,
|
||||
onClick: () => this.props.selectSourceGroup(g, "g-" + i),
|
||||
onClick: () => this.props.selectSourceGroup(g, "g-" + g.index),
|
||||
links: sources.map(this.getSource)
|
||||
}
|
||||
} else {
|
||||
|
@ -23,8 +23,8 @@ class Settings extends React.Component<SettingsProps> {
|
||||
super(props)
|
||||
}
|
||||
|
||||
componentDidUpdate= (prevProps: SettingsProps) => {
|
||||
if (this.props.display !== prevProps.display) {
|
||||
componentDidUpdate = (prevProps: SettingsProps) => {
|
||||
if (window.utils.platform === "darwin" && this.props.display !== prevProps.display) {
|
||||
if (this.props.display) window.utils.destroyTouchBar()
|
||||
else initTouchBarWithTexts()
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ const mapStateToProps = createSelector(
|
||||
display: app.menu,
|
||||
selected: app.menuKey,
|
||||
sources: sources,
|
||||
groups: groups,
|
||||
groups: groups.map((g, i) => ({ ...g, index: i })),
|
||||
searchOn: searchOn,
|
||||
itemOn: itemOn,
|
||||
})
|
||||
@ -47,7 +47,7 @@ const mapDispatchToProps = dispatch => ({
|
||||
dispatch(openGroupMenu(sids, event))
|
||||
},
|
||||
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("-")
|
||||
if (type === "g") dispatch(toggleGroupExpansion(parseInt(index)))
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ export class SourceGroup {
|
||||
sids: number[]
|
||||
name?: string
|
||||
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) {
|
||||
name = (name && name.trim()) || "Source group"
|
||||
|
Loading…
x
Reference in New Issue
Block a user