Skip to content
This repository has been archived by the owner on Nov 22, 2021. It is now read-only.

Add repost button to touchbar #147

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/dock-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ module.exports = function dockMenu(soundcloud) {
soundcloud.likeUnlike()
}
},
{
label: 'Repost',
click() {
soundcloud.repost()
}
},
{
label: 'Next',
click() {
Expand Down
4 changes: 4 additions & 0 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ app.on('ready', () => {
soundcloud.likeUnlike()
})

menu.events.on('repost', () => {
soundcloud.repost()
})

menu.events.on('nextTrack', () => {
soundcloud.nextTrack()
})
Expand Down
7 changes: 7 additions & 0 deletions app/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,13 @@ function buildMenu(options) {
events.emit('likeUnlike')
}
},
{
label: 'Repost',
accelerator: 'R',
click() {
events.emit('repost')
}
},
{
label: 'Next',
accelerator: 'Shift+Right',
Expand Down
Binary file modified app/res/like.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/liked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/res/next.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/res/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/res/play.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified app/res/previous.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/repost.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/res/reposted.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions app/soundcloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ module.exports = class SoundCloud extends Events {
this.trigger('L')
}

repost() {
this.trigger('R')
}

nextTrack() {
this.trigger('J')
}
Expand Down
10 changes: 9 additions & 1 deletion app/touch-bar-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const { TouchBar } = require('electron')

const { TouchBarButton, TouchBarLabel, TouchBarSpacer } = TouchBar
const MAX_TITLE_LENGTH = 38
const MAX_TITLE_LENGTH = 39
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With one more button on the TouchBar I would expect the title length to become shorter not longer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@salomvary I recreated the icons using the exact assets from Soundcloud. They are actually in SVG which you seemed to want earlier. Perhaps that would help.

I tested the title length and 39 is actually the maximum, the increase buttons seemed to have no effect. It seems although the 39 char length has more to do with the electron implementation (a bug possibly?)


module.exports = function touchBarMenu(window, soundcloud) {
const nextTrack = new TouchBarButton({
Expand Down Expand Up @@ -34,6 +34,13 @@ module.exports = function touchBarMenu(window, soundcloud) {
}
})

const repost = new TouchBarButton({
icon: `${__dirname}/res/repost.png`,
click: () => {
soundcloud.repost()
}
})

const trackInfo = new TouchBarLabel()

soundcloud.on('play', ({ title, subtitle }) => {
Expand All @@ -50,6 +57,7 @@ module.exports = function touchBarMenu(window, soundcloud) {
playPause,
nextTrack,
likeUnlike,
repost,
new TouchBarSpacer({ size: 'flexible' }),
trackInfo,
new TouchBarSpacer({ size: 'flexible' })
Expand Down