Skip to content

Commit

Permalink
Not spamming same message on toastr and stop current song error.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilioastarita committed Dec 28, 2016
1 parent b220e43 commit af62ec5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
13 changes: 13 additions & 0 deletions render/LyricfierRender.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,21 @@ class LyricfierRender {
protected currentView;
protected liveReload = false;
protected settings: SettingsValues;
protected lastMessageTime = 0;
protected lastMessage = '';

listenStatus(msg) {
if (msg === this.lastMessage) {
// not spamming same message.
const now = new Date();
const last = new Date(this.lastMessageTime);
last.setMilliseconds(last.getMilliseconds() + 4500);
if (now < last) {
return;
}
}
this.lastMessageTime = (new Date()).getTime();
this.lastMessage = msg;
toastr.info(msg);
}

Expand Down
7 changes: 6 additions & 1 deletion render/SpotifyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,12 @@ export class SpotifyService {

public getCurrentSong(cb) {
this.getStatus((err, status)=> {
if (err) return cb(err);
if (err) {
this.foundPort = false;
this.csrfToken = null;
this.oAuthToken.t = null;
return cb(err);
}
console.log('getStatus', status);
if (status.track && status.track.track_resource) {

Expand Down
2 changes: 1 addition & 1 deletion render/views/Song.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ <h1>lyricfier</h1>
<div class="not-playing-view">
<img src="../img/waves.svg" alt="Waveform">
<h3>Looking for a Song on Spotify</h3>
<p>Is Spotify running?</p>
<p>Connecting...</p>
<a href="#" @click.prevent="refresh" class="button">Try Again</a>
</div>
</div>
Expand Down

0 comments on commit af62ec5

Please sign in to comment.