From 74400b05996dcd03ed6431e543201220482807b5 Mon Sep 17 00:00:00 2001 From: Matthew Taylor Date: Tue, 5 Sep 2017 10:03:48 -0400 Subject: [PATCH] add comments to redux methods --- src/redux/messages.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/redux/messages.js b/src/redux/messages.js index ee64fd8f7..0236e82dd 100644 --- a/src/redux/messages.js +++ b/src/redux/messages.js @@ -112,6 +112,10 @@ module.exports.setStatus = function (type, status){ }; }; +/** + * Sends a request to mark one's unread messages count as cleared. + * @return {null} returns nothing + */ module.exports.clearMessageCount = function () { return function (dispatch) { dispatch(module.exports.setStatus('CLEAR_STATUS', module.exports.Status.FETCHING)); @@ -136,6 +140,14 @@ module.exports.clearMessageCount = function () { }; }; +/** + * Marks an admin message as read, dismissing it from the page + * @param {string} messageType type of message to delete (invite or notification) + * @param {number} messageId id of the message to delete + * @param {number} messageCount current number of unread notifications + * @param {object[]} adminMessages current list of admin messages retrieved + * @return {null} returns nothing + */ module.exports.clearAdminMessage = function (messageType, messageId, messageCount, adminMessages) { return function (dispatch) { dispatch(module.exports.setStatus('CLEAR_STATUS', module.exports.Status.FETCHING)); @@ -181,6 +193,14 @@ module.exports.clearAdminMessage = function (messageType, messageId, messageCoun }; }; +/** + * Gets a user's messages to be displayed on the /messages page + * @param {string} username username of the user for whom the messages should be gotten + * @param {string} token the user's unique token for auth + * @param {object[]} messages an array of existing messages on the page, if there are any + * @param {number} offset offset of messages to get, based on the number retrieved already + * @return {null} returns nothing + */ module.exports.getMessages = function (username, token, messages, offset) { return function (dispatch) { dispatch(module.exports.setStatus('MESSAGE_STATUS', module.exports.Status.FETCHING)); @@ -206,6 +226,12 @@ module.exports.getMessages = function (username, token, messages, offset) { }; }; +/** + * Gets the messages from the Scratch Team for a user + * @param {string} username user's username for whom to get the admin messages + * @param {string} token the user's unique token for auth + * @return {null} returns nothing + */ module.exports.getAdminMessages = function (username, token) { return function (dispatch) { dispatch(module.exports.setStatus('ADMIN_STATUS', module.exports.Status.FETCHING)); @@ -231,6 +257,12 @@ module.exports.getAdminMessages = function (username, token) { }; }; +/** + * Gets the invitation to become a Scratcher for a user, if one exists + * @param {string} username user's username for whom to get the invite + * @param {string} token the user's unique token for auth + * @return {null} returns nothing + */ module.exports.getScratcherInvite = function (username, token) { return function (dispatch) { api({