forked from FoundKeyGang/FoundKey
fix: allow to pick higher visibility than chosen before
If you selected a lower visibility that one would then be used as the parent visibility. Instead it is necessary to use two separate variables, one for parent and one for the preselected visibility.
This commit is contained in:
parent
3efa7046bd
commit
334368f6e2
2 changed files with 22 additions and 9 deletions
|
@ -133,6 +133,11 @@ let poll = $ref<{
|
|||
let useCw = $ref(false);
|
||||
let showPreview = $ref(false);
|
||||
let cw = $ref<string | null>(null);
|
||||
|
||||
// these define the "maximum" these parameters can be set to and will be tightened further down
|
||||
let parentLocalOnly = false;
|
||||
let parentVisibility = 'public';
|
||||
|
||||
let localOnly = $ref<boolean>(props.initialLocalOnly ?? defaultStore.state.defaultNoteLocalOnly);
|
||||
let visibility = $ref(props.initialVisibility ?? defaultStore.state.defaultNoteVisibility as foundkey.NoteVisibility);
|
||||
let visibleUsers = $ref([]);
|
||||
|
@ -251,12 +256,11 @@ if (props.reply && props.reply.text != null) {
|
|||
}
|
||||
|
||||
if (props.channel) {
|
||||
visibility = 'public';
|
||||
localOnly = true; // TODO: チャンネルが連合するようになった折には消す
|
||||
parentLocalOnly = true; // TODO: remove when channels are federated
|
||||
}
|
||||
|
||||
if (props.reply) {
|
||||
visibility = foundkey.minVisibility(props.reply.visibility, visibility);
|
||||
parentVisibility = foundkey.minVisibility(props.reply.visibility, parentVisibility);
|
||||
if (props.reply.visibility === 'specified') {
|
||||
os.api('users/show', {
|
||||
userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply.userId),
|
||||
|
@ -270,10 +274,11 @@ if (props.reply) {
|
|||
});
|
||||
}
|
||||
}
|
||||
parentLocalOnly ||= props.reply.localOnly;
|
||||
}
|
||||
|
||||
if (props.renote) {
|
||||
visibility = foundkey.minVisibility(props.renote.visibility, visibility);
|
||||
parentVisibility = foundkey.minVisibility(props.renote.visibility, parentVisibility);
|
||||
if (props.renote.visibility === 'specified') {
|
||||
os.api('users/show', {
|
||||
userIds: props.renote.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.renote.userId),
|
||||
|
@ -287,13 +292,18 @@ if (props.renote) {
|
|||
});
|
||||
}
|
||||
}
|
||||
parentLocalOnly ||= props.renote.localOnly;
|
||||
}
|
||||
|
||||
if (props.specified) {
|
||||
visibility = 'specified';
|
||||
parentVisibility = 'specified';
|
||||
pushVisibleUser(props.specified);
|
||||
}
|
||||
|
||||
// set visibility and local only defaults to minimum of preselected or allowed.
|
||||
visibility = foundkey.minVisibility(visibility, parentVisibility);
|
||||
localOnly ||= parentLocalOnly;
|
||||
|
||||
// keep cw when reply
|
||||
if (defaultStore.state.keepCw && props.reply && props.reply.cw) {
|
||||
useCw = true;
|
||||
|
@ -393,8 +403,10 @@ function setVisibility() {
|
|||
}
|
||||
|
||||
os.popup(defineAsyncComponent(() => import('./visibility-picker.vue')), {
|
||||
parentVisibility: visibility,
|
||||
parentLocalOnly: localOnly,
|
||||
parentVisibility,
|
||||
parentLocalOnly,
|
||||
currentVisibility: visibility,
|
||||
currentLocalOnly: localOnly,
|
||||
src: visibilityButton,
|
||||
}, {
|
||||
changeVisibility: v => {
|
||||
|
|
|
@ -53,6 +53,7 @@ const modal = $ref<InstanceType<typeof MkModal>>();
|
|||
const props = withDefaults(defineProps<{
|
||||
parentVisibility: foundkey.NoteVisibility;
|
||||
parentLocalOnly: boolean;
|
||||
currentVisibility: foundkey.NoteVisibility;
|
||||
currentLocalOnly: boolean;
|
||||
src?: HTMLElement;
|
||||
}>(), {
|
||||
|
@ -64,8 +65,8 @@ const emit = defineEmits<{
|
|||
(ev: 'closed'): void;
|
||||
}>();
|
||||
|
||||
let v = $ref(props.parentVisibility);
|
||||
let localOnly = $ref(props.parentLocalOnly);
|
||||
let v = $ref(props.currentVisibility);
|
||||
let localOnly = $ref(props.currentLocalOnly);
|
||||
|
||||
const disabled = foundkey.noteVisibilities.reduce((acc, visibility) => {
|
||||
acc[visibility] = (visibility !== foundkey.minVisibility(visibility, props.parentVisibility));
|
||||
|
|
Loading…
Reference in a new issue