2025-06-27 16:29:31 +02:00
|
|
|
import { createAppAsyncThunk } from "@/app/async-thunk"
|
|
|
|
|
import { client } from "@/app/client"
|
2026-05-03 19:14:50 +02:00
|
|
|
import type { Settings } from "@/app/types"
|
2024-06-13 21:54:14 +02:00
|
|
|
|
|
|
|
|
export const reloadSettings = createAppAsyncThunk("settings/reload", async () => await client.user.getSettings().then(r => r.data))
|
2025-02-14 13:49:46 +01:00
|
|
|
|
2024-06-13 21:54:14 +02:00
|
|
|
export const reloadProfile = createAppAsyncThunk("profile/reload", async () => await client.user.getProfile().then(r => r.data))
|
2025-02-14 13:49:46 +01:00
|
|
|
|
2024-06-13 21:54:14 +02:00
|
|
|
export const reloadTags = createAppAsyncThunk("entries/tags", async () => await client.entry.getTags().then(r => r.data))
|
2025-02-14 13:49:46 +01:00
|
|
|
|
2026-05-03 19:14:50 +02:00
|
|
|
export const changeSettings = createAppAsyncThunk("settings/change", async (newSettings: Partial<Settings>, thunkApi) => {
|
2024-06-13 21:54:14 +02:00
|
|
|
const { settings } = thunkApi.getState().user
|
|
|
|
|
if (!settings) return
|
2026-05-03 19:14:50 +02:00
|
|
|
await client.user.saveSettings({ ...settings, ...newSettings })
|
2024-06-13 21:54:14 +02:00
|
|
|
})
|