diff --git a/CHANGELOG.md b/CHANGELOG.md index 185518f..c7072a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/api/settings.ts b/src/api/settings.ts index 79b510c..9c02334 100644 --- a/src/api/settings.ts +++ b/src/api/settings.ts @@ -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(