aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-02-10 00:05:39 +0100
committerMorris Jobke <hey@morrisjobke.de>2015-02-10 00:05:39 +0100
commit4a99849c6c444a656c17b0e1f82dead6fb60cc5c (patch)
tree7670b264cffde651a16bb038bb4400fe30eb9833 /apps
parent068f6107c63e67554d65c089861838eaf73c668d (diff)
parent12f835b1981ecfbfb99687b9f61294653a9863bc (diff)
downloadnextcloud-server-4a99849c6c444a656c17b0e1f82dead6fb60cc5c.tar.gz
nextcloud-server-4a99849c6c444a656c17b0e1f82dead6fb60cc5c.zip
Merge pull request #13663 from owncloud/issue/13624-notification-when-favorting-fails
Only update favorite icon if the operation was successful
Diffstat (limited to 'apps')
-rw-r--r--apps/files/controller/apicontroller.php6
-rw-r--r--apps/files/js/tagsplugin.js16
2 files changed, 17 insertions, 5 deletions
diff --git a/apps/files/controller/apicontroller.php b/apps/files/controller/apicontroller.php
index a8bea27e4bb..1bb07010a27 100644
--- a/apps/files/controller/apicontroller.php
+++ b/apps/files/controller/apicontroller.php
@@ -76,11 +76,11 @@ class ApiController extends Controller {
try {
$this->tagService->updateFileTags($path, $tags);
} catch (\OCP\Files\NotFoundException $e) {
- return new DataResponse($e->getMessage(), Http::STATUS_NOT_FOUND);
+ return new DataResponse(['message' => $e->getMessage()], Http::STATUS_NOT_FOUND);
} catch (\OCP\Files\StorageNotAvailableException $e) {
- return new DataResponse($e->getMessage(), Http::STATUS_SERVICE_UNAVAILABLE);
+ return new DataResponse(['message' => $e->getMessage()], Http::STATUS_SERVICE_UNAVAILABLE);
} catch (\Exception $e) {
- return new DataResponse($e->getMessage(), Http::STATUS_NOT_FOUND);
+ return new DataResponse(['message' => $e->getMessage()], Http::STATUS_NOT_FOUND);
}
$result['tags'] = $tags;
}
diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js
index 27ab3eced04..293e25176f3 100644
--- a/apps/files/js/tagsplugin.js
+++ b/apps/files/js/tagsplugin.js
@@ -109,7 +109,9 @@
self.applyFileTags(
dir + '/' + fileName,
- tags
+ tags,
+ $actionEl,
+ isFavorite
).then(function(result) {
// response from server should contain updated tags
var newTags = result.tags;
@@ -157,8 +159,10 @@
*
* @param {String} fileName path to the file or folder to tag
* @param {Array.<String>} tagNames array of tag names
+ * @param {Object} $actionEl element
+ * @param {boolean} isFavorite Was the item favorited before
*/
- applyFileTags: function(fileName, tagNames) {
+ applyFileTags: function(fileName, tagNames, $actionEl, isFavorite) {
var encodedPath = OC.encodePath(fileName);
while (encodedPath[0] === '/') {
encodedPath = encodedPath.substr(1);
@@ -171,6 +175,14 @@
}),
dataType: 'json',
type: 'POST'
+ }).fail(function(response) {
+ var message = '';
+ // show message if it is available
+ if(response.responseJSON && response.responseJSON.message) {
+ message = ': ' + response.responseJSON.message;
+ }
+ OC.Notification.showTemporary(t('files', 'An error occurred while trying to update the tags') + message);
+ toggleStar($actionEl, isFavorite);
});
}
};