Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.mdns.eu/nextcloud/passwords-client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarius David Wieschollek <passwords.public@mdns.eu>2020-02-26 20:27:37 +0300
committerMarius David Wieschollek <passwords.public@mdns.eu>2020-02-26 20:27:37 +0300
commita0ac896fa0be99cdf6f866bdc67d47803acb3dc1 (patch)
tree9e21b5bea384457b1bd613092e834ae20b0b199b /src
parent44dc505f5a92427bda2cb74a7b9f40ff16c8f592 (diff)
Allow fetching single items from collection
Signed-off-by: Marius David Wieschollek <passwords.public@mdns.eu>
Diffstat (limited to 'src')
-rw-r--r--src/Api/Api.js4
-rw-r--r--src/Collection/AbstractCollection.js24
2 files changed, 26 insertions, 2 deletions
diff --git a/src/Api/Api.js b/src/Api/Api.js
index be87216..84d7892 100644
--- a/src/Api/Api.js
+++ b/src/Api/Api.js
@@ -181,7 +181,7 @@ export default class Api {
* @returns {SessionAuthorization}
*/
getSessionAuthorization() {
- return this.getInstance('authorization.session', this);
+ return this.getInstance('authorization.session');
}
/**
@@ -333,7 +333,7 @@ export default class Api {
response: ApiResponse
},
authorization: {
- session: SessionAuthorization
+ session: () => { return new SessionAuthorization(this); }
},
challenge : {
pwdv1: PWDv1Challenge
diff --git a/src/Collection/AbstractCollection.js b/src/Collection/AbstractCollection.js
index 5947cf4..4dd63a4 100644
--- a/src/Collection/AbstractCollection.js
+++ b/src/Collection/AbstractCollection.js
@@ -3,6 +3,13 @@ import AbstractModel from '../Model/AbstractModel';
export default class AbstractCollection {
/**
+ * @return {Number}
+ */
+ get length() {
+ return this._elements.length;
+ }
+
+ /**
*
* @param {AbstractConverter} converter
* @param {AbstractModel} elements
@@ -60,6 +67,23 @@ export default class AbstractCollection {
}
/**
+ * @param {(Number|String)} index
+ * @return {AbstractModel|string|null}
+ * @api
+ */
+ get(index) {
+ if(this._elements.hasOwnProperty(index)) {
+ return this._elements[index];
+ }
+
+ for(let element in this._elements) {
+ if(element.getId() === index) return element;
+ }
+
+ return null;
+ }
+
+ /**
* @param {(String|Object|AbstractModel)} element
* @private
*/