summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMar0xy <marie@kaifa.ch>2023-11-16 00:22:12 +0100
committerMar0xy <marie@kaifa.ch>2023-11-16 00:22:12 +0100
commit490b249407e1a89b23b0afc274daed1cffb89a59 (patch)
tree69b3848c69bfae20e885d990ab1d6743a8901644
parentupd: add option to disable server disconnect warning (diff)
downloadsharkey-490b249407e1a89b23b0afc274daed1cffb89a59.tar.gz
sharkey-490b249407e1a89b23b0afc274daed1cffb89a59.tar.bz2
sharkey-490b249407e1a89b23b0afc274daed1cffb89a59.zip
upd: Allow users to change default like emoji
When users change the default like emoji in reactions tab from heart to another one it will be send out as that specific emoji. If reset back to heart it will default to the instance like emoji again which is heart by default. Closes transfem-org/Sharkey#95
-rw-r--r--packages/frontend/src/components/MkNote.vue5
-rw-r--r--packages/frontend/src/components/MkNoteDetailed.vue5
-rw-r--r--packages/frontend/src/components/MkNoteSub.vue5
-rw-r--r--packages/frontend/src/pages/settings/reaction.vue23
-rw-r--r--packages/frontend/src/store.ts4
5 files changed, 36 insertions, 6 deletions
diff --git a/packages/frontend/src/components/MkNote.vue b/packages/frontend/src/components/MkNote.vue
index 295ab64a23..8b412f79b8 100644
--- a/packages/frontend/src/components/MkNote.vue
+++ b/packages/frontend/src/components/MkNote.vue
@@ -280,6 +280,7 @@ const translating = ref(false);
const showTicker = (defaultStore.state.instanceTicker === 'always') || (defaultStore.state.instanceTicker === 'remote' && appearNote.user.instance);
const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || (appearNote.visibility === 'followers' && appearNote.userId === $i.id));
let renoteCollapsed = $ref(defaultStore.state.collapseRenotes && isRenote && (($i && ($i.id === note.userId || $i.id === appearNote.userId)) || (appearNote.myReaction != null)));
+const defaultLike = computed(() => defaultStore.state.like !== '❤️' ? defaultStore.state.like : props.meta.defaultLike);
const keymap = {
'r': () => reply(true),
@@ -513,7 +514,7 @@ function like(): void {
}
os.api('notes/reactions/create', {
noteId: appearNote.id,
- reaction: props.meta.defaultLike,
+ reaction: defaultLike.value,
});
const el = likeButton.value as HTMLElement | null | undefined;
if (el) {
@@ -534,7 +535,7 @@ function react(viaKeyboard = false): void {
os.api('notes/reactions/create', {
noteId: appearNote.id,
- reaction: props.meta.defaultLike,
+ reaction: defaultLike.value,
});
const el = reactButton.value as HTMLElement | null | undefined;
if (el) {
diff --git a/packages/frontend/src/components/MkNoteDetailed.vue b/packages/frontend/src/components/MkNoteDetailed.vue
index 88773bdf03..66eeb962f3 100644
--- a/packages/frontend/src/components/MkNoteDetailed.vue
+++ b/packages/frontend/src/components/MkNoteDetailed.vue
@@ -323,6 +323,7 @@ const conversation = ref<Misskey.entities.Note[]>([]);
const replies = ref<Misskey.entities.Note[]>([]);
const quotes = ref<Misskey.entities.Note[]>([]);
const canRenote = computed(() => ['public', 'home'].includes(appearNote.visibility) || appearNote.userId === $i.id);
+const defaultLike = computed(() => defaultStore.state.like !== '❤️' ? defaultStore.state.like : meta.defaultLike);
watch(() => props.expandAllCws, (expandAllCws) => {
if (expandAllCws !== showContent.value) showContent.value = expandAllCws;
@@ -558,7 +559,7 @@ function react(viaKeyboard = false): void {
if (appearNote.reactionAcceptance === 'likeOnly') {
os.api('notes/reactions/create', {
noteId: appearNote.id,
- reaction: meta.defaultLike,
+ reaction: defaultLike.value,
});
const el = reactButton.value as HTMLElement | null | undefined;
if (el) {
@@ -588,7 +589,7 @@ function like(): void {
showMovedDialog();
os.api('notes/reactions/create', {
noteId: appearNote.id,
- reaction: meta.defaultLike,
+ reaction: defaultLike.value,
});
const el = likeButton.value as HTMLElement | null | undefined;
if (el) {
diff --git a/packages/frontend/src/components/MkNoteSub.vue b/packages/frontend/src/components/MkNoteSub.vue
index 7b8d744d6a..85d1203831 100644
--- a/packages/frontend/src/components/MkNoteSub.vue
+++ b/packages/frontend/src/components/MkNoteSub.vue
@@ -134,6 +134,7 @@ const menuButton = shallowRef<HTMLElement>();
const likeButton = shallowRef<HTMLElement>();
let appearNote = $computed(() => isRenote ? props.note.renote as Misskey.entities.Note : props.note);
+const defaultLike = computed(() => defaultStore.state.like !== '❤️' ? defaultStore.state.like : props.meta.defaultLike);
const isRenote = (
props.note.renote != null &&
@@ -189,7 +190,7 @@ function react(viaKeyboard = false): void {
if (props.note.reactionAcceptance === 'likeOnly') {
os.api('notes/reactions/create', {
noteId: props.note.id,
- reaction: props.meta.defaultLike,
+ reaction: defaultLike.value,
});
const el = reactButton.value as HTMLElement | null | undefined;
if (el) {
@@ -219,7 +220,7 @@ function like(): void {
showMovedDialog();
os.api('notes/reactions/create', {
noteId: props.note.id,
- reaction: props.meta.defaultLike,
+ reaction: defaultLike.value,
});
const el = reactButton.value as HTMLElement | null | undefined;
if (el) {
diff --git a/packages/frontend/src/pages/settings/reaction.vue b/packages/frontend/src/pages/settings/reaction.vue
index 183d2bfb47..16ddf00a6a 100644
--- a/packages/frontend/src/pages/settings/reaction.vue
+++ b/packages/frontend/src/pages/settings/reaction.vue
@@ -23,6 +23,16 @@ SPDX-License-Identifier: AGPL-3.0-only
<template #caption>{{ i18n.ts.reactionSettingDescription2 }} <button class="_textButton" @click="preview">{{ i18n.ts.preview }}</button></template>
</FromSlot>
+ <FromSlot>
+ <template #label>Default like emoji</template>
+ <MkCustomEmoji v-if="like.startsWith(':')" style="max-height: 3em; font-size: 1.1em;" :useOriginalSize="false" :class="$style.reaction" :name="like" :normal="true" :noStyle="true"/>
+ <MkEmoji v-else :emoji="like" style="max-height: 3em; font-size: 1.1em;" :normal="true" :noStyle="true"/>
+ <div class="_gaps_s" style="padding-top: 8px;">
+ <MkButton rounded :small="true" @click="chooseNewLike"><i class="ph-smiley ph-bold ph-lg"></i> Change</MkButton>
+ <MkButton rounded :small="true" @click="resetLike"><i class="ph-arrow-clockwise ph-bold ph-lg"></i> Reset</MkButton>
+ </div>
+ </FromSlot>
+
<MkRadios v-model="reactionPickerSize">
<template #label>{{ i18n.ts.size }}</template>
<option :value="1">{{ i18n.ts.small }}</option>
@@ -74,6 +84,7 @@ import { definePageMetadata } from '@/scripts/page-metadata.js';
import { deepClone } from '@/scripts/clone.js';
let reactions = $ref(deepClone(defaultStore.state.reactions));
+const like = $computed(defaultStore.makeGetterSetter('like'));
const reactionPickerSize = $computed(defaultStore.makeGetterSetter('reactionPickerSize'));
const reactionPickerWidth = $computed(defaultStore.makeGetterSetter('reactionPickerWidth'));
@@ -120,6 +131,18 @@ function chooseEmoji(ev: MouseEvent) {
});
}
+function chooseNewLike(ev: MouseEvent) {
+ os.pickEmoji(ev.currentTarget ?? ev.target, {
+ showPinned: false,
+ }).then(emoji => {
+ defaultStore.set('like', emoji as string);
+ });
+}
+
+function resetLike() {
+ defaultStore.set('like', '❤️');
+}
+
watch($$(reactions), () => {
save();
}, {
diff --git a/packages/frontend/src/store.ts b/packages/frontend/src/store.ts
index 30c876ec20..a655d3542b 100644
--- a/packages/frontend/src/store.ts
+++ b/packages/frontend/src/store.ts
@@ -110,6 +110,10 @@ export const defaultStore = markRaw(new Storage('base', {
where: 'account',
default: 'nonSensitiveOnly' as 'likeOnly' | 'likeOnlyForRemote' | 'nonSensitiveOnly' | 'nonSensitiveOnlyForLocalLikeOnlyForRemote' | null,
},
+ like: {
+ where: 'account',
+ default: '❤️',
+ },
mutedAds: {
where: 'account',
default: [] as string[],