Merge branch 'feat/default-note-visibility'

Reviewed-on: FoundKeyGang/FoundKey#67
This commit is contained in:
Norm 2022-09-15 17:43:35 -04:00
commit d1a29ce87e
Signed by untrusted user: norm
GPG key ID: 7123E30E441E80DE
31 changed files with 51 additions and 58 deletions

View file

@ -108,7 +108,6 @@ add: "إضافة"
reaction: "التفاعلات"
reactionSetting: "التفاعلات المراد عرضها في منتقي التفاعلات."
reactionSettingDescription2: "اسحب لترتيب ، انقر للحذف ، استخدم \"+\" للإضافة."
rememberNoteVisibility: "تذكر إعدادت مدى رؤية الملاحظات"
attachCancel: "أزل المرفق"
markAsSensitive: "علّمه كمحتوى حساس"
unmarkAsSensitive: "ألغ تعيينه كمحتوى حساس"

View file

@ -108,7 +108,6 @@ add: "যুক্ত করুন"
reaction: "প্রতিক্রিয়া"
reactionSetting: "রিঅ্যাকশন পিকারে যেসকল প্রতিক্রিয়া দেখানো হবে"
reactionSettingDescription2: "পুনরায় সাজাতে টেনে আনুন, মুছতে ক্লিক করুন, যোগ করতে + টিপুন।"
rememberNoteVisibility: "নোটের দৃশ্যমান্যতার সেটিংস মনে রাখুন"
attachCancel: "অ্যাটাচমেন্ট সরান "
markAsSensitive: "সংবেদনশীল হিসাবে চিহ্নিত করুন"
unmarkAsSensitive: "সংবেদনশীল চিহ্ন সরান"

View file

@ -108,7 +108,6 @@ add: "Afegir"
reaction: "Reaccions"
reactionSetting: "Reaccions a mostrar al selector de reaccions"
reactionSettingDescription2: "Arrossega per reordenar, fes clic per suprimir, prem \"+\" per afegir."
rememberNoteVisibility: "Recorda la configuració de visibilitat de les notes"
attachCancel: "Eliminar el fitxer adjunt"
markAsSensitive: "Marcar com a NSFW"
instances: "Instàncies"

View file

@ -105,7 +105,6 @@ sensitive: "NSFW"
add: "Přidat"
reaction: "Reakce"
reactionSettingDescription2: "Přetažením změníte pořadí, kliknutím smažete, zmáčkněte \"+\" k přidání"
rememberNoteVisibility: "Zapamatovat nastavení zobrazení poznámky"
attachCancel: "Odstranit přílohu"
markAsSensitive: "Označit jako NSFW"
unmarkAsSensitive: "Odznačit jako NSFW"

View file

@ -109,7 +109,6 @@ add: "Hinzufügen"
reaction: "Reaktionen"
reactionSetting: "In der Reaktionsauswahl anzuzeigende Reaktionen"
reactionSettingDescription2: "Ziehe um Anzuordnen, klicke um zu löschen, drücke „+“ um hinzuzufügen"
rememberNoteVisibility: "Notizsichtbarkeit merken"
attachCancel: "Anhang entfernen"
markAsSensitive: "Als NSFW markieren"
unmarkAsSensitive: "Als nicht NSFW markieren"

View file

@ -109,7 +109,6 @@ add: "Add"
reaction: "Reactions"
reactionSetting: "Reactions to show in the reaction picker"
reactionSettingDescription2: "Drag to reorder, click to delete, press \"+\" to add."
rememberNoteVisibility: "Remember note visibility settings"
attachCancel: "Remove attachment"
markAsSensitive: "Mark as NSFW"
unmarkAsSensitive: "Unmark as NSFW"

View file

@ -108,7 +108,6 @@ add: "Agregar"
reaction: "Reacción"
reactionSetting: "Reacciones para mostrar en el menú de reacciones"
reactionSettingDescription2: "Arrastre para reordenar, click para borrar, apriete la tecla + para añadir."
rememberNoteVisibility: "Recordar visibilidad"
attachCancel: "Quitar adjunto"
markAsSensitive: "Marcar como sensible"
unmarkAsSensitive: "Desmarcar como sensible"

View file

@ -108,7 +108,6 @@ add: "Ajouter"
reaction: "Réactions"
reactionSetting: "Réactions à afficher dans le sélecteur de réactions"
reactionSettingDescription2: "Déplacer pour réorganiser, cliquer pour effacer, utiliser « + » pour ajouter."
rememberNoteVisibility: "Activer l'option \" se souvenir de la visibilité des notes \" vous permet de réutiliser automatiquement la visibilité utilisée lors de la publication de votre note précédente."
attachCancel: "Supprimer le fichier attaché"
markAsSensitive: "Marquer comme sensible"
unmarkAsSensitive: "Supprimer le marquage comme sensible"

View file

@ -108,7 +108,6 @@ add: "Tambahkan"
reaction: "Reaksi"
reactionSetting: "Reaksi untuk dimunculkan di bilah reaksi"
reactionSettingDescription2: "Geser untuk memindah urutkan, klik untuk menghapus, tekan \"+\" untuk menambahkan"
rememberNoteVisibility: "Ingat pengaturan visibilitas catatan"
attachCancel: "Hapus lampiran"
markAsSensitive: "Tandai sebagai konten sensitif"
unmarkAsSensitive: "Hapus tanda konten sensitif"

View file

@ -108,7 +108,6 @@ add: "Aggiungi"
reaction: "Reazione"
reactionSetting: "Reazioni visualizzate sul pannello"
reactionSettingDescription2: "Trascina per riorganizzare, clicca per cancellare, usa il pulsante \"+\" per aggiungere."
rememberNoteVisibility: "Ricordare le impostazioni di visibilità delle note"
attachCancel: "Rimuovi allegato"
markAsSensitive: "Segna come sensibile"
unmarkAsSensitive: "Segna come non sensibile"

View file

@ -109,7 +109,6 @@ add: "追加"
reaction: "リアクション"
reactionSetting: "ピッカーに表示するリアクション"
reactionSettingDescription2: "ドラッグして並び替え、クリックして削除、+を押して追加します。"
rememberNoteVisibility: "公開範囲を記憶する"
attachCancel: "添付取り消し"
markAsSensitive: "閲覧注意にする"
unmarkAsSensitive: "閲覧注意を解除する"

View file

@ -108,7 +108,6 @@ add: "増やす"
reaction: "リアクション"
reactionSetting: "Reaction that will be displayed in Picker. "
reactionSettingDescription2: "ドラッグで並び替え、クリックで削除、+を押して追加やで。"
rememberNoteVisibility: "公開範囲覚えといて"
attachCancel: "のっけるのやめる"
markAsSensitive: "ちょっとこれはアカン"
unmarkAsSensitive: "そこまでアカンことないやろ"

View file

@ -108,7 +108,6 @@ add: "추가"
reaction: "리액션"
reactionSetting: "선택기에 표시할 리액션"
reactionSettingDescription2: "끌어서 순서 변경, 클릭해서 삭제, +를 눌러서 추가할 수 있습니다."
rememberNoteVisibility: "공개 범위를 기억하기"
attachCancel: "첨부 취소"
markAsSensitive: "열람주의로 설정"
unmarkAsSensitive: "열람주의 해제"

View file

@ -108,7 +108,6 @@ sensitive: "NSFW"
add: "Toevoegen"
reaction: "Reacties"
reactionSettingDescription2: "Sleep om opnieuw te ordenen, Klik om te verwijderen, Druk op \"+\" om toe te voegen"
rememberNoteVisibility: "Vergeet niet de notitie zichtbaarheidsinstellingen"
attachCancel: "Verwijder bijlage"
markAsSensitive: "Markeren als NSFW"
unmarkAsSensitive: "Geen NSFW"

View file

@ -108,7 +108,6 @@ add: "Dodaj"
reaction: "Reakcja"
reactionSetting: "Reakcje do pokazania w wyborniku reakcji"
reactionSettingDescription2: "Przeciągnij aby zmienić kolejność, naciśnij aby usunąć, naciśnij „+” aby dodać"
rememberNoteVisibility: "Zapamiętuj ustawienia widoczności wpisu"
attachCancel: "Usuń załącznik"
markAsSensitive: "Oznacz jako NSFW"
unmarkAsSensitive: "Cofnij NSFW"

View file

@ -106,7 +106,6 @@ sensitive: "Conteúdo sensível"
add: "Adicionar"
reaction: "Reações"
reactionSetting: "Quais reações a mostrar no selecionador de reações"
rememberNoteVisibility: "Lembrar das configurações de visibilidade de notas"
attachCancel: "Remover anexo"
markAsSensitive: "Marcar como sensível"
unmarkAsSensitive: "Desmarcar como sensível"

View file

@ -108,7 +108,6 @@ add: "Adaugă"
reaction: "Reacție"
reactionSetting: "Reacții care să apară in selectorul de reacții"
reactionSettingDescription2: "Trage pentru a rearanja, apasă pe \"+\" pentru a adăuga."
rememberNoteVisibility: "Amintește setarea de vizibilitate a notelor"
attachCancel: "Înlătură atașament"
markAsSensitive: "Marchează ca NSFW"
unmarkAsSensitive: "Demarchează ca NSFW"

View file

@ -108,7 +108,6 @@ add: "Добавить"
reaction: "Реакции"
reactionSetting: "Реакции, отображаемые в палитре"
reactionSettingDescription2: "Расставляйте перетаскиванием, удаляйте нажатием, добавляйте кнопкой «+»."
rememberNoteVisibility: "Запоминать видимость заметок"
attachCancel: "Удалить вложение"
markAsSensitive: "Отметить как «не для всех»"
unmarkAsSensitive: "Снять отметку «не для всех»"

View file

@ -108,7 +108,6 @@ add: "Pridať"
reaction: "Reakcie"
reactionSetting: "Reakcie zobrazené vo výbere reakcií"
reactionSettingDescription2: "Ťahaním preusporiadate, kliknutím odstránite, Stlačením \"+\" pridáte"
rememberNoteVisibility: "Zapamätať nastavenia viditeľnosti poznámky"
attachCancel: "Odstrániť prílohu"
markAsSensitive: "Označiť ako NSFW"
unmarkAsSensitive: "Odznačiť NSFW"

View file

@ -108,7 +108,6 @@ add: "Lägg till"
reaction: "Reaktioner"
reactionSetting: "Reaktioner som ska visas i reaktionsväljaren"
reactionSettingDescription2: "Dra för att omordna, klicka för att radera, tryck \"+\" för att lägga till."
rememberNoteVisibility: "Komihåg notvisningsinställningar"
attachCancel: "Ta bort bilaga"
markAsSensitive: "Markera som känsligt innehåll"
unmarkAsSensitive: "Avmarkera som känsligt innehåll"

View file

@ -108,7 +108,6 @@ add: "Додати"
reaction: "Реакції"
reactionSetting: "Налаштування реакцій"
reactionSettingDescription2: "Перемістити щоб змінити порядок, Клацнути мишою щоб видалити, Натиснути \"+\" щоб додати."
rememberNoteVisibility: "Пам’ятати параметри видимісті"
attachCancel: "Видалити вкладення"
markAsSensitive: "Позначити як NSFW"
unmarkAsSensitive: "Зняти позначку NSFW"

View file

@ -108,7 +108,6 @@ add: "Thêm"
reaction: "Biểu cảm"
reactionSetting: "Chọn những biểu cảm hiển thị"
reactionSettingDescription2: "Kéo để sắp xếp, nhấn để xóa, nhấn \"+\" để thêm."
rememberNoteVisibility: "Lưu kiểu tút mặc định"
attachCancel: "Gỡ tập tin đính kèm"
markAsSensitive: "Đánh dấu là nhạy cảm"
unmarkAsSensitive: "Bỏ đánh dấu nhạy cảm"

View file

@ -108,7 +108,6 @@ add: "添加"
reaction: "回应"
reactionSetting: "在选择器中显示的回应"
reactionSettingDescription2: "拖动重新排序,单击删除,点击 + 添加。"
rememberNoteVisibility: "保存上次设置的可见性"
attachCancel: "删除附件"
markAsSensitive: "标记为敏感内容"
unmarkAsSensitive: "取消标记为敏感内容"

View file

@ -108,7 +108,6 @@ add: "新增"
reaction: "情感"
reactionSetting: "在選擇器中顯示反應"
reactionSettingDescription2: "拖動以重新列序,點擊以刪除,按下 + 添加。"
rememberNoteVisibility: "記住貼文可見性"
attachCancel: "移除附件"
markAsSensitive: "標記為敏感內容"
unmarkAsSensitive: "取消標記為敏感內容"

View file

@ -15,9 +15,9 @@
<span v-if="localOnly" class="local-only"><i class="fas fa-biohazard"></i></span>
<button ref="visibilityButton" v-tooltip="i18n.ts.visibility" class="_button visibility" :disabled="channel != null" @click="setVisibility">
<span v-if="visibility === 'public'"><i class="fas fa-globe"></i></span>
<span v-if="visibility === 'home'"><i class="fas fa-home"></i></span>
<span v-if="visibility === 'followers'"><i class="fas fa-unlock"></i></span>
<span v-if="visibility === 'specified'"><i class="fas fa-envelope"></i></span>
<span v-else-if="visibility === 'home'"><i class="fas fa-home"></i></span>
<span v-else-if="visibility === 'followers'"><i class="fas fa-unlock"></i></span>
<span v-else-if="visibility === 'specified'"><i class="fas fa-envelope"></i></span>
</button>
<button v-tooltip="i18n.ts.previewNoteText" class="_button preview" :class="{ active: showPreview }" @click="showPreview = !showPreview"><i class="fas fa-file-code"></i></button>
<button class="submit _buttonGradate" :disabled="!canPost" data-cy-open-post-form-submit @click="post">{{ submitText }}<i :class="reply ? 'fas fa-reply' : renote ? 'fas fa-quote-right' : 'fas fa-paper-plane'"></i></button>
@ -97,7 +97,7 @@ const props = withDefaults(defineProps<{
mention?: foundkey.entities.User;
specified?: foundkey.entities.User;
initialText?: string;
initialVisibility?: typeof foundkey.noteVisibilities;
initialVisibility?: foundkey.NoteVisibility;
initialFiles?: foundkey.entities.DriveFile[];
initialLocalOnly?: boolean;
initialVisibleUsers?: foundkey.entities.User[];
@ -133,8 +133,8 @@ let poll = $ref<{
let useCw = $ref(false);
let showPreview = $ref(false);
let cw = $ref<string | null>(null);
let localOnly = $ref<boolean>(props.initialLocalOnly ?? defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly);
let visibility = $ref(props.initialVisibility ?? (defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility) as typeof foundkey.noteVisibilities[number]);
let localOnly = $ref<boolean>(props.initialLocalOnly ?? defaultStore.state.defaultNoteLocalOnly);
let visibility = $ref(props.initialVisibility ?? defaultStore.state.defaultNoteVisibility as foundkey.NoteVisibility);
let visibleUsers = $ref([]);
if (props.initialVisibleUsers) {
props.initialVisibleUsers.forEach(pushVisibleUser);
@ -255,9 +255,8 @@ if (props.channel) {
localOnly = true; // TODO:
}
//
if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visibility)) {
visibility = props.reply.visibility;
if (props.reply) {
visibility = foundkey.minVisibility(props.reply.visibility, visibility);
if (props.reply.visibility === 'specified') {
os.api('users/show', {
userIds: props.reply.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.reply.userId),
@ -273,6 +272,23 @@ if (props.reply && ['home', 'followers', 'specified'].includes(props.reply.visib
}
}
if (props.renote) {
visibility = foundkey.minVisibility(props.renote.visibility, visibility);
if (props.renote.visibility === 'specified') {
os.api('users/show', {
userIds: props.renote.visibleUserIds.filter(uid => uid !== $i.id && uid !== props.renote.userId),
}).then(users => {
users.forEach(pushVisibleUser);
});
if (props.renote.userId !== $i.id) {
os.api('users/show', { userId: props.renote.userId }).then(user => {
pushVisibleUser(user);
});
}
}
}
if (props.specified) {
visibility = 'specified';
pushVisibleUser(props.specified);
@ -383,15 +399,9 @@ function setVisibility() {
}, {
changeVisibility: v => {
visibility = v;
if (defaultStore.state.rememberNoteVisibility) {
defaultStore.set('visibility', visibility);
}
},
changeLocalOnly: v => {
localOnly = v;
if (defaultStore.state.rememberNoteVisibility) {
defaultStore.set('localOnly', localOnly);
}
},
}, 'closed');
}

View file

@ -30,8 +30,7 @@
</FormSwitch>
<FormSection>
<FormSwitch v-model="rememberNoteVisibility" class="_formBlock" @update:modelValue="save()">{{ i18n.ts.rememberNoteVisibility }}</FormSwitch>
<FormFolder v-if="!rememberNoteVisibility" class="_formBlock">
<FormFolder class="_formBlock">
<template #label>{{ i18n.ts.defaultNoteVisibility }}</template>
<template v-if="defaultNoteVisibility === 'public'" #suffix>{{ i18n.ts._visibility.public }}</template>
<template v-else-if="defaultNoteVisibility === 'home'" #suffix>{{ i18n.ts._visibility.home }}</template>
@ -73,7 +72,6 @@ let ffVisibility = $ref($i.ffVisibility);
let defaultNoteVisibility = $computed(defaultStore.makeGetterSetter('defaultNoteVisibility'));
let defaultNoteLocalOnly = $computed(defaultStore.makeGetterSetter('defaultNoteLocalOnly'));
let rememberNoteVisibility = $computed(defaultStore.makeGetterSetter('rememberNoteVisibility'));
let keepCw = $computed(defaultStore.makeGetterSetter('keepCw'));
function save() {

View file

@ -23,10 +23,6 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'account',
default: false,
},
rememberNoteVisibility: {
where: 'account',
default: false,
},
defaultNoteVisibility: {
where: 'account',
default: 'public',
@ -75,14 +71,6 @@ export const defaultStore = markRaw(new Storage('base', {
'ui',
],
},
visibility: {
where: 'deviceAccount',
default: 'public' as 'public' | 'home' | 'followers' | 'specified',
},
localOnly: {
where: 'deviceAccount',
default: false,
},
widgets: {
where: 'deviceAccount',
default: [] as {

View file

@ -1,7 +1,5 @@
export const notificationTypes = ['follow', 'mention', 'reply', 'renote', 'quote', 'reaction', 'pollVote', 'pollEnded', 'receiveFollowRequest', 'followRequestAccepted', 'groupInvited', 'app'] as const;
export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const;
export const mutedNoteReasons = ['word', 'manual', 'spam', 'other'] as const;
export const ffVisibility = ['public', 'followers', 'private'] as const;

View file

@ -1,3 +1,5 @@
import { NoteVisibility } from './visibility.js';
export type ID = string;
export type DateString = string;
@ -138,7 +140,7 @@ export type Note = {
renoteId: Note['id'];
files: DriveFile[];
fileIds: DriveFile['id'][];
visibility: 'public' | 'home' | 'followers' | 'specified';
visibility: NoteVisibility;
visibleUserIds?: User['id'][];
localOnly?: boolean;
myReaction?: string;

View file

@ -2,10 +2,14 @@ export { Endpoints } from './api.types.js';
export { default as Stream, Connection as ChannelConnection } from './streaming.js';
export { Channels } from './streaming.types.js';
export { Acct } from './acct.js';
export {
noteVisibilities,
NoteVisibility,
minVisibility,
} from './visibility.js';
export {
permissions,
notificationTypes,
noteVisibilities,
mutedNoteReasons,
ffVisibility,
} from './consts.js';

View file

@ -0,0 +1,17 @@
/**
* Possible visibilities of notes.
* Ordered most public first.
*/
export const noteVisibilities = ['public', 'home', 'followers', 'specified'] as const;
export type NoteVisibility = typeof noteVisibilities[number];
export function minVisibility(a: NoteVisibility, b: NoteVisibility): NoteVisibility {
return noteVisibilities[
// larger index means more private, so pick the largest index
Math.max(
noteVisibilities.indexOf(a),
noteVisibilities.indexOf(b),
)
];
}