diff --git a/src/api/settings.ts b/src/api/settings.ts new file mode 100644 index 0000000..35094ef --- /dev/null +++ b/src/api/settings.ts @@ -0,0 +1,31 @@ +import { BACKEND_URL } from "@/constants" +import { http } from "./common" + +async function downloadBlob(blob: Blob) { + const fileUrl = window.URL.createObjectURL(blob) + window.location.assign(fileUrl) +} + +export async function exportFollowers( + authToken: string, +): Promise { + const url = `${BACKEND_URL}/api/v1/settings/export_followers` + const response = await http(url, { + method: "GET", + authToken, + }) + const blob = await response.blob() + downloadBlob(blob) +} + +export async function exportFollows( + authToken: string, +): Promise { + const url = `${BACKEND_URL}/api/v1/settings/export_follows` + const response = await http(url, { + method: "GET", + authToken, + }) + const blob = await response.blob() + downloadBlob(blob) +} diff --git a/src/views/Settings.vue b/src/views/Settings.vue index 3a6bbad..eb184ef 100644 --- a/src/views/Settings.vue +++ b/src/views/Settings.vue @@ -34,6 +34,25 @@ +
+

Export

+ + + + + + + + + + + +
Follows{{ currentUser.following_count }} + download +
Followers{{ currentUser.followers_count }} + download +
+
@@ -41,11 +60,12 @@