1
1
mirror of https://github.com/kokonect-link/cherrypick synced 2025-01-19 16:23:08 +09:00
This commit is contained in:
NoriDev 2023-10-31 18:47:51 +09:00
parent 2842583fb8
commit a44118998d
7 changed files with 49 additions and 46 deletions

View File

@ -11,8 +11,8 @@ import { NoteUpdateService } from '@/core/NoteUpdateService.js';
import { DI } from '@/di-symbols.js'; import { DI } from '@/di-symbols.js';
import { GetterService } from '@/server/api/GetterService.js'; import { GetterService } from '@/server/api/GetterService.js';
import { MAX_NOTE_TEXT_LENGTH } from '@/const.js'; import { MAX_NOTE_TEXT_LENGTH } from '@/const.js';
import type { DriveFilesRepository, MiDriveFile } from '@/models/_.js';
import { ApiError } from '../../error.js'; import { ApiError } from '../../error.js';
import type { DriveFilesRepository, MiDriveFile } from "@/models/_.js";
export const meta = { export const meta = {
tags: ['notes'], tags: ['notes'],
@ -114,7 +114,6 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
throw new ApiError(meta.errors.noSuchNote); throw new ApiError(meta.errors.noSuchNote);
} }
let files: MiDriveFile[] = []; let files: MiDriveFile[] = [];
const fileIds = ps.fileIds ?? ps.mediaIds ?? null; const fileIds = ps.fileIds ?? ps.mediaIds ?? null;
if (fileIds != null) { if (fileIds != null) {

View File

@ -172,8 +172,11 @@ export default class Stream extends EventEmitter<StreamEvents> {
* ! JSONで行われます ! * ! JSONで行われます !
*/ */
public send(typeOrPayload: string): void public send(typeOrPayload: string): void
public send(typeOrPayload: string, payload: any): void public send(typeOrPayload: string, payload: any): void
public send(typeOrPayload: Record<string, any> | any[]): void public send(typeOrPayload: Record<string, any> | any[]): void
public send(typeOrPayload: string | Record<string, any> | any[], payload?: any): void { public send(typeOrPayload: string | Record<string, any> | any[], payload?: any): void {
if (typeof typeOrPayload === 'string') { if (typeof typeOrPayload === 'string') {
this.stream.send(JSON.stringify({ this.stream.send(JSON.stringify({

View File

@ -54,7 +54,7 @@ watch(() => props.lang, (to) => {
return new Promise((resolve) => { return new Promise((resolve) => {
fetchLanguage(to).then(() => resolve); fetchLanguage(to).then(() => resolve);
}); });
}, { immediate: true, }); }, { immediate: true });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -26,42 +26,42 @@ SPDX-License-Identifier: AGPL-3.0-only
</section> </section>
<!-- フォルダの中にはカスタム絵文字やフォルダがある --> <!-- フォルダの中にはカスタム絵文字やフォルダがある -->
<section v-else v-panel style="border-radius: 6px; border-bottom: 0.5px solid var(--divider);"> <section v-else v-panel style="border-radius: 6px; border-bottom: 0.5px solid var(--divider);">
<header class="_acrylic" @click="shown = !shown"> <header class="_acrylic" @click="shown = !shown">
<i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-folder ti-fw"></i>:{{ customEmojiTree.length }} <i class="ti ti-icons ti-fw"></i>:{{ emojis.length }}) <i class="toggle ti-fw" :class="shown ? 'ti ti-chevron-down' : 'ti ti-chevron-up'"></i> <slot></slot> (<i class="ti ti-folder ti-fw"></i>:{{ customEmojiTree.length }} <i class="ti ti-icons ti-fw"></i>:{{ emojis.length }})
</header> </header>
<div v-if="shown" style="padding-left: 9px;"> <div v-if="shown" style="padding-left: 9px;">
<MkEmojiPickerSection <MkEmojiPickerSection
v-for="child in customEmojiTree" v-for="child in customEmojiTree"
:key="`custom:${child.value}`" :key="`custom:${child.value}`"
:initialShown="initialShown" :initialShown="initialShown"
:emojis="computed(() => customEmojis.filter(e => e.category === child.category).map(e => `:${e.name}:`))" :emojis="computed(() => customEmojis.filter(e => e.category === child.category).map(e => `:${e.name}:`))"
:hasChildSection="child.children.length !== 0" :hasChildSection="child.children.length !== 0"
:customEmojiTree="child.children" :customEmojiTree="child.children"
@chosen="nestedChosen" @chosen="nestedChosen"
> >
{{ child.value || i18n.ts.other }} {{ child.value || i18n.ts.other }}
</MkEmojiPickerSection> </MkEmojiPickerSection>
</div> </div>
<div v-if="shown" class="body"> <div v-if="shown" class="body">
<button <button
v-for="emoji in emojis" v-for="emoji in emojis"
:key="emoji" :key="emoji"
:data-emoji="emoji" :data-emoji="emoji"
class="_button item" class="_button item"
@pointerenter="computeButtonTitle" @pointerenter="computeButtonTitle"
@click="emit('chosen', emoji, $event)" @click="emit('chosen', emoji, $event)"
> >
<MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/> <MkCustomEmoji v-if="emoji[0] === ':'" class="emoji" :name="emoji" :normal="true"/>
<MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/> <MkEmoji v-else class="emoji" :emoji="emoji" :normal="true"/>
</button> </button>
</div> </div>
</section> </section>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { ref, computed, Ref } from 'vue'; import { ref, computed, Ref } from 'vue';
import { CustomEmojiFolderTree, getEmojiName } from '@/scripts/emojilist.js';
import { i18n } from '../i18n.js'; import { i18n } from '../i18n.js';
import { CustomEmojiFolderTree, getEmojiName } from '@/scripts/emojilist.js';
import { customEmojis } from '@/custom-emojis.js'; import { customEmojis } from '@/custom-emojis.js';
import MkEmojiPickerSection from '@/components/MkEmojiPicker.section.vue'; import MkEmojiPickerSection from '@/components/MkEmojiPicker.section.vue';

View File

@ -78,8 +78,8 @@ SPDX-License-Identifier: AGPL-3.0-only
:key="`custom:${child.value}`" :key="`custom:${child.value}`"
:initialShown="false" :initialShown="false"
:emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))" :emojis="computed(() => customEmojis.filter(e => child.value === '' ? (e.category === 'null' || !e.category) : e.category === child.value).filter(filterAvailable).map(e => `:${e.name}:`))"
:hasChildSection="child.children.length !== 0" :hasChildSection="child.children.length !== 0"
:customEmojiTree="child.children" :customEmojiTree="child.children"
@chosen="chosen" @chosen="chosen"
> >
{{ child.value || i18n.ts.other }} {{ child.value || i18n.ts.other }}
@ -104,12 +104,12 @@ import { ref, shallowRef, computed, watch, onMounted } from 'vue';
import * as Misskey from 'cherrypick-js'; import * as Misskey from 'cherrypick-js';
import XSection from '@/components/MkEmojiPicker.section.vue'; import XSection from '@/components/MkEmojiPicker.section.vue';
import { import {
emojilist, emojilist,
emojiCharByCategory, emojiCharByCategory,
UnicodeEmojiDef, UnicodeEmojiDef,
unicodeEmojiCategories as categories, unicodeEmojiCategories as categories,
getEmojiName, getEmojiName,
CustomEmojiFolderTree CustomEmojiFolderTree,
} from '@/scripts/emojilist.js'; } from '@/scripts/emojilist.js';
import MkRippleEffect from '@/components/MkRippleEffect.vue'; import MkRippleEffect from '@/components/MkRippleEffect.vue';
import * as os from '@/os.js'; import * as os from '@/os.js';
@ -154,7 +154,7 @@ const searchResultCustom = ref<Misskey.entities.CustomEmoji[]>([]);
const searchResultUnicode = ref<UnicodeEmojiDef[]>([]); const searchResultUnicode = ref<UnicodeEmojiDef[]>([]);
const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index'); const tab = ref<'index' | 'custom' | 'unicode' | 'tags'>('index');
const customEmojiFolderRoot: CustomEmojiFolderTree = { value: "", category: "", children: [] }; const customEmojiFolderRoot: CustomEmojiFolderTree = { value: '', category: '', children: [] };
function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree { function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): CustomEmojiFolderTree {
const parts = input.split('/').map(p => p.trim()); const parts = input.split('/').map(p => p.trim());
@ -176,9 +176,9 @@ function parseAndMergeCategories(input: string, root: CustomEmojiFolderTree): Cu
} }
customEmojiCategories.value.forEach(ec => { customEmojiCategories.value.forEach(ec => {
if (ec !== null) { if (ec !== null) {
parseAndMergeCategories(ec, customEmojiFolderRoot); parseAndMergeCategories(ec, customEmojiFolderRoot);
} }
}); });
parseAndMergeCategories('', customEmojiFolderRoot); parseAndMergeCategories('', customEmojiFolderRoot);

View File

@ -11,7 +11,7 @@ import { url } from '@/config.js';
let stream: Misskey.Stream | null = null; let stream: Misskey.Stream | null = null;
let timeoutHeartBeat: number | null = null; let timeoutHeartBeat: number | null = null;
export let isReloading: boolean = false; export let isReloading = false;
export function useStream(): Misskey.Stream { export function useStream(): Misskey.Stream {
if (stream) return stream; if (stream) return stream;

View File

@ -28,6 +28,7 @@ const hash = (str: string, seed = 0): number => {
}; };
const BASE62_DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; const BASE62_DIGITS = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
function toBase62(n: number): string { function toBase62(n: number): string {
if (n === 0) { if (n === 0) {
return '0'; return '0';