From 440e26f4b089cac612c4553c7c0463605cdc3db3 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Mon, 23 Jan 2023 23:15:38 +0000 Subject: [PATCH] added `sync` settings --- .../sync/components/spotifySync/index.jsx | 62 ++++++++++++ .../sync/components/spotifySync/index.less | 52 ++++++++++ .../app/constants/settings/sync/index.jsx | 94 +++++++++++++++++++ 3 files changed, 208 insertions(+) create mode 100644 packages/app/constants/settings/sync/components/spotifySync/index.jsx create mode 100644 packages/app/constants/settings/sync/components/spotifySync/index.less create mode 100644 packages/app/constants/settings/sync/index.jsx diff --git a/packages/app/constants/settings/sync/components/spotifySync/index.jsx b/packages/app/constants/settings/sync/components/spotifySync/index.jsx new file mode 100644 index 00000000..e97b369c --- /dev/null +++ b/packages/app/constants/settings/sync/components/spotifySync/index.jsx @@ -0,0 +1,62 @@ +import React from "react" + +import { Button, Spin, Avatar, Modal } from "antd" +import { Icons } from "components/Icons" + +import SyncModel from "models/sync" + +import "./index.less" + +export default (props) => { + const onLogout = async () => { + Modal.confirm({ + title: "Are you sure you want to logout?", + content: "You will be logged out of your Spotify account", + okText: "Logout", + okType: "danger", + cancelText: "Cancel", + onOk: async () => { + await SyncModel.spotifyCore.unlinkAccount() + .then(() => { + app.message.success("Successfully logged out of Spotify") + }) + .catch((err) => { + console.error(err) + app.message.error("Failed to logout of Spotify") + }) + } + }) + } + + if (props.ctx.spotifyAccount) { + return
+
+ Spotify account avatar +

+ { + props.ctx.spotifyAccount.display_name + } +

+
+ +
+ +
+
+ } + + return +} \ No newline at end of file diff --git a/packages/app/constants/settings/sync/components/spotifySync/index.less b/packages/app/constants/settings/sync/components/spotifySync/index.less new file mode 100644 index 00000000..7fc1a7b5 --- /dev/null +++ b/packages/app/constants/settings/sync/components/spotifySync/index.less @@ -0,0 +1,52 @@ +.spotifyAccount { + display: flex; + flex-direction: row; + + align-items: center; + justify-content: space-between; + + background-color: var(--background-color-primary); + + padding: 10px; + + border-radius: 12px; + + .spotifyAccount_info { + display: flex; + flex-direction: row; + + align-items: center; + + img { + width: 40px; + height: 40px; + + object-fit: cover; + + border-radius: 12px; + + margin-right: 10px; + } + + p { + font-size: 16px; + font-weight: 500; + line-height: 1.5; + margin: 0; + } + } + + .spotifyAccount_actions { + display: flex; + + align-items: center; + + .ant-btn { + margin-left: 10px; + + &:first-child { + margin-left: 0; + } + } + } +} \ No newline at end of file diff --git a/packages/app/constants/settings/sync/index.jsx b/packages/app/constants/settings/sync/index.jsx new file mode 100644 index 00000000..a71cb0bf --- /dev/null +++ b/packages/app/constants/settings/sync/index.jsx @@ -0,0 +1,94 @@ +import React from "react" +import loadable from "@loadable/component" +import SyncModel from "models/sync" + +// TODO: Make logout button require a valid session to be not disabled + +export default { + icon: "MdSync", + label: "Sync", + ctxData: async () => { + const spotifyAccount = await SyncModel.spotifyCore.getData().catch((err) => { + return null + }) + + return { + spotifyAccount + } + }, + settings: [ + { + id: "sync_settings", + icon: "MdSync", + title: "Sync Settings", + description: "Sync your settings across all devices stored in the cloud", + group: "sync.settings", + component: "Switch" + }, + { + id: "spotify", + icon: "SiSpotify", + title: "Spotify", + description: "Sync your Spotify account to get access to Spaces, playlists and more", + group: "sync.accounts", + component: loadable(() => import("./components/spotifySync")), + storaged: false + }, + { + id: "soundcloud", + icon: "SiSoundcloud", + title: "SoundCloud", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + }, + { + id: "youtube", + icon: "SiYoutube", + title: "YouTube", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + }, + { + id: "twitch", + icon: "SiTwitch", + title: "Twitch", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + }, + { + id: "twitter", + icon: "SiTwitter", + title: "Twitter", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + }, + { + id: "instagram", + icon: "SiInstagram", + title: "Instagram", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + }, + { + id: "mixcloud", + icon: "SiMixcloud", + title: "Mixcloud", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + }, + { + id: "discord", + icon: "SiDiscord", + title: "Discord", + group: "sync.accounts", + component: () =>

Not implemented

, + storaged: false + } + ] +} \ No newline at end of file