fix group menu indexing

This commit is contained in:
刘浩远 2020-08-08 17:48:14 +08:00
parent 79d5a5861e
commit 7deb250bcc
5 changed files with 9 additions and 9 deletions

View File

@ -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) => {

View File

@ -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 {

View File

@ -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()
}

View File

@ -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)))
}

View File

@ -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"