Skip to content

Commit

Permalink
Merge tag '2024.5.0-io.6' into host
Browse files Browse the repository at this point in the history
  • Loading branch information
u1-liquid committed Jan 12, 2025
2 parents 46d0711 + f280ce2 commit 7de0171
Show file tree
Hide file tree
Showing 24 changed files with 441 additions and 106 deletions.
2 changes: 2 additions & 0 deletions locales/en-US.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,8 @@ consentAll: "Allow All Items"
consentSelected: "Allow Selected Items"
emailAddressLogin: "Login with email address"
usernameLogin: "Login with username"
autoloadDrafts: "Automatically load drafts when opening the posting form"
drafts: "Drafts"

_bubbleGame:
howToPlay: "How to play"
Expand Down
8 changes: 8 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5330,6 +5330,14 @@ export interface Locale extends ILocale {
* ユーザー名でログイン
*/
"usernameLogin": string;
/**
* 投稿フォームを開いたときに下書きを自動で読み込む
*/
"autoloadDrafts": string;
/**
* 下書き
*/
"drafts": string;
"_bubbleGame": {
/**
* 遊び方
Expand Down
2 changes: 2 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1326,6 +1326,8 @@ consentAll: "全て許可"
consentSelected: "選択した項目のみ許可"
emailAddressLogin: "メールアドレスでログイン"
usernameLogin: "ユーザー名でログイン"
autoloadDrafts: "投稿フォームを開いたときに下書きを自動で読み込む"
drafts: "下書き"

_bubbleGame:
howToPlay: "遊び方"
Expand Down
2 changes: 2 additions & 0 deletions locales/ko-KR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,8 @@ consentAll: "모두 허용"
consentSelected: "선택한 항목만 허용"
emailAddressLogin: "이메일 주소로 로그인"
usernameLogin: "사용자명으로 로그인"
autoloadDrafts: "글 작성 시 자동으로 임시 저장된 글 불러오기"
drafts: "임시 저장"

_bubbleGame:
howToPlay: "설명"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "misskey",
"version": "2024.5.0-host.5e",
"version": "2024.5.0-host.6",
"codename": "nasubi",
"repository": {
"type": "git",
Expand Down
10 changes: 5 additions & 5 deletions packages/backend/src/core/chart/ChartManagementService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ export class ChartManagementService implements OnApplicationShutdown {
@bindThis
public async start() {
// 20分おきにメモリ情報をDBに書き込み
this.saveIntervalId = setInterval(() => {
this.saveIntervalId = setInterval(async () => {
for (const chart of this.charts) {
chart.save();
await chart.save();
}
}, 1000 * 60 * 20);
}
Expand All @@ -69,9 +69,9 @@ export class ChartManagementService implements OnApplicationShutdown {
public async dispose(): Promise<void> {
clearInterval(this.saveIntervalId);
if (process.env.NODE_ENV !== 'test') {
await Promise.all(
this.charts.map(chart => chart.save()),
);
for (const chart of this.charts) {
await chart.save();
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,18 @@ export class CleanChartsProcessorService {
public async process(): Promise<void> {
this.logger.info('Clean charts...');

await Promise.all([
this.federationChart.clean(),
this.notesChart.clean(),
this.usersChart.clean(),
this.activeUsersChart.clean(),
this.instanceChart.clean(),
this.perUserNotesChart.clean(),
this.perUserPvChart.clean(),
this.driveChart.clean(),
this.perUserReactionsChart.clean(),
this.perUserFollowingChart.clean(),
this.perUserDriveChart.clean(),
this.apRequestChart.clean(),
]);
await this.federationChart.clean();
await this.notesChart.clean();
await this.usersChart.clean();
await this.activeUsersChart.clean();
await this.instanceChart.clean();
await this.perUserNotesChart.clean();
await this.perUserPvChart.clean();
await this.driveChart.clean();
await this.perUserReactionsChart.clean();
await this.perUserFollowingChart.clean();
await this.perUserDriveChart.clean();
await this.apRequestChart.clean();

this.logger.succ('All charts successfully cleaned.');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ export class ResyncChartsProcessorService {

// TODO: ユーザーごとのチャートも更新する
// TODO: インスタンスごとのチャートも更新する
await Promise.all([
this.driveChart.resync(),
this.notesChart.resync(),
this.usersChart.resync(),
]);
await this.driveChart.resync();
await this.notesChart.resync();
await this.usersChart.resync();

this.logger.succ('All charts successfully resynced.');
}
Expand Down
26 changes: 12 additions & 14 deletions packages/backend/src/queue/processors/TickChartsProcessorService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,20 +48,18 @@ export class TickChartsProcessorService {
public async process(): Promise<void> {
this.logger.info('Tick charts...');

await Promise.all([
this.federationChart.tick(false),
this.notesChart.tick(false),
this.usersChart.tick(false),
this.activeUsersChart.tick(false),
this.instanceChart.tick(false),
this.perUserNotesChart.tick(false),
this.perUserPvChart.tick(false),
this.driveChart.tick(false),
this.perUserReactionsChart.tick(false),
this.perUserFollowingChart.tick(false),
this.perUserDriveChart.tick(false),
this.apRequestChart.tick(false),
]);
await this.federationChart.tick(false);
await this.notesChart.tick(false);
await this.usersChart.tick(false);
await this.activeUsersChart.tick(false);
await this.instanceChart.tick(false);
await this.perUserNotesChart.tick(false);
await this.perUserPvChart.tick(false);
await this.driveChart.tick(false);
await this.perUserReactionsChart.tick(false);
await this.perUserFollowingChart.tick(false);
await this.perUserDriveChart.tick(false);
await this.apRequestChart.tick(false);

this.logger.succ('All charts successfully ticked.');
}
Expand Down
9 changes: 6 additions & 3 deletions packages/backend/src/server/api/endpoints/notes/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const meta = {

res: {
type: 'object',
optional: false, nullable: false,
optional: true, nullable: false,
properties: {
createdNote: {
type: 'object',
Expand Down Expand Up @@ -207,6 +207,7 @@ export const paramDef = {
},
required: ['choices'],
},
noCreatedNote: { type: 'boolean', default: false },
},
// (re)note with text, files and poll are optional
if: {
Expand Down Expand Up @@ -281,7 +282,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
const note = await this.notesRepository.findOneBy({ id: idempotent });
if (note) {
logger.info('The request has already been processed.', { noteId: note.id });
return { createdNote: await this.noteEntityService.pack(note, me) };
if (ps.noCreatedNote) return;
else return { createdNote: await this.noteEntityService.pack(note, me) };
}
}

Expand Down Expand Up @@ -453,7 +455,8 @@ export default class extends Endpoint<typeof meta, typeof paramDef> { // eslint-
await this.redisForTimelines.set(`note:idempotent:${me.id}:${hash}`, note.id, 'EX', 60);

logger.info('Successfully created a note.', { noteId: note.id });
return {
if (ps.noCreatedNote) return;
else return {
createdNote: await this.noteEntityService.pack(note, me),
};
} catch (err) {
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/server/web/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ window.onload = async () => {

document.getElementById('submit').addEventListener('click', () => {
api('notes/create', {
text: document.getElementById('text').value
text: document.getElementById('text').value,
noCreatedNote: true,
}).then(() => {
location.reload();
});
Expand Down
183 changes: 183 additions & 0 deletions packages/frontend/src/components/MkDraftsDialog.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
<template>
<MkModalWindow
ref="dialog"
:height="500"
:width="800"
@click="done(true)"
@close="done(true)"
@closed="emit('closed')"
>
<template #header>
{{ i18n.ts.drafts }}
</template>
<div style="display: flex; flex-direction: column">
<div v-if="drafts.length === 0" class="empty">
<div class="_fullinfo">
<img :src="infoImageUrl" class="_ghost"/>
<div>{{ i18n.ts.nothing }}</div>
</div>
</div>
<div v-for="draft in drafts" :key="draft.id" :class="$style.draftItem">
<div :class="$style.draftNote" @click="selectDraft(draft.id)">
<div :class="$style.draftNoteHeader">
<div :class="$style.draftNoteDestination">
<span v-if="draft.channel" style="opacity: 0.7; padding-right: 0.5em">
<i class="ti ti-device-tv"></i> {{ draft.channel.name }}
</span>
<span v-if="draft.renote">
<i class="ti ti-quote"></i> <MkAcct :user="draft.renote.user" /> <span>{{ draft.renote.text }}</span>
</span>
<span v-else-if="draft.reply">
<i class="ti ti-arrow-back-up"></i> <MkAcct :user="draft.reply.user" /> <span>{{ draft.reply.text }}</span>
</span>
<span v-else>
<i class="ti ti-pencil"></i>
</span>
</div>
<div :class="$style.draftNoteInfo">
<MkTime :time="draft.createdAt" colored />
<span v-if="draft.visibility !== 'public'" :title="i18n.ts._visibility[draft.visibility]" style="margin-left: 0.5em">
<i v-if="draft.visibility === 'home'" class="ti ti-home"></i>
<i v-else-if="draft.visibility === 'followers'" class="ti ti-lock"></i>
<i v-else-if="draft.visibility === 'specified'" ref="specified" class="ti ti-mail"></i>
</span>
<span v-if="draft.localOnly" :title="i18n.ts._visibility['disableFederation']" style="margin-left: 0.5em">
<i class="ti ti-rocket-off"></i>
</span>
<span v-if="draft.channel" :title="draft.channel.name" style="margin-left: 0.5em">
<i class="ti ti-device-tv"></i>
</span>
</div>
</div>
<div>
<p v-if="!!draft.cw" :class="$style.draftNoteCw">
<Mfm :text="draft.cw" />
</p>
<MkSubNoteContent :class="$style.draftNoteText" :note="draft" />
</div>
</div>
<button :class="$style.delete" class="_button" @click="removeDraft(draft.id)">
<i class="ti ti-trash"></i>
</button>
</div>
</div>
</MkModalWindow>
</template>

<script lang="ts" setup>
import { onActivated, onMounted, ref, shallowRef } from 'vue';
import * as Misskey from 'misskey-js';
import { miLocalStorage } from '@/local-storage.js';
import { infoImageUrl } from '@/instance.js';
import { i18n } from '@/i18n.js';
import { $i } from '@/account.js';
import MkSubNoteContent from '@/components/MkSubNoteContent.vue';
import MkModalWindow from '@/components/MkModalWindow.vue';
import type { NoteDraftItem } from '@/types/note-draft-item.js';
const emit = defineEmits<{
(ev: 'done', v: { canceled: true } | { canceled: false; selected: string | undefined }): void;
(ev: 'closed'): void;
}>();
const dialog = shallowRef<InstanceType<typeof MkModalWindow>>();
const drafts = ref<(Misskey.entities.Note & { useCw: boolean })[]>([]);
onMounted(loadDrafts);
onActivated(loadDrafts);
function loadDrafts() {
const stored = JSON.parse(miLocalStorage.getItem('drafts') ?? '{}') as Record<string, NoteDraftItem>;
drafts.value = Object.keys(stored).map((key) => ({
...(stored[key].data as Misskey.entities.Note & { useCw: boolean }),
id: key,
createdAt: stored[key].updatedAt,
channel: stored[key].channel as Misskey.entities.Channel,
renote: stored[key].renote as Misskey.entities.Note,
reply: stored[key].reply as Misskey.entities.Note,
user: $i as Misskey.entities.User,
}));
}
function selectDraft(draft: string) {
done(false, draft);
}
function removeDraft(draft: string) {
const stored = JSON.parse(miLocalStorage.getItem('drafts') ?? '{}') as Record<string, NoteDraftItem>;
delete stored[draft];
miLocalStorage.setItem('drafts', JSON.stringify(stored));
loadDrafts();
}
function done(canceled: boolean, selected?: string): void {
emit('done', { canceled, selected } as
| { canceled: true }
| { canceled: false; selected: string | undefined });
dialog.value?.close();
}
</script>

<style lang="scss" module>
.draftItem {
display: flex;
padding: 8px 0 8px 0;
border-bottom: 1px solid var(--divider);
&:hover {
color: var(--accent);
background-color: var(--accentedBg);
}
}
.draftNote {
flex: 1;
width: calc(100% - 16px - 48px - 4px);
margin: 0 8px 0 8px;
}
.draftNoteHeader {
display: flex;
flex-wrap: nowrap;
margin-bottom: 4px;
}
.draftNoteDestination {
flex-shrink: 1;
flex-grow: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
margin-right: 4px;
}
.draftNoteInfo {
flex-shrink: 0;
margin-left: auto;
}
.draftNoteCw {
cursor: default;
display: block;
overflow-wrap: break-word;
}
.draftNoteText {
cursor: default;
}
.delete {
width: 48px;
height: 64px;
display: flex;
align-self: center;
justify-content: center;
align-items: center;
background-color: var(--buttonBg);
border-radius: 4px;
margin-right: 4px;
}
</style>
Loading

0 comments on commit 7de0171

Please sign in to comment.