Skip to content
This repository was archived by the owner on Jul 6, 2020. It is now read-only.

Commit d5e8d60

Browse files
committed
Fix recently played links restored from file
Make links actually work
1 parent 5878562 commit d5e8d60

File tree

1 file changed

+22
-6
lines changed

1 file changed

+22
-6
lines changed

src/toby.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,23 @@ var Toby = (function() {
125125
}
126126
});
127127
}
128+
129+
// Fix up the recently played so that we can click the link and have it
130+
// play.
131+
this.state.recentlyPlayedData = _.forEach(this.state.recentlyPlayedData, function(v) {
132+
v.playVideo = function() {
133+
this.setState({
134+
currentVideoSrc: v.url,
135+
webviewStyle: {
136+
visibility: "visible"
137+
},
138+
searchListStyle: {
139+
display: "none"
140+
}
141+
});
142+
}.bind(this);
143+
}.bind(this));
144+
128145
},
129146
addToRecentlyPlayedList: function(video) {
130147
var found = _.find(this.state.recentlyPlayedData, function(v) {
@@ -134,8 +151,8 @@ var Toby = (function() {
134151
});
135152

136153
if (found === undefined) {
154+
// Might want to make this configurable in the future
137155
this.state.recentlyPlayedData = _.take(this.state.recentlyPlayedData, 25);
138-
139156
this.state.recentlyPlayedData.push({
140157
"description": video.description,
141158
"url": video.url,
@@ -152,10 +169,6 @@ var Toby = (function() {
152169
});
153170
}.bind(this)
154171
});
155-
156-
fs.writeFile(recentlyPlayedPath, JSON.stringify(this.state.recentlyPlayedData, undefined, 2), function(err) {
157-
if (err) throw err;
158-
});
159172
}
160173
},
161174
handleSearch: function(e) {
@@ -371,8 +384,11 @@ var Toby = (function() {
371384

372385
if(recentlyPlayedVideo !== undefined) {
373386
recentlyPlayedVideo.description = newTitle;
374-
}
375387

388+
fs.writeFile(recentlyPlayedPath, JSON.stringify(this.state.recentlyPlayedData, undefined, 2), function(err) {
389+
if (err) throw err;
390+
});
391+
}
376392
},
377393
render: function() {
378394
var bindClick = this.handleClick.bind(this);

0 commit comments

Comments
 (0)