From a88e070acb788abe780465c0d17ebdc2fef60845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?nicole=20miko=C5=82ajczyk?= Date: Sat, 14 Mar 2026 14:15:27 +0100 Subject: [PATCH] nicolium: Migrate data exporter to hooks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: nicole mikołajczyk --- packages/nicolium/src/actions/export-data.ts | 19 +++++++------------ .../src/pages/settings/export-data.tsx | 8 +++++--- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/packages/nicolium/src/actions/export-data.ts b/packages/nicolium/src/actions/export-data.ts index 9c60a1894..08f07d102 100644 --- a/packages/nicolium/src/actions/export-data.ts +++ b/packages/nicolium/src/actions/export-data.ts @@ -1,10 +1,8 @@ import { defineMessages } from 'react-intl'; -import { getClient } from '@/api'; -import { useAuthStore } from '@/stores/auth'; import toast from '@/toast'; -import type { Account, PaginatedResponse } from 'pl-api'; +import type { Account, PaginatedResponse, PlApiClient } from 'pl-api'; const messages = defineMessages({ blocksSuccess: { @@ -41,11 +39,8 @@ const listAccounts = async (response: PaginatedResponse) => { return Array.from(new Set(accounts)); }; -const exportFollows = async () => { - const me = useAuthStore.getState().currentAccountId; - if (!me) return; - - const response = await getClient().accounts.getAccountFollowing(me, { limit: 40 }); +const exportFollows = async (client: PlApiClient) => { + const response = await client.accounts.getAccountFollowing(me, { limit: 40 }); const followings = await listAccounts(response); const followingsCsv = followings.map((fqn) => fqn + ',true'); followingsCsv.unshift('Account address,Show boosts'); @@ -54,16 +49,16 @@ const exportFollows = async () => { toast.success(messages.followersSuccess); }; -const exportBlocks = async () => { - const response = await getClient().filtering.getBlocks({ limit: 40 }); +const exportBlocks = async (client: PlApiClient) => { + const response = await client.filtering.getBlocks({ limit: 40 }); const blocks = await listAccounts(response); fileExport(blocks.join('\n'), 'export_block.csv'); toast.success(messages.blocksSuccess); }; -const exportMutes = async () => { - const response = await getClient().filtering.getMutes({ limit: 40 }); +const exportMutes = async (client: PlApiClient) => { + const response = await client.filtering.getMutes({ limit: 40 }); const mutes = await listAccounts(response); fileExport(mutes.join('\n'), 'export_mutes.csv'); diff --git a/packages/nicolium/src/pages/settings/export-data.tsx b/packages/nicolium/src/pages/settings/export-data.tsx index c6da02530..add659e1e 100644 --- a/packages/nicolium/src/pages/settings/export-data.tsx +++ b/packages/nicolium/src/pages/settings/export-data.tsx @@ -7,6 +7,7 @@ import Column from '@/components/ui/column'; import Form from '@/components/ui/form'; import FormActions from '@/components/ui/form-actions'; import Text from '@/components/ui/text'; +import { useClient } from '@/hooks/use-client'; interface ICSVExporter { inputLabel: React.ReactNode; @@ -51,12 +52,13 @@ const messages = defineMessages({ }); const ExportDataPage = () => { + const client = useClient(); const intl = useIntl(); return ( exportFollows(client)} inputLabel={} inputHint={ { } /> exportBlocks(client)} inputLabel={} inputHint={ { } /> exportMutes(client)} inputLabel={} inputHint={