fix(general): some fixes and improvements of Play visibility (#14384)
* fix(backend): missing `visibility` param in packing flash * fix(frontend): use `visibility` value got from API * enhance(frontend): change preview appearance of private Play * Update CHANGELOG.md
This commit is contained in:
		
							parent
							
								
									f50941389d
								
							
						
					
					
						commit
						01a815f8a7
					
				
					 9 changed files with 110 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -49,6 +49,7 @@ export class FlashEntityService {
 | 
			
		|||
			title: flash.title,
 | 
			
		||||
			summary: flash.summary,
 | 
			
		||||
			script: flash.script,
 | 
			
		||||
			visibility: flash.visibility,
 | 
			
		||||
			likedCount: flash.likedCount,
 | 
			
		||||
			isLiked: meId ? await this.flashLikesRepository.exists({ where: { flashId: flash.id, userId: meId } }) : undefined,
 | 
			
		||||
		});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -44,6 +44,11 @@ export const packedFlashSchema = {
 | 
			
		|||
			type: 'string',
 | 
			
		||||
			optional: false, nullable: false,
 | 
			
		||||
		},
 | 
			
		||||
		visibility: {
 | 
			
		||||
			type: 'string',
 | 
			
		||||
			optional: false, nullable: false,
 | 
			
		||||
			enum: ['private', 'public'],
 | 
			
		||||
		},
 | 
			
		||||
		likedCount: {
 | 
			
		||||
			type: 'number',
 | 
			
		||||
			optional: false, nullable: true,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,6 +3,7 @@
 | 
			
		|||
 * SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { AISCRIPT_VERSION } from '@syuilo/aiscript';
 | 
			
		||||
import type { entities } from 'misskey-js'
 | 
			
		||||
 | 
			
		||||
export function abuseUserReport() {
 | 
			
		||||
| 
						 | 
				
			
			@ -114,6 +115,40 @@ export function file(isSensitive = false) {
 | 
			
		|||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
const script = `/// @ ${AISCRIPT_VERSION}
 | 
			
		||||
 | 
			
		||||
var name = ""
 | 
			
		||||
 | 
			
		||||
Ui:render([
 | 
			
		||||
	Ui:C:textInput({
 | 
			
		||||
		label: "Your name"
 | 
			
		||||
		onInput: @(v) { name = v }
 | 
			
		||||
	})
 | 
			
		||||
	Ui:C:button({
 | 
			
		||||
		text: "Hello"
 | 
			
		||||
		onClick: @() {
 | 
			
		||||
			Mk:dialog(null, \`Hello, {name}!\`)
 | 
			
		||||
		}
 | 
			
		||||
	})
 | 
			
		||||
])
 | 
			
		||||
`;
 | 
			
		||||
 | 
			
		||||
export function flash(): entities.Flash {
 | 
			
		||||
	return {
 | 
			
		||||
		id: 'someflashid',
 | 
			
		||||
		createdAt: '2016-12-28T22:49:51.000Z',
 | 
			
		||||
		updatedAt: '2016-12-28T22:49:51.000Z',
 | 
			
		||||
		userId: 'someuserid',
 | 
			
		||||
		user: userLite(),
 | 
			
		||||
		title: 'Some Play title',
 | 
			
		||||
		summary: 'Some Play summary',
 | 
			
		||||
		script,
 | 
			
		||||
		visibility: 'public',
 | 
			
		||||
		likedCount: 0,
 | 
			
		||||
		isLiked: false,
 | 
			
		||||
	};
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export function folder(id = 'somefolderid', name = 'Some Folder', parentId: string | null = null): entities.DriveFolder {
 | 
			
		||||
	return {
 | 
			
		||||
		id,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -398,6 +398,7 @@ function toStories(component: string): Promise<string> {
 | 
			
		|||
		glob('src/components/global/Mk*.vue'),
 | 
			
		||||
		glob('src/components/global/RouterView.vue'),
 | 
			
		||||
		glob('src/components/Mk[A-E]*.vue'),
 | 
			
		||||
		glob('src/components/MkFlashPreview.vue'),
 | 
			
		||||
		glob('src/components/MkGalleryPostPreview.vue'),
 | 
			
		||||
		glob('src/components/MkSignupServerRules.vue'),
 | 
			
		||||
		glob('src/components/MkUserSetupDialog.vue'),
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -0,0 +1,53 @@
 | 
			
		|||
/*
 | 
			
		||||
 * SPDX-FileCopyrightText: syuilo and misskey-project
 | 
			
		||||
 * SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
import { StoryObj } from '@storybook/vue3';
 | 
			
		||||
import MkFlashPreview from './MkFlashPreview.vue';
 | 
			
		||||
import { flash } from './../../.storybook/fakes.js';
 | 
			
		||||
export const Public = {
 | 
			
		||||
	render(args) {
 | 
			
		||||
		return {
 | 
			
		||||
			components: {
 | 
			
		||||
				MkFlashPreview,
 | 
			
		||||
			},
 | 
			
		||||
			setup() {
 | 
			
		||||
				return {
 | 
			
		||||
					args,
 | 
			
		||||
				};
 | 
			
		||||
			},
 | 
			
		||||
			computed: {
 | 
			
		||||
				props() {
 | 
			
		||||
					return {
 | 
			
		||||
						...this.args,
 | 
			
		||||
					};
 | 
			
		||||
				},
 | 
			
		||||
			},
 | 
			
		||||
			template: '<MkFlashPreview v-bind="props" />',
 | 
			
		||||
		};
 | 
			
		||||
	},
 | 
			
		||||
	args: {
 | 
			
		||||
		flash: {
 | 
			
		||||
			...flash(),
 | 
			
		||||
			visibility: 'public',
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
	parameters: {
 | 
			
		||||
		layout: 'fullscreen',
 | 
			
		||||
	},
 | 
			
		||||
	decorators: [
 | 
			
		||||
		() => ({
 | 
			
		||||
			template: '<div style="display: flex; align-items: center; justify-content: center; height: 100vh"><div style="max-width: 700px; width: 100%; margin: 3rem"><story/></div></div>',
 | 
			
		||||
		}),
 | 
			
		||||
	],
 | 
			
		||||
} satisfies StoryObj<typeof MkFlashPreview>;
 | 
			
		||||
export const Private = {
 | 
			
		||||
	...Public,
 | 
			
		||||
	args: {
 | 
			
		||||
		flash: {
 | 
			
		||||
			...flash(),
 | 
			
		||||
			visibility: 'private',
 | 
			
		||||
		},
 | 
			
		||||
	},
 | 
			
		||||
} satisfies StoryObj<typeof MkFlashPreview>;
 | 
			
		||||
| 
						 | 
				
			
			@ -4,7 +4,7 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		|||
-->
 | 
			
		||||
 | 
			
		||||
<template>
 | 
			
		||||
<MkA :to="`/play/${flash.id}`" class="vhpxefrk _panel">
 | 
			
		||||
<MkA :to="`/play/${flash.id}`" class="vhpxefrk _panel" :class="[{ gray: flash.visibility === 'private' }]">
 | 
			
		||||
	<article>
 | 
			
		||||
		<header>
 | 
			
		||||
			<h1 :title="flash.title">{{ flash.title }}</h1>
 | 
			
		||||
| 
						 | 
				
			
			@ -22,11 +22,11 @@ SPDX-License-Identifier: AGPL-3.0-only
 | 
			
		|||
 | 
			
		||||
<script lang="ts" setup>
 | 
			
		||||
import { } from 'vue';
 | 
			
		||||
import * as Misskey from 'misskey-js';
 | 
			
		||||
import { userName } from '@/filters/user.js';
 | 
			
		||||
 | 
			
		||||
const props = defineProps<{
 | 
			
		||||
	//flash: Misskey.entities.Flash;
 | 
			
		||||
	flash: any;
 | 
			
		||||
	flash: Misskey.entities.Flash;
 | 
			
		||||
}>();
 | 
			
		||||
</script>
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -91,6 +91,12 @@ const props = defineProps<{
 | 
			
		|||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	&:global(.gray) {
 | 
			
		||||
		--c: var(--bg);
 | 
			
		||||
		background-image: linear-gradient(45deg, var(--c) 16.67%, transparent 16.67%, transparent 50%, var(--c) 50%, var(--c) 66.67%, transparent 66.67%, transparent 100%);
 | 
			
		||||
		background-size: 16px 16px;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	@media (max-width: 700px) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -369,7 +369,6 @@ const props = defineProps<{
 | 
			
		|||
}>();
 | 
			
		||||
 | 
			
		||||
const flash = ref<Misskey.entities.Flash | null>(null);
 | 
			
		||||
const visibility = ref<'private' | 'public'>('public');
 | 
			
		||||
 | 
			
		||||
if (props.id) {
 | 
			
		||||
	flash.value = await misskeyApi('flash/show', {
 | 
			
		||||
| 
						 | 
				
			
			@ -380,6 +379,7 @@ if (props.id) {
 | 
			
		|||
const title = ref(flash.value?.title ?? 'New Play');
 | 
			
		||||
const summary = ref(flash.value?.summary ?? '');
 | 
			
		||||
const permissions = ref(flash.value?.permissions ?? []);
 | 
			
		||||
const visibility = ref<'private' | 'public'>(flash.value?.visibility ?? 'public');
 | 
			
		||||
const script = ref(flash.value?.script ?? PRESET_DEFAULT);
 | 
			
		||||
 | 
			
		||||
function selectPreset(ev: MouseEvent) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -4672,6 +4672,8 @@ export type components = {
 | 
			
		|||
      title: string;
 | 
			
		||||
      summary: string;
 | 
			
		||||
      script: string;
 | 
			
		||||
      /** @enum {string} */
 | 
			
		||||
      visibility: 'private' | 'public';
 | 
			
		||||
      likedCount: number | null;
 | 
			
		||||
      isLiked?: boolean;
 | 
			
		||||
    };
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue