~vthompson/music-app/remix-genres-tab-001

« back to all changes in this revision

Viewing changes to meta-database.js

  • Committer: Tarmac
  • Author(s): Victor Thompson
  • Date: 2014-10-20 03:40:47 UTC
  • mfrom: (674.1.1 remix-fix-1382170)
  • Revision ID: tarmac-20141020034047-ehccbq6fkl3f0jpj
Fix playlist deletion and renaming in recent table. Fixes: https://bugs.launchpad.net/bugs/1382170.

Approved by Andrew Hayzen, Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
    return res;
104
104
}
105
105
 
 
106
function recentContainsPlaylist(key) {
 
107
    var db = getDatabase();
 
108
    var rs;
 
109
    db.transaction( function(tx) {
 
110
        rs = tx.executeSql("SELECT count(*) as value FROM recent WHERE type=? AND key=?",
 
111
                               ["playlist", key]);
 
112
    }
 
113
    );
 
114
    return rs.rows.item(0).value > 0;
 
115
}
 
116
 
 
117
function recentRemovePlaylist(key) {
 
118
    var res = false
 
119
    var db = getDatabase();
 
120
    db.transaction( function(tx) {
 
121
        res = tx.executeSql("DELETE FROM recent WHERE type=? AND key=?",
 
122
                            ["playlist", key]).rowsAffected > 0;
 
123
 
 
124
    })
 
125
    return res
 
126
}
 
127
 
 
128
function recentRenamePlaylist(oldKey, newKey) {
 
129
    var db = getDatabase();
 
130
    db.transaction( function(tx) {
 
131
        tx.executeSql("UPDATE recent SET title=?,key=? WHERE type=? AND key=?",
 
132
                            [newKey, newKey, "playlist", oldKey]);
 
133
 
 
134
    })
 
135
}
 
136
 
106
137
function isRecentEmpty() {
107
138
    var db = getDatabase();
108
139
    var res = 0;