Skip to content

Commit

Permalink
If icon is unknown, use default icon
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaMahany committed Jan 12, 2024
1 parent 6e46249 commit c968e3c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 deletions.
24 changes: 12 additions & 12 deletions ee/desktop/user/menu/menu_icon.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@ func getIcon(icon menuIcon) []byte {
assets.MenubarTranslucentMonochromeIco,
assets.MenubarTranslucentMonochromePng,
)
case DefaultIcon:
return chooseIcon(
assets.MenubarDefaultDarkmodeIco,
assets.MenubarDefaultDarkmodePng,
assets.MenubarDefaultLightmodeIco,
assets.MenubarDefaultLightmodePng,
assets.MenubarDefaultLightmodeShadowIco,
assets.MenubarDefaultLightmodeShadowPng,
assets.MenubarDefaultMonochromeIco,
assets.MenubarDefaultMonochromePng,
)
case TriangleExclamationIcon:
return chooseIcon(
assets.MenubarTriangleExclamationDarkmodeIco,
Expand All @@ -53,8 +42,19 @@ func getIcon(icon menuIcon) []byte {
assets.MenubarCircleXMonochromeIco,
assets.MenubarCircleXMonochromePng,
)
case DefaultIcon:
fallthrough
default:
return nil
return chooseIcon(
assets.MenubarDefaultDarkmodeIco,
assets.MenubarDefaultDarkmodePng,
assets.MenubarDefaultLightmodeIco,
assets.MenubarDefaultLightmodePng,
assets.MenubarDefaultLightmodeShadowIco,
assets.MenubarDefaultLightmodeShadowPng,
assets.MenubarDefaultMonochromeIco,
assets.MenubarDefaultMonochromePng,
)
}
}

Expand Down
16 changes: 5 additions & 11 deletions ee/desktop/user/menu/menu_icon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ func Test_getIcon(t *testing.T) {
t.Parallel()

tests := []struct {
name string
icon menuIcon
expectedErr bool
name string
icon menuIcon
}{
{
name: "invalid",
icon: "invalid",
expectedErr: true,
name: "invalid",
icon: "invalid",
},
{
name: "Translucent",
Expand All @@ -42,11 +40,7 @@ func Test_getIcon(t *testing.T) {
t.Parallel()

icon := getIcon(tt.icon)
if tt.expectedErr {
assert.Nil(t, icon)
} else {
assert.NotNil(t, icon)
}
assert.NotNil(t, icon)
})
}
}

0 comments on commit c968e3c

Please sign in to comment.