rework boost visibility #388
* only show allowed visibilities * "local only" is a switch notice that the backend will limit the visibility, too
This commit is contained in:
parent
be36a793cd
commit
aa72db76c4
9 changed files with 118 additions and 298 deletions
|
|
@ -265,6 +265,7 @@ import MkUserCardMini from '@/components/MkUserCardMini.vue';
|
|||
import MkPagination, { type Paging } from '@/components/MkPagination.vue';
|
||||
import MkReactionIcon from '@/components/MkReactionIcon.vue';
|
||||
import MkButton from '@/components/MkButton.vue';
|
||||
import { boostMenuItems, type Visibility } from '@/scripts/boost-quote.js';
|
||||
|
||||
const props = defineProps<{
|
||||
note: Misskey.entities.Note;
|
||||
|
|
@ -438,57 +439,15 @@ useTooltip(quoteButton, async (showing) => {
|
|||
}, {}, 'closed');
|
||||
});
|
||||
|
||||
type Visibility = 'public' | 'home' | 'followers' | 'specified';
|
||||
|
||||
function smallerVisibility(a: Visibility | string, b: Visibility | string): Visibility {
|
||||
if (a === 'specified' || b === 'specified') return 'specified';
|
||||
if (a === 'followers' || b === 'followers') return 'followers';
|
||||
if (a === 'home' || b === 'home') return 'home';
|
||||
// if (a === 'public' || b === 'public')
|
||||
return 'public';
|
||||
}
|
||||
|
||||
function boostVisibility() {
|
||||
if (!defaultStore.state.showVisibilitySelectorOnBoost) {
|
||||
renote(defaultStore.state.visibilityOnBoost);
|
||||
} else {
|
||||
os.popupMenu([
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'ph-globe-hemisphere-west ph-bold ph-lg',
|
||||
text: i18n.ts._visibility['public'],
|
||||
action: () => {
|
||||
renote('public');
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'ph-house ph-bold ph-lg',
|
||||
text: i18n.ts._visibility['home'],
|
||||
action: () => {
|
||||
renote('home');
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'ph-lock ph-bold ph-lg',
|
||||
text: i18n.ts._visibility['followers'],
|
||||
action: () => {
|
||||
renote('followers');
|
||||
},
|
||||
},
|
||||
{
|
||||
type: 'button',
|
||||
icon: 'ph-planet ph-bold ph-lg',
|
||||
text: i18n.ts._timelines.local,
|
||||
action: () => {
|
||||
renote('local');
|
||||
},
|
||||
}], renoteButton.value);
|
||||
os.popupMenu(boostMenuItems(appearNote, renote), renoteButton.value);
|
||||
}
|
||||
}
|
||||
|
||||
function renote(visibility: Visibility | 'local') {
|
||||
function renote(visibility: Visibility, localOnly: boolean = false) {
|
||||
pleaseLogin();
|
||||
showMovedDialog();
|
||||
|
||||
|
|
@ -517,17 +476,9 @@ function renote(visibility: Visibility | 'local') {
|
|||
os.popup(MkRippleEffect, { x, y }, {}, 'end');
|
||||
}
|
||||
|
||||
const configuredVisibility = defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility;
|
||||
const localOnlySetting = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly;
|
||||
|
||||
let noteVisibility = visibility === 'local' || visibility === 'specified' ? smallerVisibility(appearNote.value.visibility, configuredVisibility) : smallerVisibility(visibility, configuredVisibility);
|
||||
if (appearNote.value.channel?.isSensitive) {
|
||||
noteVisibility = smallerVisibility(visibility === 'local' || visibility === 'specified' ? appearNote.value.visibility : visibility, 'home');
|
||||
}
|
||||
|
||||
misskeyApi('notes/create', {
|
||||
localOnly: visibility === 'local' ? true : localOnlySetting,
|
||||
visibility: noteVisibility,
|
||||
localOnly: localOnly,
|
||||
visibility: visibility,
|
||||
renoteId: appearNote.value.id,
|
||||
}).then(() => {
|
||||
os.toast(i18n.ts.renoted);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue