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 useCw = $ref(false);
|
||||||
let showPreview = $ref(false);
|
let showPreview = $ref(false);
|
||||||
let cw = $ref<string | null>(null);
|
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 localOnly = $ref<boolean>(props.initialLocalOnly ?? defaultStore.state.defaultNoteLocalOnly);
|
||||||
let visibility = $ref(props.initialVisibility ?? defaultStore.state.defaultNoteVisibility as foundkey.NoteVisibility);
|
let visibility = $ref(props.initialVisibility ?? defaultStore.state.defaultNoteVisibility as foundkey.NoteVisibility);
|
||||||
let visibleUsers = $ref([]);
|
let visibleUsers = $ref([]);
|
||||||
|
@ -251,12 +256,11 @@ if (props.reply && props.reply.text != null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.channel) {
|
if (props.channel) {
|
||||||
visibility = 'public';
|
parentLocalOnly = true; // TODO: remove when channels are federated
|
||||||
localOnly = true; // TODO: チャンネルが連合するようになった折には消す
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (props.reply) {
|
if (props.reply) {
|
||||||
visibility = foundkey.minVisibility(props.reply.visibility, visibility);
|
parentVisibility = foundkey.minVisibility(props.reply.visibility, parentVisibility);
|
||||||
if (props.reply.visibility === 'specified') {
|
if (props.reply.visibility === 'specified') {
|
||||||
os.api('users/show', {
|
os.api('users/show', {
|
||||||
userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply.userId),
|
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) {
|
if (props.renote) {
|
||||||
visibility = foundkey.minVisibility(props.renote.visibility, visibility);
|
parentVisibility = foundkey.minVisibility(props.renote.visibility, parentVisibility);
|
||||||
if (props.renote.visibility === 'specified') {
|
if (props.renote.visibility === 'specified') {
|
||||||
os.api('users/show', {
|
os.api('users/show', {
|
||||||
userIds: props.renote.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.renote.userId),
|
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) {
|
if (props.specified) {
|
||||||
visibility = 'specified';
|
parentVisibility = 'specified';
|
||||||
pushVisibleUser(props.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
|
// keep cw when reply
|
||||||
if (defaultStore.state.keepCw && props.reply && props.reply.cw) {
|
if (defaultStore.state.keepCw && props.reply && props.reply.cw) {
|
||||||
useCw = true;
|
useCw = true;
|
||||||
|
@ -393,8 +403,10 @@ function setVisibility() {
|
||||||
}
|
}
|
||||||
|
|
||||||
os.popup(defineAsyncComponent(() => import('./visibility-picker.vue')), {
|
os.popup(defineAsyncComponent(() => import('./visibility-picker.vue')), {
|
||||||
parentVisibility: visibility,
|
parentVisibility,
|
||||||
parentLocalOnly: localOnly,
|
parentLocalOnly,
|
||||||
|
currentVisibility: visibility,
|
||||||
|
currentLocalOnly: localOnly,
|
||||||
src: visibilityButton,
|
src: visibilityButton,
|
||||||
}, {
|
}, {
|
||||||
changeVisibility: v => {
|
changeVisibility: v => {
|
||||||
|
|
|
@ -53,6 +53,7 @@ const modal = $ref<InstanceType<typeof MkModal>>();
|
||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
parentVisibility: foundkey.NoteVisibility;
|
parentVisibility: foundkey.NoteVisibility;
|
||||||
parentLocalOnly: boolean;
|
parentLocalOnly: boolean;
|
||||||
|
currentVisibility: foundkey.NoteVisibility;
|
||||||
currentLocalOnly: boolean;
|
currentLocalOnly: boolean;
|
||||||
src?: HTMLElement;
|
src?: HTMLElement;
|
||||||
}>(), {
|
}>(), {
|
||||||
|
@ -64,8 +65,8 @@ const emit = defineEmits<{
|
||||||
(ev: 'closed'): void;
|
(ev: 'closed'): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
let v = $ref(props.parentVisibility);
|
let v = $ref(props.currentVisibility);
|
||||||
let localOnly = $ref(props.parentLocalOnly);
|
let localOnly = $ref(props.currentLocalOnly);
|
||||||
|
|
||||||
const disabled = foundkey.noteVisibilities.reduce((acc, visibility) => {
|
const disabled = foundkey.noteVisibilities.reduce((acc, visibility) => {
|
||||||
acc[visibility] = (visibility !== foundkey.minVisibility(visibility, props.parentVisibility));
|
acc[visibility] = (visibility !== foundkey.minVisibility(visibility, props.parentVisibility));
|
||||||
|
|
Loading…
Reference in a new issue