Set file name for follower/following list downloads

This commit is contained in:
silverpill 2023-01-20 20:59:23 +00:00
parent d1b651a83c
commit 8c5f7c4b0e
2 changed files with 9 additions and 4 deletions

View file

@ -14,6 +14,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Show full date and time in post timestamp tooltip.
- Show error message if profile details can't be updated.
- Set file name for follower/following list downloads.
## [1.10.0] - 2023-01-18

View file

@ -20,9 +20,13 @@ export async function changePassword(
}
}
async function downloadBlob(blob: Blob) {
async function downloadBlob(blob: Blob, name: string) {
const fileUrl = window.URL.createObjectURL(blob)
window.location.assign(fileUrl)
const hiddenLink = document.createElement("a")
hiddenLink.setAttribute("href", fileUrl)
hiddenLink.setAttribute("download", name)
hiddenLink.click()
window.URL.revokeObjectURL(fileUrl)
}
export async function exportFollowers(
@ -34,7 +38,7 @@ export async function exportFollowers(
authToken,
})
const blob = await response.blob()
downloadBlob(blob)
downloadBlob(blob, "followers.csv")
}
export async function exportFollows(
@ -46,7 +50,7 @@ export async function exportFollows(
authToken,
})
const blob = await response.blob()
downloadBlob(blob)
downloadBlob(blob, "follows.csv")
}
export async function importFollows(