Skip to content

Commit

Permalink
spec(profile): 相互リンクバナーのサイズ変更・ID付与 (#696)
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid authored Aug 14, 2024
1 parent 2896ff3 commit 4c6e594
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions packages/backend/src/models/UserProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class MiUserProfile {
public mutualLinkSections: {
name: string | null;
mutualLinks: {
id: string;
fileId: MiDriveFile['id'];
description: string | null;
imgSrc: string;
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/models/json-schema/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,13 @@ export const packedUserDetailedNotMeOnlySchema = {
items: {
type: 'object',
properties: {
id: { type: 'string', format: 'misskey:id' },
url: { type: 'string' },
fileId: { type: 'string', format: 'misskey:id' },
description: { type: 'string', nullable: true },
imgSrc: { type: 'string' },
},
required: ['url', 'fileId'],
required: ['id', 'url', 'fileId'],
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions packages/backend/src/server/api/endpoints/i/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { AvatarDecorationService } from '@/core/AvatarDecorationService.js';
import { notificationRecieveConfig } from '@/models/json-schema/user.js';
import { ApiLoggerService } from '../../ApiLoggerService.js';
import { ApiError } from '../../error.js';
import { IdService } from "@/core/IdService.js";

export const meta = {
tags: ['account'],
Expand Down Expand Up @@ -268,6 +269,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
@Inject(DI.pagesRepository)
private pagesRepository: PagesRepository,

private idService: IdService,
private userEntityService: UserEntityService,
private driveFileEntityService: DriveFileEntityService,
private globalEventService: GlobalEventService,
Expand Down Expand Up @@ -377,6 +379,7 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
}

return {
id: this.idService.gen(),
url: mutualLink.url,
fileId: file.id,
imgSrc: this.driveFileEntityService.getPublicUrl(file),
Expand Down
12 changes: 7 additions & 5 deletions packages/frontend/src/pages/settings/profile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>

<script lang="ts" setup>
import { computed, reactive, ref, watch, defineAsyncComponent, Ref } from 'vue';
import { computed, reactive, ref, watch, defineAsyncComponent } from 'vue';
import MkButton from '@/components/MkButton.vue';
import MkInput from '@/components/MkInput.vue';
import MkSwitch from '@/components/MkSwitch.vue';
Expand All @@ -202,7 +202,6 @@ import { defaultStore } from '@/store.js';
import { globalEvents } from '@/events.js';
import MkInfo from '@/components/MkInfo.vue';
import MkTextarea from '@/components/MkTextarea.vue';
import * as Misskey from "misskey-js";
const $i = signinRequired();
Expand All @@ -225,7 +224,7 @@ watch(() => profile, () => {
deep: true,
});
const mutualLinkSections = ref($i.mutualLinkSections ?? []) as Ref<Misskey.entities.UserDetailed['mutualLinkSections']>;
const mutualLinkSections = ref($i.mutualLinkSections.map(section => ({ ...section, id: Math.random().toString(), none: !section.name })) ?? []);
const fields = ref($i.fields.map(field => ({ id: Math.random().toString(), name: field.name, value: field.value })) ?? []);
const fieldEditMode = ref(false);
const mutualLinkSectionEditMode = ref(false);
Expand All @@ -240,6 +239,7 @@ function addField() {
function addMutualLinks(index:number) {
mutualLinkSections.value[index].mutualLinks.push({
id: Math.random().toString(),
fileId: '',
url: '',
imgSrc: '',
Expand All @@ -249,7 +249,9 @@ function addMutualLinks(index:number) {
function addMutualLinkSections() {
mutualLinkSections.value.push({
id: Math.random().toString(),
name: 'New Section',
none: false,
mutualLinks: [],
});
}
Expand Down Expand Up @@ -495,8 +497,8 @@ definePageMetadata(() => ({
}
.mutualLinkImg {
max-width: 150px;
max-height: 30px;
max-width: 200px;
max-height: 40px;
object-fit: contain;
}
Expand Down
6 changes: 3 additions & 3 deletions packages/frontend/src/pages/user/home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ SPDX-License-Identifier: AGPL-3.0-only
<div v-for="(section, index) in user?.mutualLinkSections" :key="index" :class="$style.mutualLinkSections">
<span v-if="section.name">{{ section.name }}</span>
<div :class="$style.mutualLinks">
<div v-for="(mutualLink, i) in section.mutualLinks" :key="i">
<div v-for="mutualLink in section.mutualLinks" :key="mutualLink.id">
<MkLink :hideIcon="true" :url="mutualLink.url">
<img :class="$style.mutualLinkImg" :src="mutualLink.imgSrc" :alt="mutualLink.description"/>
</MkLink>
Expand Down Expand Up @@ -832,7 +832,7 @@ onUnmounted(() => {
}
.mutualLinkImg {
max-width: 150px;
max-height: 30px;
max-width: 200px;
max-height: 40px;
}
</style>
2 changes: 2 additions & 0 deletions packages/misskey-js/src/autogen/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3845,6 +3845,8 @@ export type components = {
mutualLinkSections: ({
name: string | null;
mutualLinks: ({
/** Format: misskey:id */
id: string;
url: string;
/** Format: misskey:id */
fileId: string;
Expand Down

0 comments on commit 4c6e594

Please sign in to comment.