Merge lp:~abreu-alexandre/webapps-core/post-error-feedback into lp:webapps-core

Proposed by Alexandre Abreu
Status: Needs review
Proposed branch: lp:~abreu-alexandre/webapps-core/post-error-feedback
Merge into: lp:webapps-core
Diff against target: 281 lines (+108/-32)
7 files modified
webapp-facebook/manifest.json (+1/-1)
webapp-facebook/unity-webapps-facebook/HubSharer.qml (+2/-9)
webapp-facebook/unity-webapps-facebook/Share.qml (+57/-7)
webapp-facebook/unity-webapps-facebook/facebook.user.js (+7/-3)
webapp-twitter/unity-webapps-twitter/HubSharer.qml (+1/-4)
webapp-twitter/unity-webapps-twitter/Share.qml (+37/-5)
webapp-twitter/unity-webapps-twitter/share.user.js (+3/-3)
To merge this branch: bzr merge lp:~abreu-alexandre/webapps-core/post-error-feedback
Reviewer Review Type Date Requested Status
Ubuntu Phablet Team Pending
Review via email: mp+265018@code.launchpad.net

Commit message

Add feedback messages when an error happens as a picture/etc. is being posted.

Description of the change

Add feedback messages when an error happens as a picture/etc. is being posted.

To post a comment you must log in.
119. By Alexandre Abreu

share content hub links

120. By Alexandre Abreu

Tweak facebook link shareing piucture

121. By Alexandre Abreu

Add error user feedback screen

Unmerged revisions

121. By Alexandre Abreu

Add error user feedback screen

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'webapp-facebook/manifest.json'
2--- webapp-facebook/manifest.json 2015-04-16 16:59:55 +0000
3+++ webapp-facebook/manifest.json 2015-09-21 15:59:22 +0000
4@@ -19,5 +19,5 @@
5 "maintainer": "Webapps Team <webapps@lists.launchpad.net>",
6 "name": "com.ubuntu.developer.webapps.webapp-facebook",
7 "title": "Facebook",
8- "version": "1.1"
9+ "version": "1.2"
10 }
11
12=== modified file 'webapp-facebook/unity-webapps-facebook/HubSharer.qml'
13--- webapp-facebook/unity-webapps-facebook/HubSharer.qml 2015-04-16 14:59:02 +0000
14+++ webapp-facebook/unity-webapps-facebook/HubSharer.qml 2015-09-21 15:59:22 +0000
15@@ -22,12 +22,8 @@
16 fileToShare: dataUri.toString(),
17 message: message};
18
19- completed(
20- JSON.stringify(result),
21- function(result) {
22- main.destroy();
23- resourceUploadCompletedCallback(result);
24- });
25+ completed(JSON.stringify(result),
26+ resourceUploadCompletedCallback);
27 }
28
29 ContentItem {
30@@ -69,9 +65,6 @@
31 /* if the upload was successful, we need to destroy the parent */
32 if (success) {
33 main.destroy();
34- } else {
35- console.error ("Upload failed");
36- /* FIXME: Display a message to the user */
37 }
38 }
39 }
40
41=== modified file 'webapp-facebook/unity-webapps-facebook/Share.qml'
42--- webapp-facebook/unity-webapps-facebook/Share.qml 2015-09-21 15:53:37 +0000
43+++ webapp-facebook/unity-webapps-facebook/Share.qml 2015-09-21 15:59:22 +0000
44@@ -36,16 +36,29 @@
45 property string accessToken
46 property var account
47
48+ property int __attemptCount: 0
49+
50 signal accountSelected
51 signal canceled
52- signal uploadCompleted(bool success)
53+ signal uploadCompleted(bool success, string errorMessage)
54
55 onUploadCompleted: {
56 activitySpinner.visible = false;
57- if (success)
58- print ("Successfully posted");
59- else
60- print ("Failed to post");
61+ if (! success) {
62+ var reply = JSON.parse(errorMessage)
63+ if (root.__attemptCount === 0 && "error" in reply && reply.error.type == "OAuthException") {
64+ console.log("Trying again!")
65+ activitySpinner.visible = true
66+ root.__attemptCount++
67+ root.account.authenticate({
68+ "ForceTokenRefresh": true
69+ })
70+ } else
71+ {
72+ statusRow.text = errorMessage
73+ statusRow.visible = true
74+ }
75+ }
76 }
77
78 AccountServiceModel {
79@@ -63,13 +76,18 @@
80 id: srv
81 onObjectHandleChanged: {
82 root.account = srv;
83+ root.__attemptCount = 0;
84 root.account.authenticate(null);
85 }
86 onAuthenticated: {
87 root.userAccountId = accountId;
88 root.accessToken = reply.AccessToken;
89- shareComponent.visible = true;
90- sharemenu.visible = false;
91+ if (!shareComponent.visible) {
92+ shareComponent.visible = true;
93+ sharemenu.visible = false;
94+ } else {
95+ callback(accessToken, fileToShare, message.text, uploadCompleted);
96+ }
97 }
98 }
99
100@@ -164,6 +182,38 @@
101 }
102 }
103
104+ Row {
105+ id: statusRow
106+
107+ visible: false
108+
109+ anchors.left: parent.left
110+ anchors.right: parent.right
111+
112+ anchors.topMargin: units.gu(4)
113+ anchors.leftMargin: units.gu(1)
114+ anchors.rightMargin: units.gu(1)
115+
116+ height: units.gu(10)
117+
118+ TextArea {
119+ id: statusLabel
120+
121+ anchors.fill: parent
122+
123+ anchors.margins: units.gu(1)
124+
125+ wrapMode: Text.Wrap
126+
127+ readOnly: true
128+
129+ clip: true
130+ font.pixelSize: FontUtils.sizeToPixels("medium")
131+ font.weight: Font.Light
132+ focus: true
133+ }
134+ }
135+
136 Item {
137 id: actionsBar
138 anchors.left: parent.left
139
140=== modified file 'webapp-facebook/unity-webapps-facebook/facebook.user.js'
141--- webapp-facebook/unity-webapps-facebook/facebook.user.js 2015-04-17 18:57:59 +0000
142+++ webapp-facebook/unity-webapps-facebook/facebook.user.js 2015-09-21 15:59:22 +0000
143@@ -49,14 +49,18 @@
144 activeTransfer.setState(hub.ContentTransfer.State.Aborted);
145
146 var xhr = new XMLHttpRequest();
147- xhr.open( 'POST', 'https://graph.facebook.com/me/photos?access_token=' + results.accessToken, true );
148+ xhr.open('POST',
149+ 'https://graph.facebook.com/me/photos?access_token=' + results.accessToken,
150+ true);
151+
152 xhr.onload = xhr.onerror = function() {
153- if ( xhr.status == 200 ) {
154+ if (xhr.status == 200) {
155 window.location.reload();
156 onResourceUploadedCallback(true);
157 }
158 else {
159- onResourceUploadedCallback(false);
160+ onResourceUploadedCallback(
161+ false, xhr.responseText);
162 }
163 };
164
165
166=== modified file 'webapp-twitter/unity-webapps-twitter/HubSharer.qml'
167--- webapp-twitter/unity-webapps-twitter/HubSharer.qml 2015-03-12 21:41:16 +0000
168+++ webapp-twitter/unity-webapps-twitter/HubSharer.qml 2015-09-21 15:59:22 +0000
169@@ -31,7 +31,7 @@
170 };
171
172 completed(JSON.stringify(result),
173- function(result) { main.destroy(); resourceUploadCompletedCallback(result); });
174+ resourceUploadCompletedCallback);
175 }
176
177 ContentItem {
178@@ -69,9 +69,6 @@
179 /* if the upload was successful, we need to destroy the parent */
180 if (success) {
181 main.destroy();
182- } else {
183- console.error ("Upload failed");
184- /* FIXME: Display a message to the user */
185 }
186 }
187 }
188
189=== modified file 'webapp-twitter/unity-webapps-twitter/Share.qml'
190--- webapp-twitter/unity-webapps-twitter/Share.qml 2015-03-12 21:41:16 +0000
191+++ webapp-twitter/unity-webapps-twitter/Share.qml 2015-09-21 15:59:22 +0000
192@@ -40,14 +40,14 @@
193
194 signal accountSelected
195 signal canceled
196- signal uploadCompleted(bool success)
197+ signal uploadCompleted(bool success, string errorMessage)
198
199 onUploadCompleted: {
200 activitySpinner.visible = false;
201- if (success)
202- print ("Successfully posted");
203- else
204- print ("Failed to post");
205+ if (! success) {
206+ statusRow.text = errorMessage
207+ statusRow.visible = true
208+ }
209 }
210
211 AccountServiceModel {
212@@ -169,6 +169,38 @@
213 }
214 }
215
216+ Row {
217+ id: statusRow
218+
219+ visible: false
220+
221+ anchors.left: parent.left
222+ anchors.right: parent.right
223+
224+ anchors.topMargin: units.gu(4)
225+ anchors.leftMargin: units.gu(1)
226+ anchors.rightMargin: units.gu(1)
227+
228+ height: units.gu(10)
229+
230+ TextArea {
231+ id: statusLabel
232+
233+ anchors.fill: parent
234+
235+ anchors.margins: units.gu(1)
236+
237+ wrapMode: Text.Wrap
238+
239+ readOnly: true
240+
241+ clip: true
242+ font.pixelSize: FontUtils.sizeToPixels("medium")
243+ font.weight: Font.Light
244+ focus: true
245+ }
246+ }
247+
248 Item {
249 id: actionsBar
250 anchors.left: parent.left
251
252=== modified file 'webapp-twitter/unity-webapps-twitter/share.user.js'
253--- webapp-twitter/unity-webapps-twitter/share.user.js 2015-04-16 14:59:02 +0000
254+++ webapp-twitter/unity-webapps-twitter/share.user.js 2015-09-21 15:59:22 +0000
255@@ -245,7 +245,7 @@
256 activeTransfer = null;
257 onResourceUploadedCallback(
258 false,
259- {errorMessage: results.errorMsg});
260+ results.errorMsg);
261 return;
262 }
263
264@@ -278,7 +278,7 @@
265 window.location.reload();
266 onResourceUploadedCallback(
267 results.success,
268- {errorMessage: results.errorMsg});
269+ results.errorMsg);
270 });
271 }
272 );
273@@ -311,7 +311,7 @@
274 if (content.errorMsg
275 && content.errorMsg.length !== 0) {
276 onResourceUploadedCallback(
277- false, {errorMessage: content.errorMsg})
278+ false, content.errorMsg)
279 activeTransfer = null;
280 return;
281 }

Subscribers

People subscribed via source and target branches

to all changes: