Merge lp:~nik90/cliffhanger/add-watchlist-feature into lp:~flashback-dev/cliffhanger/trunk

Proposed by Nekhelesh Ramananthan
Status: Merged
Merged at revision: 30
Proposed branch: lp:~nik90/cliffhanger/add-watchlist-feature
Merge into: lp:~flashback-dev/cliffhanger/trunk
Diff against target: 410 lines (+163/-4)
13 files modified
Flashback.qml (+9/-0)
backend/backend.js (+8/-0)
components/TraktPopup.qml (+18/-0)
models/AiringShows.qml (+2/-0)
models/Show.qml (+2/-0)
models/TraktUserWatchlist.qml (+9/-0)
models/TraktWatchlist.qml (+15/-0)
ui/EpisodePage.qml (+1/-0)
ui/HomeTab.qml (+17/-3)
ui/MoviePage.qml (+36/-0)
ui/SeasonPage.qml (+1/-0)
ui/TvPage.qml (+38/-1)
ui/TvTab.qml (+7/-0)
To merge this branch: bzr merge lp:~nik90/cliffhanger/add-watchlist-feature
Reviewer Review Type Date Requested Status
Flashback Dev Pending
Review via email: mp+202374@code.launchpad.net

Commit message

Added user watchlist feature

Description of the change

Added user watchlist feature

To post a comment you must log in.
34. By Nekhelesh Ramananthan

Small fixes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Flashback.qml'
2--- Flashback.qml 2014-01-03 14:01:43 +0000
3+++ Flashback.qml 2014-01-20 22:13:50 +0000
4@@ -117,6 +117,15 @@
5 }
6 }
7
8+ // Document to store the user's watchlist activity on Trakt
9+ U1db.Document {
10+ id: watchlistActivityDocument
11+ database: db
12+ docId: "traktWatchlistActivity"
13+ create: true
14+ defaults: { "movie": "default", "show": "default" }
15+ }
16+
17 Loader { id: userActivityLoader }
18
19 Component {
20
21=== modified file 'backend/backend.js'
22--- backend/backend.js 2014-01-19 23:00:52 +0000
23+++ backend/backend.js 2014-01-20 22:13:50 +0000
24@@ -169,6 +169,14 @@
25 return credentials.trakt_baseUrl + "/user/calendar/shows.json/" + credentials.trakt_apiKey + "/" + username + "/" + startDate + "/" + noOfDays
26 }
27
28+function traktWatchlistUrl(type) {
29+ return credentials.trakt_baseUrl + "/" + type + "/watchlist/" + credentials.trakt_apiKey
30+}
31+
32+function traktUnwatchlistUrl(type) {
33+ return credentials.trakt_baseUrl + "/" + type + "/unwatchlist/" + credentials.trakt_apiKey
34+}
35+
36 function userWatchlistMovies(username) {
37 return credentials.trakt_baseUrl + "/user/watchlist/movies.json/" + credentials.trakt_apiKey + "/" + username
38 }
39
40=== modified file 'components/TraktPopup.qml'
41--- components/TraktPopup.qml 2013-12-28 18:30:08 +0000
42+++ components/TraktPopup.qml 2014-01-20 22:13:50 +0000
43@@ -15,10 +15,14 @@
44 // Property to set the seen message
45 property alias seenMessage: _seenAction.text
46
47+ // Property to set the watchlist message
48+ property alias watchlistMessage: _watchlistAction.text
49+
50 // Properties to set the visibility of the individual actions
51 property bool showConfigureAction: traktLogin.contents.status === "disabled"
52 property bool showCheckInAction: traktLogin.contents.status !== "disabled"
53 property bool showSeenAction: traktLogin.contents.status !== "disabled"
54+ property bool showWatchlistAction: traktLogin.contents.status !== "disabled"
55 property bool showCommentAction: true
56
57 // Signal triggered when the checked-in action is triggered
58@@ -30,6 +34,9 @@
59 // Signal triggered when the comments action is triggered
60 signal commented()
61
62+ // Signal triggered when the watchlist action is triggered
63+ signal watchlisted()
64+
65 Column {
66 id: containerLayout
67 anchors {
68@@ -61,6 +68,17 @@
69 }
70
71 Standard {
72+ id: _watchlistAction
73+ visible: showWatchlistAction
74+ iconSource: Qt.resolvedUrl("../graphics/watchlist_black.png")
75+ iconFrame: false
76+ onClicked: {
77+ popover.watchlisted()
78+ PopupUtils.close(popover)
79+ }
80+ }
81+
82+ Standard {
83 id: _seenAction
84 visible: showSeenAction
85 iconSource: Qt.resolvedUrl("../graphics/watched_black.png")
86
87=== added file 'graphics/watchlist_black.png'
88Binary files graphics/watchlist_black.png 1970-01-01 00:00:00 +0000 and graphics/watchlist_black.png 2014-01-20 22:13:50 +0000 differ
89=== modified file 'models/AiringShows.qml'
90--- models/AiringShows.qml 2014-01-02 14:31:26 +0000
91+++ models/AiringShows.qml 2014-01-20 22:13:50 +0000
92@@ -4,6 +4,8 @@
93 BasePostModel {
94 id: airingShowsModel
95
96+ property string lastUpdated: "default"
97+
98 function fetchData(username, password, date, days) {
99 source = Backend.userShows(username, date, days)
100 createMessage(username, password)
101
102=== modified file 'models/Show.qml'
103--- models/Show.qml 2013-12-30 15:03:51 +0000
104+++ models/Show.qml 2014-01-20 22:13:50 +0000
105@@ -16,6 +16,7 @@
106 'voteUp': 0,
107 'voteDown': 0,
108 'userVote': 0,
109+ 'in_watchlist': '',
110 'number_of_seasons': 0,
111 'networks': '',
112 'genres': [],
113@@ -38,6 +39,7 @@
114 'voteUp': parseInt(reply.ratings.loved),
115 'voteDown': parseInt(reply.ratings.hated),
116 'userVote': parseInt(reply.rating_advanced),
117+ 'in_watchlist': reply.in_watchlist ? reply.in_watchlist.toString() : "",
118 'in_production': reply.status,
119 'networks': reply.network,
120 'genres': reply.genres,
121
122=== modified file 'models/TraktUserWatchlist.qml'
123--- models/TraktUserWatchlist.qml 2014-01-02 21:25:37 +0000
124+++ models/TraktUserWatchlist.qml 2014-01-20 22:13:50 +0000
125@@ -1,8 +1,17 @@
126 import QtQuick 2.0
127+import "../backend/backend.js" as Backend
128
129 BasePostModel {
130 id: traktUserWatchlist
131
132+ property string lastUpdated: "default"
133+
134+ function fetchData(username, password) {
135+ source = Backend.userWatchlistMovies(username)
136+ createMessage(username, password)
137+ sendMessage()
138+ }
139+
140 function updateJSONModel() {
141 model.clear()
142 for ( var key in reply ) {
143
144=== added file 'models/TraktWatchlist.qml'
145--- models/TraktWatchlist.qml 1970-01-01 00:00:00 +0000
146+++ models/TraktWatchlist.qml 2014-01-20 22:13:50 +0000
147@@ -0,0 +1,15 @@
148+import QtQuick 2.0
149+
150+BasePostModel {
151+ id: traktWatchlist
152+
153+ // Function to create a JSON String with movie information
154+ function createMovieMessage(username, password, imdb_id, title, year) {
155+ message = JSON.stringify({username: username, password: password, movies: [{imdb_id: imdb_id, title: title, year: year}]})
156+ }
157+
158+ // Function to create a JSON String with tv show information
159+ function createShowMessage(username, password, tvdb_id, title, year) {
160+ message = JSON.stringify({username: username, password: password, shows: [{tvdb_id: tvdb_id, title: title, year: year}]})
161+ }
162+}
163
164=== modified file 'ui/EpisodePage.qml'
165--- ui/EpisodePage.qml 2014-01-04 15:06:19 +0000
166+++ ui/EpisodePage.qml 2014-01-20 22:13:50 +0000
167@@ -127,6 +127,7 @@
168 Component {
169 id: sharePopoverComponent
170 TraktPopup {
171+ showWatchlistAction: false
172 checkInMessage: showActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current episode check-in") : i18n.tr("Check-in episode into Trakt")
173 seenMessage: isEpisodeSeen ? i18n.tr("Mark episode an unseen") : i18n.tr("Mark episode as seen")
174 onCheckedIn: {
175
176=== modified file 'ui/HomeTab.qml'
177--- ui/HomeTab.qml 2014-01-02 21:25:37 +0000
178+++ ui/HomeTab.qml 2014-01-20 22:13:50 +0000
179@@ -8,6 +8,8 @@
180 Page {
181 id: homePage
182
183+ flickable: null
184+
185 Component.onCompleted: console.log("[LOG]: Home Tab Loaded")
186
187 actions: [
188@@ -30,11 +32,16 @@
189 id: userWatchlistModel
190 username: traktLogin.contents.username
191 password: traktLogin.contents.password
192+ lastUpdated: watchlistActivityDocument.contents.movie
193 onPasswordChanged: {
194 console.log("[LOG]: Retrieving user movie watchlist")
195- source = Backend.userWatchlistMovies(username)
196- createMessage(username, password)
197- sendMessage()
198+ fetchData(username, password)
199+ }
200+ onLastUpdatedChanged: {
201+ if(username !== "") {
202+ console.log("[LOG]: Retrieving user movie watchlist")
203+ fetchData(username, password)
204+ }
205 }
206 }
207
208@@ -42,10 +49,17 @@
209 id: airingShowsModel
210 username: traktLogin.contents.username
211 password: traktLogin.contents.password
212+ lastUpdated: watchlistActivityDocument.contents.show
213 onPasswordChanged: {
214 console.log("[LOG]: Retrieving shows airing today")
215 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1)
216 }
217+ onLastUpdatedChanged: {
218+ if(username !== "") {
219+ console.log("[LOG]: Retrieving shows airing today")
220+ fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 1)
221+ }
222+ }
223 }
224
225 LoadingIndicator {
226
227=== modified file 'ui/MoviePage.qml'
228--- ui/MoviePage.qml 2014-01-04 15:06:19 +0000
229+++ ui/MoviePage.qml 2014-01-20 22:13:50 +0000
230@@ -14,6 +14,7 @@
231
232 property string movie_id
233 property bool isMovieSeen
234+ property bool isMovieWatchlisted
235
236 property int upVotes: 0
237 property int downVotes: 0
238@@ -54,6 +55,7 @@
239 averageVote = reply.ratings.percentage
240 if (traktLogin.contents.status !== "disabled") {
241 isMovieSeen = reply.watched
242+ isMovieWatchlisted = reply.in_watchlist
243 userVote = reply.rating_advanced
244 }
245 }
246@@ -109,10 +111,31 @@
247 }
248 }
249
250+ TraktWatchlist {
251+ id: movieWatchlist
252+ function updateJSONModel() {
253+ if(reply.status === "success") {
254+ loadingIndicator.visible = false
255+ if(!isMovieWatchlisted) {
256+ console.log("[LOG]: Movie watchlist success")
257+ isMovieWatchlisted = true
258+ }
259+ else {
260+ console.log("[LOG]: Movie Unwatchlist success")
261+ isMovieWatchlisted = false
262+ }
263+ var tempData = watchlistActivityDocument.contents
264+ tempData.movie = Qt.formatDateTime(new Date(), "yyyyMMdd hh:mm:ss")
265+ watchlistActivityDocument.contents = tempData
266+ }
267+ }
268+ }
269+
270 Component {
271 id: sharePopoverComponent
272 TraktPopup {
273 checkInMessage: movieActivityDocument.contents.name !== "default" ? i18n.tr("Cancel current movie check-in") : i18n.tr("Check-in movie into Trakt")
274+ watchlistMessage: isMovieWatchlisted ? i18n.tr("Remove movie from watchlist") : i18n.tr("Add movie to watchlist")
275 seenMessage: isMovieSeen ? i18n.tr("Mark movie as unseen") : i18n.tr("Mark movie as seen")
276 onCheckedIn: {
277 if(movieActivityDocument.contents.name !== "default") {
278@@ -137,6 +160,19 @@
279 movieUnsee.sendMessage()
280 }
281 }
282+ onWatchlisted: {
283+ loadingIndicator.loadingText = !isMovieWatchlisted ? i18n.tr("Adding movie to watchlist") : i18n.tr("Removing movie from watchlist")
284+ loadingIndicator.visible = true
285+ if(!isMovieWatchlisted) {
286+ movieWatchlist.source = Backend.traktWatchlistUrl("movie")
287+ movieWatchlist.createMovieMessage(traktLogin.contents.username, traktLogin.contents.password, movie.attributes.imdb_id, movie.attributes.title, movie.attributes.releaseDate.split('-')[0])
288+ }
289+ else {
290+ movieWatchlist.source = Backend.traktUnwatchlistUrl("movie")
291+ movieWatchlist.createMovieMessage(traktLogin.contents.username, traktLogin.contents.password, movie.attributes.imdb_id, movie.attributes.title, movie.attributes.releaseDate.split('-')[0])
292+ }
293+ movieWatchlist.sendMessage()
294+ }
295 onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: movie_id, type: "Movie", name: movie.attributes.title, year: movie.attributes.releaseDate.split('-')[0]})
296 }
297 }
298
299=== modified file 'ui/SeasonPage.qml'
300--- ui/SeasonPage.qml 2014-01-04 15:06:19 +0000
301+++ ui/SeasonPage.qml 2014-01-20 22:13:50 +0000
302@@ -74,6 +74,7 @@
303 TraktPopup {
304 showCheckInAction: false
305 showCommentAction: false
306+ showWatchlistAction: false
307 seenMessage: !isSeasonSeen ? i18n.tr("Mark season as seen") : i18n.tr("Season has been watched!")
308 onWatched: {
309 if(!isSeasonSeen) {
310
311=== modified file 'ui/TvPage.qml'
312--- ui/TvPage.qml 2014-01-04 15:06:19 +0000
313+++ ui/TvPage.qml 2014-01-20 22:13:50 +0000
314@@ -14,6 +14,7 @@
315
316 property string tv_id
317 property int userVote: 0
318+ property bool isShowWatchlisted
319
320 actions: [
321 Action {
322@@ -41,6 +42,26 @@
323 }
324 }
325
326+ TraktWatchlist {
327+ id: showWatchlist
328+ function updateJSONModel() {
329+ if(reply.status === "success") {
330+ loadingIndicator.visible = false
331+ if(!isShowWatchlisted) {
332+ console.log("[LOG]: Show watchlist success")
333+ isShowWatchlisted = true
334+ }
335+ else {
336+ console.log("[LOG]: Show Unwatchlist success")
337+ isShowWatchlisted = false
338+ }
339+ var tempData = watchlistActivityDocument.contents
340+ tempData.show = Qt.formatDateTime(new Date(), "yyyyMMdd hh:mm:ss")
341+ watchlistActivityDocument.contents = tempData
342+ }
343+ }
344+ }
345+
346 LoadingIndicator {
347 id: loadingIndicator
348 visible: false
349@@ -51,6 +72,7 @@
350 TraktPopup {
351 showCheckInAction: false
352 seenMessage: i18n.tr("Mark show as seen")
353+ watchlistMessage: isShowWatchlisted ? i18n.tr("Remove show from watchlist") : i18n.tr("Add show to watchlist")
354 onWatched: {
355 loadingIndicator.loadingText = i18n.tr("Marking show as seen")
356 loadingIndicator.visible = true
357@@ -58,6 +80,19 @@
358 showSee.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.imdb_id, show.name, show.year)
359 showSee.sendMessage()
360 }
361+ onWatchlisted: {
362+ loadingIndicator.loadingText = !isShowWatchlisted ? i18n.tr("Adding show to watchlist") : i18n.tr("Removing show from watchlist")
363+ loadingIndicator.visible = true
364+ if(!isShowWatchlisted) {
365+ showWatchlist.source = Backend.traktWatchlistUrl("show")
366+ showWatchlist.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.name, show.year)
367+ }
368+ else {
369+ showWatchlist.source = Backend.traktUnwatchlistUrl("show")
370+ showWatchlist.createShowMessage(traktLogin.contents.username, traktLogin.contents.password, tv_id, show.name, show.year)
371+ }
372+ showWatchlist.sendMessage()
373+ }
374 onCommented: pagestack.push(Qt.resolvedUrl("CommentsPage.qml"), {id: tv_id, type: "Show", name: show.name, year: show.year})
375 }
376 }
377@@ -80,8 +115,10 @@
378 }
379 onUpdated: {
380 tvCast.json = show.attributes.creditsJson;
381- if(traktLogin.contents.status !== "disabled")
382+ if(traktLogin.contents.status !== "disabled") {
383 userVote = show.attributes.userVote
384+ isShowWatchlisted = show.attributes.in_watchlist
385+ }
386 }
387 }
388
389
390=== modified file 'ui/TvTab.qml'
391--- ui/TvTab.qml 2014-01-18 20:35:22 +0000
392+++ ui/TvTab.qml 2014-01-20 22:13:50 +0000
393@@ -35,10 +35,17 @@
394 id: airingShowsModel
395 username: traktLogin.contents.username
396 password: traktLogin.contents.password
397+ lastUpdated: watchlistActivityDocument.contents.show
398 onPasswordChanged: {
399 console.log("[LOG]: Retrieving upcoming shows")
400 fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7)
401 }
402+ onLastUpdatedChanged: {
403+ if(username !== "") {
404+ console.log("[LOG]: Retrieving upcoming shows")
405+ fetchData(username, password, Qt.formatDate(new Date(), "yyyyMMdd"), 7)
406+ }
407+ }
408 }
409
410 LoadingIndicator {

Subscribers

People subscribed via source and target branches