Skip to content
This repository has been archived by the owner on Feb 2, 2023. It is now read-only.

Commit

Permalink
Workaround for issue #86 to let Toastify run without the toast
Browse files Browse the repository at this point in the history
  • Loading branch information
aleab committed Aug 10, 2018
1 parent aad1d7e commit d5e4cd7
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
14 changes: 7 additions & 7 deletions Toastify/src/Core/Spotify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public bool IsMinimizedToTray

public Song CurrentSong
{
get { return this._currentSong ?? (this._currentSong = this.Status.Track); }
get { return this._currentSong ?? (this._currentSong = this.Status?.Track); }
private set { this._currentSong = value; }
}

Expand Down Expand Up @@ -143,11 +143,11 @@ public void InitLocalAPI()
};
this.localAPI = new SpotifyLocalAPI(this.localAPIConfig);

this.localAPI.OnTrackChange += this.SpotifyLocalAPI_OnTrackChange;
this.localAPI.OnPlayStateChange += this.SpotifyLocalAPI_OnPlayStateChange;
this.localAPI.OnTrackTimeChange += this.SpotifyLocalAPI_OnTrackTimeChange;
this.localAPI.OnVolumeChange += this.SpotifyLocalAPI_OnVolumeChange;
this.localAPI.ListenForEvents = true;
//this.localAPI.OnTrackChange += this.SpotifyLocalAPI_OnTrackChange;
//this.localAPI.OnPlayStateChange += this.SpotifyLocalAPI_OnPlayStateChange;
//this.localAPI.OnTrackTimeChange += this.SpotifyLocalAPI_OnTrackTimeChange;
//this.localAPI.OnVolumeChange += this.SpotifyLocalAPI_OnVolumeChange;
//this.localAPI.ListenForEvents = true;
}

public void StartSpotify()
Expand Down Expand Up @@ -183,7 +183,7 @@ private void StartSpotify_WorkerTask(object sender, DoWorkEventArgs e)
this.spotifyProcess.EnableRaisingEvents = true;
this.spotifyProcess.Exited += this.Spotify_Exited;

this.ConnectWithSpotify(e);
//this.ConnectWithSpotify(e);
}

private void StartSpotify_WorkerTaskCompleted(object sender, RunWorkerCompletedEventArgs e)
Expand Down
2 changes: 1 addition & 1 deletion Toastify/src/Events/SpotifyStateEventArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public SpotifyStateEventArgs(Song currentSong, bool playing, double trackTime, d
this.Volume = volume;
}

public SpotifyStateEventArgs(StatusResponse spotifyStatus) : this(spotifyStatus.Track, spotifyStatus.Playing, spotifyStatus.PlayingPosition, spotifyStatus.Volume)
public SpotifyStateEventArgs(StatusResponse spotifyStatus) : this(spotifyStatus?.Track, spotifyStatus?.Playing ?? false, spotifyStatus?.PlayingPosition ?? -1, spotifyStatus?.Volume ?? -1)
{
}
}
Expand Down
4 changes: 4 additions & 0 deletions Toastify/src/Model/HotKey.cs
Original file line number Diff line number Diff line change
Expand Up @@ -530,6 +530,10 @@ private static void HotkeyActionCallback([NotNull] Hotkey hotkey)
hotkey.LastPressTime = DateTime.Now;
LastHotkey = hotkey;

// TODO: TEMPORARY FIX: Never show the toast on demand!
if (hotkey.Action == ToastifyAction.ShowToast)
return;

if (logger.IsDebugEnabled)
logger.Debug($"HotkeyActionCallback: {hotkey.Action}");

Expand Down
2 changes: 1 addition & 1 deletion Toastify/src/View/SettingsView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@
</Grid>
</Grid>
</TabItem>
<TabItem Header="Toast" Name="TabToast">
<TabItem Header="Toast" Name="TabToast" Visibility="Collapsed">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<CheckBox Height="21" IsChecked="{Binding Path=Settings.DisableToast, Mode=TwoWay, Converter={StaticResource SettingValueToValueConverter}}" HorizontalAlignment="Left" Margin="12,10,0,0" VerticalAlignment="Top" VerticalContentAlignment="Center">Disable Toast</CheckBox>

Expand Down
2 changes: 1 addition & 1 deletion Toastify/src/View/ToastView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1087,7 +1087,7 @@ private void Spotify_TrackTimeChanged(object sender, SpotifyTrackTimeChangedEven
private void SettingsView_Launched(object sender, SettingsViewLaunchedEventArgs e)
{
this.Settings = e.Settings;
this.ShowToastPreview(true);
//this.ShowToastPreview(true);
}

private void SettingsView_Closed(object sender, EventArgs e)
Expand Down

0 comments on commit d5e4cd7

Please sign in to comment.