mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-22 19:25:18 -04:00
fix: Move content into to frontend directory
Doing this BEFORE the merge prevents a lot of merge conflicts. Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
4e18ce38f3
commit
762a0a850e
1051 changed files with 0 additions and 35 deletions
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* SPDX-FileCopyrightText: 2022 The HedgeDoc developers (see AUTHORS file)
|
||||
*
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
import type { RevisionDetails } from '../../../../api/revisions/types'
|
||||
import { getUser } from '../../../../api/users'
|
||||
import type { UserInfo } from '../../../../api/users/types'
|
||||
import { download } from '../../../common/download/download'
|
||||
|
||||
const DISPLAY_MAX_USERS_PER_REVISION = 9
|
||||
|
||||
/**
|
||||
* Downloads a given revision's content as markdown document in the browser.
|
||||
*
|
||||
* @param noteId The id of the note from which to download the revision.
|
||||
* @param revision The revision details object containing the content to download.
|
||||
*/
|
||||
export const downloadRevision = (noteId: string, revision: RevisionDetails | null): void => {
|
||||
if (!revision) {
|
||||
return
|
||||
}
|
||||
download(revision.content, `${noteId}-${revision.createdAt}.md`, 'text/markdown')
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches user details for the given usernames while returning a maximum of 9 users.
|
||||
*
|
||||
* @param usernames The list of usernames to fetch.
|
||||
* @throws {Error} in case the user-data request failed.
|
||||
* @return An array of user details.
|
||||
*/
|
||||
export const getUserDataForRevision = async (usernames: string[]): Promise<UserInfo[]> => {
|
||||
const users: UserInfo[] = []
|
||||
const usersToFetch = Math.min(usernames.length, DISPLAY_MAX_USERS_PER_REVISION) - 1
|
||||
for (let i = 0; i <= usersToFetch; i++) {
|
||||
const user = await getUser(usernames[i])
|
||||
users.push(user)
|
||||
}
|
||||
return users
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue