Merge lp:~vthompson/ubuntu-weather-app/reboot-migrate-locations into lp:ubuntu-weather-app

Proposed by Victor Thompson on 2015-06-18
Status: Merged
Approved by: Andrew Hayzen on 2015-06-28
Approved revision: 55
Merged at revision: 57
Proposed branch: lp:~vthompson/ubuntu-weather-app/reboot-migrate-locations
Merge into: lp:ubuntu-weather-app
Diff against target: 62 lines (+12/-4)
3 files modified
app/data/Storage.qml (+6/-0)
app/ubuntu-weather-app.qml (+4/-2)
app/ui/LocationsPage.qml (+2/-2)
To merge this branch: bzr merge lp:~vthompson/ubuntu-weather-app/reboot-migrate-locations
Reviewer Review Type Date Requested Status
Andrew Hayzen 2015-06-18 Approve on 2015-06-28
Ubuntu Phone Apps Jenkins Bot continuous-integration Approve on 2015-06-18
Review via email: mp+262292@code.launchpad.net

Commit message

Properly migrate Locations.

Description of the change

Properly migrate Locations.

To test without downgrading to the old app and upgrading to the new app, simply remove addedCurrentLocation from your ~/.config/com.ubuntu.weather/com.ubuntu.weather.conf file.

To post a comment you must log in.
Andrew Hayzen (ahayzen) wrote :

LGTM :-)

I tested importing from the old app normally, with no location detection/data, with no location detection. And a few other combos, everything works as expected :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'app/data/Storage.qml'
2--- app/data/Storage.qml 2015-05-09 00:47:22 +0000
3+++ app/data/Storage.qml 2015-06-18 03:58:46 +0000
4@@ -121,6 +121,12 @@
5 return res;
6 }
7
8+ function insertLocationAtStart(data) {
9+ var res = insertLocation(data);
10+ reorder(res, 0);
11+ return 0;
12+ }
13+
14 function updateLocation(dbId, data) {
15 openDB();
16 db.transaction( function(tx){
17
18=== modified file 'app/ubuntu-weather-app.qml'
19--- app/ubuntu-weather-app.qml 2015-06-10 01:47:37 +0000
20+++ app/ubuntu-weather-app.qml 2015-06-18 03:58:46 +0000
21@@ -148,6 +148,7 @@
22 property string units
23 property string windUnits
24
25+ property bool addedCurrentLocation: false
26 property bool migrated: false
27
28 Component.onCompleted: {
29@@ -170,8 +171,9 @@
30 // Add or replace the current locaiton to the storage and refresh the
31 // locationList
32 function updateCurrentLocation(location) {
33- if (locationsList == null || locationsList.length == 0) {
34- storage.insertLocation({location: location});
35+ if (!settings.addedCurrentLocation || locationsList == null || locationsList.length == 0) {
36+ storage.insertLocationAtStart({location: location});
37+ settings.addedCurrentLocation = true;
38 } else {
39 storage.updateLocation(locationsList[0].db.id, {location: location});
40 }
41
42=== modified file 'app/ui/LocationsPage.qml'
43--- app/ui/LocationsPage.qml 2015-06-14 21:17:22 +0000
44+++ app/ui/LocationsPage.qml 2015-06-18 03:58:46 +0000
45@@ -72,7 +72,7 @@
46 left: parent.left
47 right: parent.right
48 }
49- height: units.gu(8)
50+ height: settings.addedCurrentLocation ? units.gu(8) : units.gu(0)
51 interactive: false
52 model: currentLocationModel
53 delegate: WeatherListItem {
54@@ -262,7 +262,7 @@
55 "icon": iconMap[data.data[0].current.icon]
56 }
57
58- if (i > 0) {
59+ if (!settings.addedCurrentLocation || i > 0) {
60 locationsModel.append(loc)
61 } else {
62 currentLocationModel.append(loc)

Subscribers

People subscribed via source and target branches

to all changes: