From fb75282ea8c71fd4dfc08c885fe099f2f1e2baba Mon Sep 17 00:00:00 2001 From: Mar0xy Date: Mon, 4 Dec 2023 00:19:34 +0100 Subject: [PATCH] add: choose boost visibility when clicking boost Closes transfem-org/Sharkey#195 --- packages/frontend/src/components/MkNote.vue | 51 +++++++++++++++--- .../src/components/MkNoteDetailed.vue | 53 +++++++++++++++---- .../frontend/src/components/MkNoteSub.vue | 42 ++++++++++++++- packages/frontend/src/components/SkNote.vue | 51 +++++++++++++++--- .../src/components/SkNoteDetailed.vue | 51 +++++++++++++++--- .../frontend/src/components/SkNoteSub.vue | 42 ++++++++++++++- 6 files changed, 253 insertions(+), 37 deletions(-) diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue index e17f4b355a..b6d0d1af0a 100644 --- a/packages/frontend/src/components/MkNote.vue +++ b/packages/frontend/src/components/MkNote.vue @@ -114,7 +114,7 @@ SPDX-License-Identifier: AGPL-3.0-only class="_button" :style="renoted ? 'color: var(--accent) !important;' : ''" v-on:click.stop - @mousedown="renoted ? undoRenote(appearNote) : renote()" + @mousedown="renoted ? undoRenote(appearNote) : boostVisibility()" >

{{ appearNote.renoteCount }}

@@ -379,7 +379,43 @@ function smallerVisibility(a: Visibility | string, b: Visibility | string): Visi return 'public'; } -function renote() { +function boostVisibility() { + 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); +} + +function renote(visibility: Visibility | 'local') { pleaseLogin(); showMovedDialog(); @@ -411,18 +447,17 @@ function renote() { } const configuredVisibility = defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility; - const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; + const localOnlySetting = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; - let visibility = appearNote.visibility; - visibility = smallerVisibility(visibility, configuredVisibility); + let noteVisibility = visibility === 'local' ? smallerVisibility(appearNote.visibility, configuredVisibility) : smallerVisibility(visibility, configuredVisibility); if (appearNote.channel?.isSensitive) { - visibility = smallerVisibility(visibility, 'home'); + noteVisibility = smallerVisibility(visibility === 'local' ? appearNote.visibility : visibility, 'home'); } if (!props.mock) { os.api('notes/create', { - localOnly, - visibility, + localOnly: visibility === 'local' ? true : localOnlySetting, + visibility: noteVisibility, renoteId: appearNote.id, }).then(() => { os.toast(i18n.ts.renoted); diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue index a6baeb6e1f..ec60620208 100644 --- a/packages/frontend/src/components/MkNoteDetailed.vue +++ b/packages/frontend/src/components/MkNoteDetailed.vue @@ -124,7 +124,7 @@ SPDX-License-Identifier: AGPL-3.0-only class="_button" :class="$style.noteFooterButton" :style="renoted ? 'color: var(--accent) !important;' : ''" - @mousedown="renoted ? undoRenote() : renote()" + @mousedown="renoted ? undoRenote() : boostVisibility()" >

{{ appearNote.renoteCount }}

@@ -427,7 +427,43 @@ function smallerVisibility(a: Visibility | string, b: Visibility | string): Visi return 'public'; } -function renote() { +function boostVisibility() { + 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); +} + +function renote(visibility: Visibility | 'local') { pleaseLogin(); showMovedDialog(); @@ -457,17 +493,16 @@ function renote() { } const configuredVisibility = defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility; - const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; + const localOnlySetting = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; - let visibility = appearNote.visibility; - visibility = smallerVisibility(visibility, configuredVisibility); + let noteVisibility = visibility === 'local' ? smallerVisibility(appearNote.visibility, configuredVisibility) : smallerVisibility(visibility, configuredVisibility); if (appearNote.channel?.isSensitive) { - visibility = smallerVisibility(visibility, 'home'); + noteVisibility = smallerVisibility(visibility === 'local' ? appearNote.visibility : visibility, 'home'); } - + os.api('notes/create', { - localOnly, - visibility, + localOnly: visibility === 'local' ? true : localOnlySetting, + visibility: noteVisibility, renoteId: appearNote.id, }).then(() => { os.toast(i18n.ts.renoted); diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue index 5c08c3adc4..ce95444bc2 100644 --- a/packages/frontend/src/components/MkNoteSub.vue +++ b/packages/frontend/src/components/MkNoteSub.vue @@ -31,7 +31,7 @@ SPDX-License-Identifier: AGPL-3.0-only class="_button" :class="$style.noteFooterButton" :style="renoted ? 'color: var(--accent) !important;' : ''" - @mousedown="renoted ? undoRenote() : renote()" + @mousedown="renoted ? undoRenote() : boostVisibility()" >

{{ note.renoteCount }}

@@ -252,7 +252,43 @@ watch(() => props.expandAllCws, (expandAllCws) => { let replies: Misskey.entities.Note[] = $ref([]); -function renote() { +function boostVisibility() { + 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); +} + +function renote(visibility: 'public' | 'home' | 'followers' | 'specified' | 'local') { pleaseLogin(); showMovedDialog(); @@ -283,6 +319,8 @@ function renote() { os.api('notes/create', { renoteId: props.note.id, + localOnly: visibility === 'local' ? true : false, + visibility: visibility === 'local' ? props.note.visibility : visibility, }).then(() => { os.toast(i18n.ts.renoted); renoted.value = true; diff --git a/packages/frontend/src/components/SkNote.vue b/packages/frontend/src/components/SkNote.vue index 349304db45..5bad52040e 100644 --- a/packages/frontend/src/components/SkNote.vue +++ b/packages/frontend/src/components/SkNote.vue @@ -116,7 +116,7 @@ SPDX-License-Identifier: AGPL-3.0-only class="_button" :style="renoted ? 'color: var(--accent) !important;' : ''" v-on:click.stop - @mousedown="renoted ? undoRenote(appearNote) : renote()" + @mousedown="renoted ? undoRenote(appearNote) : boostVisibility()" >

{{ appearNote.renoteCount }}

@@ -380,7 +380,43 @@ function smallerVisibility(a: Visibility | string, b: Visibility | string): Visi return 'public'; } -function renote() { +function boostVisibility() { + 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); +} + +function renote(visibility: Visibility | 'local') { pleaseLogin(); showMovedDialog(); @@ -412,18 +448,17 @@ function renote() { } const configuredVisibility = defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility; - const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; + const localOnlySetting = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; - let visibility = appearNote.visibility; - visibility = smallerVisibility(visibility, configuredVisibility); + let noteVisibility = visibility === 'local' ? smallerVisibility(appearNote.visibility, configuredVisibility) : smallerVisibility(visibility, configuredVisibility); if (appearNote.channel?.isSensitive) { - visibility = smallerVisibility(visibility, 'home'); + noteVisibility = smallerVisibility(visibility === 'local' ? appearNote.visibility : visibility, 'home'); } if (!props.mock) { os.api('notes/create', { - localOnly, - visibility, + localOnly: visibility === 'local' ? true : localOnlySetting, + visibility: noteVisibility, renoteId: appearNote.id, }).then(() => { os.toast(i18n.ts.renoted); diff --git a/packages/frontend/src/components/SkNoteDetailed.vue b/packages/frontend/src/components/SkNoteDetailed.vue index 79d279aaed..85a6ed45ef 100644 --- a/packages/frontend/src/components/SkNoteDetailed.vue +++ b/packages/frontend/src/components/SkNoteDetailed.vue @@ -132,7 +132,7 @@ SPDX-License-Identifier: AGPL-3.0-only class="_button" :class="$style.noteFooterButton" :style="renoted ? 'color: var(--accent) !important;' : ''" - @mousedown="renoted ? undoRenote() : renote()" + @mousedown="renoted ? undoRenote() : boostVisibility()" >

{{ appearNote.renoteCount }}

@@ -435,7 +435,43 @@ function smallerVisibility(a: Visibility | string, b: Visibility | string): Visi return 'public'; } -function renote() { +function boostVisibility() { + 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); +} + +function renote(visibility: Visibility | 'local') { pleaseLogin(); showMovedDialog(); @@ -465,17 +501,16 @@ function renote() { } const configuredVisibility = defaultStore.state.rememberNoteVisibility ? defaultStore.state.visibility : defaultStore.state.defaultNoteVisibility; - const localOnly = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; + const localOnlySetting = defaultStore.state.rememberNoteVisibility ? defaultStore.state.localOnly : defaultStore.state.defaultNoteLocalOnly; - let visibility = appearNote.visibility; - visibility = smallerVisibility(visibility, configuredVisibility); + let noteVisibility = visibility === 'local' ? smallerVisibility(appearNote.visibility, configuredVisibility) : smallerVisibility(visibility, configuredVisibility); if (appearNote.channel?.isSensitive) { - visibility = smallerVisibility(visibility, 'home'); + noteVisibility = smallerVisibility(visibility === 'local' ? appearNote.visibility : visibility, 'home'); } os.api('notes/create', { - localOnly, - visibility, + localOnly: visibility === 'local' ? true : localOnlySetting, + visibility: noteVisibility, renoteId: appearNote.id, }).then(() => { os.toast(i18n.ts.renoted); diff --git a/packages/frontend/src/components/SkNoteSub.vue b/packages/frontend/src/components/SkNoteSub.vue index c537fc902b..cc44f42177 100644 --- a/packages/frontend/src/components/SkNoteSub.vue +++ b/packages/frontend/src/components/SkNoteSub.vue @@ -39,7 +39,7 @@ SPDX-License-Identifier: AGPL-3.0-only class="_button" :class="$style.noteFooterButton" :style="renoted ? 'color: var(--accent) !important;' : ''" - @mousedown="renoted ? undoRenote() : renote()" + @mousedown="renoted ? undoRenote() : boostVisibility()" >

{{ note.renoteCount }}

@@ -261,7 +261,43 @@ watch(() => props.expandAllCws, (expandAllCws) => { let replies: Misskey.entities.Note[] = $ref([]); -function renote() { +function boostVisibility() { + 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); +} + +function renote(visibility: 'public' | 'home' | 'followers' | 'specified' | 'local') { pleaseLogin(); showMovedDialog(); @@ -292,6 +328,8 @@ function renote() { os.api('notes/create', { renoteId: props.note.id, + localOnly: visibility === 'local' ? true : false, + visibility: visibility === 'local' ? props.note.visibility : visibility, }).then(() => { os.toast(i18n.ts.renoted); renoted.value = true;