From 23fcd2927ed1ae0ac9af14e134d3b503896b70eb Mon Sep 17 00:00:00 2001 From: Max Berger Date: Sat, 7 Mar 2026 22:20:22 +0100 Subject: [PATCH] Add typedef for Share type --- .../web/internal_data/ShareCollectionScene.js | 8 +++---- radicale/web/internal_data/api.js | 22 +++++++++++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/radicale/web/internal_data/ShareCollectionScene.js b/radicale/web/internal_data/ShareCollectionScene.js index 268a1579..9f39f7d5 100644 --- a/radicale/web/internal_data/ShareCollectionScene.js +++ b/radicale/web/internal_data/ShareCollectionScene.js @@ -104,8 +104,8 @@ function update_share_list(user, password, collection) { } }); - reload_sharing_list(user, password, collection, function (response) { - add_share_rows(user, password, collection, response["Content"] || []); + reload_sharing_list(user, password, collection, function (shares) { + add_share_rows(user, password, collection, shares); }); } @@ -114,7 +114,7 @@ function update_share_list(user, password, collection) { * @param {string} user * @param {string} password * @param {Collection} collection - * @param {Object} share + * @param {import('./api.js').Share} share * @param {HTMLElement} template * @param {string} delete_label * @param {function(string, string, string, function():void):void} delete_action @@ -164,7 +164,7 @@ function add_share_row_node(user, password, collection, share, template, delete_ * @param {string} user * @param {string} password * @param {Collection} collection - * @param {Object} shares + * @param {Array} shares */ function add_share_rows(user, password, collection, shares) { /** @type {HTMLElement} */ let token_template = document.querySelector("[data-name=sharetokenrowtemplate]"); diff --git a/radicale/web/internal_data/api.js b/radicale/web/internal_data/api.js index ed45d205..6ba48466 100644 --- a/radicale/web/internal_data/api.js +++ b/radicale/web/internal_data/api.js @@ -426,11 +426,28 @@ export function discover_server_features(user, password, callback) { ); } +/** + * @typedef {Object} Share + * @property {string} ShareType + * @property {string} PathOrToken + * @property {string} PathMapped + * @property {string} Owner + * @property {string} User + * @property {string} Permissions + * @property {boolean} EnabledByOwner + * @property {boolean} EnabledByUser + * @property {boolean} HiddenByOwner + * @property {boolean} HiddenByUser + * @property {number} TimestampCreated + * @property {number} TimestampUpdated + * @property {string} Properties + */ + /** * @param {string} user * @param {string} password * @param {Collection} collection - * @param {function(object):void} callback + * @param {function(Array):void} callback */ export function reload_sharing_list(user, password, collection, callback) { call_sharing_api( @@ -439,7 +456,8 @@ export function reload_sharing_list(user, password, collection, callback) { "all/list", { PathMapped: collection.href }, function (response) { - callback(JSON.parse(response)); + let parsed = JSON.parse(response); + callback(parsed["Content"] || []); }, ); }