diff --git a/music-time-2.2.4.vsix b/music-time-2.2.4.vsix new file mode 100644 index 0000000..7e7aa87 Binary files /dev/null and b/music-time-2.2.4.vsix differ diff --git a/package.json b/package.json index bb025fa..b6da24c 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "music-time", "displayName": "Music Time for Spotify", - "version": "2.2.36", + "version": "2.2.4", "publisher": "softwaredotcom", "description": "Music Time for Spotify is a VS Code extension that discovers the most productive music to listen to as you code.", "author": { diff --git a/src/app/views/components/slack_workspaces.tsx b/src/app/views/components/slack_workspaces.tsx index dfb1dd4..72027de 100644 --- a/src/app/views/components/slack_workspaces.tsx +++ b/src/app/views/components/slack_workspaces.tsx @@ -130,6 +130,7 @@ export default function SlackWorkspaces(props) { {props.stateData.slackWorkspaces.map((workspace, index) => { + const team_name = workspace.meta ? JSON.parse(workspace.meta).team.name : workspace.team_name return ( @@ -137,8 +138,7 @@ export default function SlackWorkspaces(props) { diff --git a/src/command-helper.ts b/src/command-helper.ts index 108b758..3e4085f 100644 --- a/src/command-helper.ts +++ b/src/command-helper.ts @@ -3,7 +3,6 @@ import { MusicControlManager } from "./music/MusicControlManager"; import { launchMusicAnalytics, launchWebUrl } from "./Util"; import { PlaylistItem, PlayerName, PlayerDevice, playSpotifyDevice } from "cody-music"; import { SocialShareManager } from "./social/SocialShareManager"; -import { connectSlackWorkspace, disconnectSlack, disconnectSlackAuth } from "./managers/SlackManager"; import { showGenreSelections, showMoodSelections } from "./selector/RecTypeSelectorManager"; import { showSortPlaylistMenu } from "./selector/SortPlaylistSelectorManager"; import { showDeviceSelectorMenu } from "./selector/SpotifyDeviceSelectorManager"; @@ -34,7 +33,7 @@ import { updateSort, } from "./managers/PlaylistDataManager"; import { launchTrackPlayer, playSelectedItem, playSelectedItems } from "./managers/PlaylistControlManager"; -import { vscode_mt_issues_url } from "./Constants"; +import { app_endpoint, vscode_mt_issues_url } from "./Constants"; import { displayReadmeIfNotExists } from './DataController'; /** @@ -232,7 +231,13 @@ export function createCommands( // CONNECT SLACK cmds.push( commands.registerCommand("musictime.connectSlack", () => { - connectSlackWorkspace(); + launchWebUrl(`${app_endpoint}/data_sources/integration_types/slack`); + }) + ); + + cmds.push( + commands.registerCommand("musictime.connectSlackWorkspace", () => { + launchWebUrl(`${app_endpoint}/data_sources/integration_types/slack`); }) ); @@ -246,11 +251,7 @@ export function createCommands( // DISCONNECT SLACK cmds.push( commands.registerCommand("musictime.disconnectSlack", (item: any) => { - if (!item) { - disconnectSlack(); - } else { - disconnectSlackAuth(item.value); - } + launchWebUrl(`${app_endpoint}/data_sources/integration_types/slack`); }) ); diff --git a/src/managers/SlackManager.ts b/src/managers/SlackManager.ts index 84890ce..4a9222c 100644 --- a/src/managers/SlackManager.ts +++ b/src/managers/SlackManager.ts @@ -66,14 +66,15 @@ export async function disconnectSlack() { // disconnect slack flow export async function disconnectSlackAuth(authId) { // get the domain - const integration = (await getSlackWorkspaces()).find((n) => n.authId === authId); + const integration = (await getSlackWorkspaces()).find((n) => n.auth_id === authId || n.authId === authId); if (!integration) { window.showErrorMessage("Unable to find selected integration to disconnect"); return; } + const team_name = integration.meta ? JSON.parse(integration.meta).team.name : integration.team_name // ask before disconnecting const selection = await window.showInformationMessage( - `Are you sure you would like to disconnect the '${integration.team_domain}' Slack workspace?`, + `Are you sure you would like to disconnect the '${team_name}' Slack workspace?`, ...[DISCONNECT_LABEL] ); @@ -223,7 +224,11 @@ async function getWorkspaceAccessToken(team_domain) { async function showSlackWorkspacesToDisconnect() { const workspaces = await getSlackWorkspaces(); const items = workspaces.map((n) => { - return { label: n.team_domain, value: n.authId }; + if (n.meta) { + return { label: JSON.parse(n.meta).team.name, value: n.auth_id }; + } else { + return { label: n.team_domain, value: n.authId }; + } }); items.push({ label: "all", value: "all" }); let menuOptions = { diff --git a/src/managers/SpotifyManager.ts b/src/managers/SpotifyManager.ts index e9058b2..2e7f090 100644 --- a/src/managers/SpotifyManager.ts +++ b/src/managers/SpotifyManager.ts @@ -22,7 +22,10 @@ export function updateAddedNewIntegration(val: boolean) { addedNewIntegration = val; } -export function getConnectedSpotifyUser() { +export async function getConnectedSpotifyUser() { + if (!spotifyUser || !spotifyUser.id) { + spotifyUser = await getUserProfile(); + } return spotifyUser; } diff --git a/src/model/SoftwareIntegration.ts b/src/model/SoftwareIntegration.ts index 135ec46..660433d 100644 --- a/src/model/SoftwareIntegration.ts +++ b/src/model/SoftwareIntegration.ts @@ -4,6 +4,7 @@ export default class SoftwareIntegration { public value: string; // i.e. public status: string; // i.e. ACTIVE public authId: string; + public auth_id: string; public access_token: string; public refresh_token: string; public pluginId: number; @@ -12,4 +13,5 @@ export default class SoftwareIntegration { public integration_id: string; public plugin_uuid: string; public scopes: string[] = []; -} \ No newline at end of file + public team: any; +} diff --git a/src/sidebar/ReactData.ts b/src/sidebar/ReactData.ts index 5a4ccc1..95e2cb6 100644 --- a/src/sidebar/ReactData.ts +++ b/src/sidebar/ReactData.ts @@ -24,7 +24,7 @@ import { isCodeTimeTimeInstalled } from "../Util"; export async function getReactData(tab_view = undefined, playlist_id = undefined, loading = false) { const name = getItem("name"); const authType = getItem("authType"); - const spotifyUser = getConnectedSpotifyUser(); + const spotifyUser = await getConnectedSpotifyUser(); const selectedTabView = tab_view ? tab_view : getSelectedTabView(); const metricsTypeSelected = getUserMetricsSelected(); @@ -90,8 +90,8 @@ export async function getReactData(tab_view = undefined, playlist_id = undefined spotifyPlayerContext, currentlyRunningTrack, deviceMenuInfo, + spotifyUser, likedSongsPlaylist: getSpotifyLikedPlaylist(), - spotifyUser: getConnectedSpotifyUser(), slackConnected: !!(await hasSlackWorkspaces()), slackWorkspaces: await getSlackWorkspaces(), currentColorKind: getCurrentColorKind(),