Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance(frontend): 通常のノートでも、お気に入りに登録したチャンネルにリノートできるように #13855

Merged
merged 3 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
- Enhance: 通報のコメント内のリンクをクリックした際、ウィンドウで開くように
- Enhance: `Ui:C:postForm` および `Ui:C:postFormButton` に `localOnly` と `visibility` を設定できるように
- Enhance: AiScriptを0.18.0にバージョンアップ
- Enhance: 通常のノートでも、お気に入りに登録したチャンネルにリノートできるように
- Fix: 一部のページ内リンクが正しく動作しない問題を修正
- Fix: 周年の実績が閏年を考慮しない問題を修正
- Fix: ローカルURLのプレビューポップアップが左上に表示される
Expand Down
12 changes: 12 additions & 0 deletions locales/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,10 @@ export interface Locale extends ILocale {
* リノートしました。
*/
"renoted": string;
/**
* {name} にリノートしました。
*/
"renotedToX": ParameterizedString<"name">;
/**
* この投稿はリノートできません。
*/
Expand All @@ -468,6 +472,14 @@ export interface Locale extends ILocale {
* チャンネル内引用
*/
"inChannelQuote": string;
/**
* チャンネルにリノート
*/
"renoteToChannel": string;
/**
* 他のチャンネルにリノート
*/
"renoteToOtherChannel": string;
/**
* ピン留めされたノート
*/
Expand Down
3 changes: 3 additions & 0 deletions locales/ja-JP.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,14 @@ enterEmoji: "絵文字を入力"
renote: "リノート"
unrenote: "リノート解除"
renoted: "リノートしました。"
renotedToX: "{name} にリノートしました。"
cantRenote: "この投稿はリノートできません。"
cantReRenote: "リノートをリノートすることはできません。"
quote: "引用"
inChannelRenote: "チャンネル内リノート"
inChannelQuote: "チャンネル内引用"
renoteToChannel: "チャンネルにリノート"
renoteToOtherChannel: "他のチャンネルにリノート"
pinnedNote: "ピン留めされたノート"
pinned: "ピン留め"
you: "あなた"
Expand Down
38 changes: 38 additions & 0 deletions packages/frontend/src/scripts/get-note-menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ export function getRenoteMenu(props: {

const channelRenoteItems: MenuItem[] = [];
const normalRenoteItems: MenuItem[] = [];
const normalExternalChannelRenoteItems: MenuItem[] = [];

if (appearNote.channel) {
channelRenoteItems.push(...[{
Expand Down Expand Up @@ -596,12 +597,49 @@ export function getRenoteMenu(props: {
});
},
}]);

normalExternalChannelRenoteItems.push({
type: 'parent',
icon: 'ti ti-repeat',
text: appearNote.channel ? i18n.ts.renoteToOtherChannel : i18n.ts.renoteToChannel,
children: async () => {
const channels = await misskeyApi('channels/my-favorites', {
limit: 30,
});
return channels.filter((channel) => {
if (!appearNote.channelId) return true;
return channel.id !== appearNote.channelId;
}).map((channel) => ({
text: channel.name,
action: () => {
const el = props.renoteButton.value;
if (el) {
const rect = el.getBoundingClientRect();
const x = rect.left + (el.offsetWidth / 2);
const y = rect.top + (el.offsetHeight / 2);
os.popup(MkRippleEffect, { x, y }, {}, 'end');
}

if (!props.mock) {
misskeyApi('notes/create', {
renoteId: appearNote.id,
channelId: channel.id,
}).then(() => {
os.toast(i18n.tsx.renotedToX({ name: channel.name }));
});
}
},
}));
},
});
}

const renoteItems = [
...normalRenoteItems,
...(channelRenoteItems.length > 0 && normalRenoteItems.length > 0) ? [{ type: 'divider' }] as MenuItem[] : [],
...channelRenoteItems,
...(normalExternalChannelRenoteItems.length > 0 && (normalRenoteItems.length > 0 || channelRenoteItems.length > 0)) ? [{ type: 'divider' }] as MenuItem[] : [],
...normalExternalChannelRenoteItems,
];

return {
Expand Down
Loading