From 7609fdbabf2dca556873a9c48df4c597f7df209a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien?= Date: Thu, 28 Jan 2021 16:59:20 +0100 Subject: Add Loading for searchUser and share Signed-off-by: Marco Nassabain --- js/controller/ShareController.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'js/controller/ShareController.js') diff --git a/js/controller/ShareController.js b/js/controller/ShareController.js index 57722f416..b5b252dd6 100644 --- a/js/controller/ShareController.js +++ b/js/controller/ShareController.js @@ -6,15 +6,19 @@ * * @author Marco Nassabain */ -app.controller('ShareController', function (ShareResource) { +app.controller('ShareController', function (ShareResource, Loading) { 'use strict'; this.userList = []; this.searchUsers = function(search) { + + Loading.setLoading('user', true); + // TODO: search === undefined 🤢 je pense pas que c'est ouf comme syntaxe if (search === '' || search === undefined) { this.userList = []; + Loading.setLoading('user', false); return; } @@ -22,13 +26,16 @@ app.controller('ShareController', function (ShareResource) { var response = ShareResource.getUsers(search); response.then((response) => { this.userList = response.ocs.data.users; + Loading.setLoading('user', false); }); }; - // Dict (user_id)>: Local mapping b/w users & articles: [Article 1 : , Article 2: <...>] + // Dict (user_id)>: Local mapping b/w users & articles: + //[Article 1 : , Article 2: <...>] this.usersSharedArticles = {}; this.shareItem = function(itemId, userId) { + Loading.setLoading(userId, true); if (this.usersSharedArticles[itemId] && this.usersSharedArticles[itemId].includes(userId)) {return ; } // quick initialization (instead of if (...) : []) @@ -38,6 +45,7 @@ app.controller('ShareController', function (ShareResource) { var response = ShareResource.shareItem(itemId, userId); response.then((result) => { + Loading.setLoading(userId, false); return result; }); }; -- cgit v1.2.3