diff options
author | Vitaly Takmazov | 2022-10-29 18:03:27 +0300 |
---|---|---|
committer | Vitaly Takmazov | 2023-01-13 10:37:58 +0300 |
commit | 77ff3fccdb68fecda3ca338b94d7bfcd0c5ce198 (patch) | |
tree | 2fed1702664205ba58b59b3c0725fa92efece167 /vnext/src/api/index.js | |
parent | a037b8161a4550bfbbb7296a679d2b8cb3c969d2 (diff) |
Trends and cleanup JSDoc
Diffstat (limited to 'vnext/src/api/index.js')
-rw-r--r-- | vnext/src/api/index.js | 59 |
1 files changed, 51 insertions, 8 deletions
diff --git a/vnext/src/api/index.js b/vnext/src/api/index.js index a6a6208c..fac845e8 100644 --- a/vnext/src/api/index.js +++ b/vnext/src/api/index.js @@ -4,13 +4,17 @@ import Cookies from 'universal-cookie'; const apiBaseUrl = 'https://juick.com'; /** - * @typedef {Object} Token + * @typedef {object} Token * @property {string} type * @property {string} token */ +/** + * @typedef { object } TagStats + * @property { string } tag + */ /** - * @typedef {Object} User + * @typedef {object} User * @property {string=} uname * @property {number} uid * @property {number=} unreadCount @@ -22,7 +26,7 @@ const apiBaseUrl = 'https://juick.com'; */ /** - * @typedef {Object} SecureUserProperties + * @typedef {object} SecureUserProperties * @property {string=} hash * @property {Token[]=} tokens * @property {string=} telegramName @@ -38,7 +42,7 @@ const apiBaseUrl = 'https://juick.com'; */ /** - * @typedef {Object} ChatProperties + * @typedef {object} ChatProperties * @property {number=} unreadCount * @property {string=} lastMessageText */ @@ -48,7 +52,7 @@ const apiBaseUrl = 'https://juick.com'; */ /** - * @typedef {Object} Message + * @typedef {object} Message * @property {string} body * @property {number=} mid * @property {number=} rid @@ -83,9 +87,10 @@ client.interceptors.request.use(config => { /** * fetch my info + * * @param {string} username * @param {string} password - * @return {Promise<SecureUser, Error>} me object + * @returns {Promise<SecureUser, Error>} me object */ export function me(username = '', password = '') { let cookies = new Cookies(); @@ -113,6 +118,9 @@ export function info(username) { } +/** + * + */ export function getChats() { return client.get('/api/groups_pms'); } @@ -174,7 +182,13 @@ export function comment(mid, rid, body, attach) { form.append('attach', attach); return client.post('/api/comment', form); } - +/** + * Edit message + * + * @param {number} mid + * @param {number} rid + * @param {string?} body + */ export function update(mid, rid, body) { let form = new FormData(); form.append('mid', mid); @@ -182,7 +196,11 @@ export function update(mid, rid, body) { form.append('body', body); return client.post('/api/update', form); } - +/** + * Update user avatar + * + * @param {string} newAvatar + */ export function updateAvatar(newAvatar) { let form = new FormData(); form.append('avatar', newAvatar); @@ -196,14 +214,23 @@ function socialLink(network) { return `${apiBaseUrl}/api/_${network}login?state=${window.location.protocol}//${window.location.host}${window.location.pathname}`; } +/** + * + */ export function facebookLink() { return socialLink('fb'); } +/** + * + */ export function vkLink() { return socialLink('vk'); } +/** + * + */ export function appleLink() { return socialLink('apple'); } @@ -239,3 +266,19 @@ export function fetchUserUri(profileUrl) { } }); } + +/** + * + * @returns { Promise<TagStats[]> } tags + */ + export const trends = async () => { + try { + const response = await client.get('/api/tags'); + return response.data; + } catch (e) { + console.error(e); + return []; + } +}; + + |