Fix unset public name action to call unsetPublicName method

This commit is contained in:
srgooglo 2025-07-04 14:13:31 +02:00
parent e3d8d25391
commit a0c82c3cae

View File

@ -3,196 +3,194 @@ import UserModel from "@models/user"
import UploadButton from "@components/UploadButton" import UploadButton from "@components/UploadButton"
export default { export default {
id: "profile", id: "profile",
icon: "FiUser", icon: "FiUser",
label: "Profile", label: "Profile",
group: "basic", group: "basic",
ctxData: async () => { ctxData: async () => {
const userData = await UserModel.data() const userData = await UserModel.data()
return { return {
userData userData,
} }
}, },
settings: [ settings: [
{ {
id: "username", id: "username",
group: "account.basicInfo", group: "account.basicInfo",
component: "Button", component: "Button",
icon: "FiAtSign", icon: "FiAtSign",
title: "Username", title: "Username",
description: "Your username is the name you use to log in to your account.", description:
props: { "Your username is the name you use to log in to your account.",
disabled: true, props: {
children: "Change username", disabled: true,
}, children: "Change username",
}, },
{ },
id: "public_name", {
group: "account.basicInfo", id: "public_name",
component: "Input", group: "account.basicInfo",
icon: "FiEdit3", component: "Input",
title: "Name", icon: "FiEdit3",
description: "Change your public name", title: "Name",
props: { description: "Change your public name",
maxLength: 120, props: {
showCount: true, maxLength: 120,
allowClear: true, showCount: true,
placeholder: "Enter your name. e.g. John Doe", allowClear: true,
}, placeholder: "Enter your name. e.g. John Doe",
defaultValue: (ctx) => { },
return ctx.userData.public_name defaultValue: (ctx) => {
}, return ctx.userData.public_name
onUpdate: async (value) => { },
const result = await UserModel.updateData({ onUpdate: async (value) => {
public_name: value const result = await UserModel.updateData({
}) public_name: value,
})
if (result) { if (result) {
app.message.success("Public name updated") app.message.success("Public name updated")
return value return value
} }
}, },
extraActions: [ extraActions: [
{ {
"id": "unset", id: "unset",
"icon": "Delete", icon: "Delete",
"title": "Unset", title: "Unset",
"onClick": async () => { onClick: async () => {
await UserModel.unsetFullName() await UserModel.unsetPublicName()
} },
} },
], ],
debounced: true, debounced: true,
storaged: false, storaged: false,
}, },
{ {
id: "email", id: "email",
group: "account.basicInfo", group: "account.basicInfo",
component: "Input", component: "Input",
icon: "FiMail", icon: "FiMail",
title: "Email", title: "Email",
description: "Change your email address", description: "Change your email address",
props: { props: {
placeholder: "Enter your email address", placeholder: "Enter your email address",
allowClear: true, allowClear: true,
showCount: true, showCount: true,
maxLength: 320, maxLength: 320,
}, },
defaultValue: (ctx) => { defaultValue: (ctx) => {
return ctx.userData.email return ctx.userData.email
}, },
onUpdate: async (value) => { onUpdate: async (value) => {
const result = await UserModel.updateData({ const result = await UserModel.updateData({
email: value email: value,
}) })
if (result) { if (result) {
return value return value
} }
}, },
debounced: true, debounced: true,
}, },
{ {
id: "avatar", id: "avatar",
group: "account.profile", group: "account.profile",
icon: "FiImage", icon: "FiImage",
title: "Avatar", title: "Avatar",
description: "Change your avatar (Upload an image or use an URL)", description: "Change your avatar (Upload an image or use an URL)",
component: loadable(() => import("../components/urlInput")), component: loadable(() => import("../components/urlInput")),
extraActions: [ extraActions: [UploadButton],
UploadButton defaultValue: (ctx) => {
], return ctx.userData.avatar
defaultValue: (ctx) => { },
return ctx.userData.avatar onUpdate: async (value) => {
}, const result = await UserModel.updateData({
onUpdate: async (value) => { avatar: value,
const result = await UserModel.updateData({ })
avatar: value
})
if (result) { if (result) {
app.message.success("Avatar updated") app.message.success("Avatar updated")
return value return value
} }
}, },
}, },
{ {
id: "cover", id: "cover",
group: "account.profile", group: "account.profile",
icon: "FiImage", icon: "FiImage",
title: "Cover", title: "Cover",
description: "Change your profile cover (Upload an image or use an URL)", description:
component: loadable(() => import("../components/urlInput")), "Change your profile cover (Upload an image or use an URL)",
extraActions: [ component: loadable(() => import("../components/urlInput")),
UploadButton extraActions: [UploadButton],
], defaultValue: (ctx) => {
defaultValue: (ctx) => { return ctx.userData.cover
return ctx.userData.cover },
}, onUpdate: async (value) => {
onUpdate: async (value) => { const result = await UserModel.updateData({
const result = await UserModel.updateData({ cover: value,
cover: value })
})
if (result) { if (result) {
app.message.success("Cover updated") app.message.success("Cover updated")
return value return value
} }
}, },
}, },
{ {
id: "description", id: "description",
group: "account.profile", group: "account.profile",
component: "TextArea", component: "TextArea",
icon: "FiEdit3", icon: "FiEdit3",
title: "Description", title: "Description",
description: "Change your description for your profile", description: "Change your description for your profile",
props: { props: {
placeholder: "Enter here a description for your profile", placeholder: "Enter here a description for your profile",
maxLength: 320, maxLength: 320,
showCount: true, showCount: true,
allowClear: true allowClear: true,
}, },
defaultValue: (ctx) => { defaultValue: (ctx) => {
return ctx.userData.description return ctx.userData.description
}, },
onUpdate: async (value) => { onUpdate: async (value) => {
const result = await UserModel.updateData({ const result = await UserModel.updateData({
description: value description: value,
}) })
if (result) { if (result) {
return value return value
} }
}, },
debounced: true, debounced: true,
}, },
{ {
id: "Links", id: "Links",
group: "account.profile", group: "account.profile",
component: loadable(() => import("../components/profileLinks")), component: loadable(() => import("../components/profileLinks")),
icon: "MdLink", icon: "MdLink",
title: "Links", title: "Links",
description: "Add links to your profile", description: "Add links to your profile",
onUpdate: async (value) => { onUpdate: async (value) => {
// filter invalid links // filter invalid links
value = value.filter((link) => { value = value.filter((link) => {
return link.key && link.value return link.key && link.value
}) })
const result = await UserModel.updateData({ const result = await UserModel.updateData({
links: value links: value,
}) })
if (result) { if (result) {
return result.links return result.links
} }
}, },
defaultValue: (ctx) => { defaultValue: (ctx) => {
return ctx.userData.links ?? [] return ctx.userData.links ?? []
}, },
debounced: true, debounced: true,
} },
] ],
} }