-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove Sonos support (not needed anymore)
- Loading branch information
Showing
8 changed files
with
66 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.kubukoz.next | ||
|
||
import cats.implicits._ | ||
import com.kubukoz.next.util.Config | ||
import cats.Monad | ||
|
||
trait LoginProcess[F[_]] { | ||
def login: F[Unit] | ||
def refreshUserToken(refreshToken: Config.RefreshToken): F[Unit] | ||
} | ||
|
||
object LoginProcess { | ||
def apply[F[_]](implicit F: LoginProcess[F]): LoginProcess[F] = F | ||
|
||
def instance[F[_]: UserOutput: Login: ConfigLoader: Monad]: LoginProcess[F] = new LoginProcess[F] { | ||
|
||
def login: F[Unit] = for { | ||
tokens <- Login[F].server | ||
config <- ConfigLoader[F].loadConfig | ||
newConfig = config.copy(token = tokens.access.some, refreshToken = tokens.refresh.some) | ||
_ <- ConfigLoader[F].saveConfig(newConfig) | ||
_ <- UserOutput[F].print(UserMessage.SavedToken) | ||
} yield () | ||
|
||
def refreshUserToken(refreshToken: Config.RefreshToken): F[Unit] = for { | ||
newToken <- Login[F].refreshToken(refreshToken) | ||
config <- ConfigLoader[F].loadConfig | ||
newConfig = config.copy(token = newToken.some) | ||
_ <- ConfigLoader[F].saveConfig(newConfig) | ||
_ <- UserOutput[F].print(UserMessage.RefreshedToken) | ||
} yield () | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.kubukoz.next | ||
|
||
trait Runner[F[_]] { | ||
def run(choice: Choice): F[Unit] | ||
} | ||
|
||
object Runner { | ||
def apply[F[_]](implicit F: Runner[F]): Runner[F] = F | ||
|
||
def instance[F[_]: Spotify: LoginProcess]: Runner[F] = { | ||
case Choice.Login => LoginProcess[F].login | ||
case Choice.SkipTrack => Spotify[F].skipTrack | ||
case Choice.DropTrack => Spotify[F].dropTrack | ||
case Choice.FastForward(p) => Spotify[F].fastForward(p) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.