Frontend: Fixed renote button
ci/woodpecker/push/ociImagePush Pipeline was successful Details

This commit is contained in:
Natty 2023-09-30 21:03:16 +02:00
parent 2ffb82895c
commit dde74dd56b
Signed by: natty
GPG Key ID: BF6CB659ADEE60EC
2 changed files with 9 additions and 14 deletions

View File

@ -163,6 +163,7 @@ export type Note = {
url?: string; url?: string;
updatedAt?: DateString; updatedAt?: DateString;
isHidden?: boolean; isHidden?: boolean;
hasRenotedBefore?: boolean;
}; };
export type NoteReaction = { export type NoteReaction = {

View File

@ -36,6 +36,8 @@ const props = defineProps<{
const buttonRef = ref<HTMLElement>(); const buttonRef = ref<HTMLElement>();
const hasRenotedBefore = ref(props.note.hasRenotedBefore ?? false);
const canRenote = computed( const canRenote = computed(
() => () =>
["public", "home"].includes(props.note.visibility) || ["public", "home"].includes(props.note.visibility) ||
@ -68,14 +70,6 @@ useTooltip(buttonRef, async (showing) => {
const renote = async (viaKeyboard = false, ev?: MouseEvent) => { const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
pleaseLogin(); pleaseLogin();
const renotes = await os.api("notes/renotes", {
noteId: props.note.id,
userId: $i.id,
limit: 1,
});
const hasRenotedBefore = renotes.length > 0;
let buttonActions: Array<MenuItem> = []; let buttonActions: Array<MenuItem> = [];
if (props.note.visibility === "public") { if (props.note.visibility === "public") {
@ -88,7 +82,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
renoteId: props.note.id, renoteId: props.note.id,
visibility: "public", visibility: "public",
}); });
hasRenotedBefore = true; hasRenotedBefore.value = true;
const el = const el =
ev && ev &&
((ev.currentTarget ?? ev.target) as ((ev.currentTarget ?? ev.target) as
@ -115,7 +109,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
renoteId: props.note.id, renoteId: props.note.id,
visibility: "home", visibility: "home",
}); });
hasRenotedBefore = true; hasRenotedBefore.value = true;
const el = const el =
ev && ev &&
((ev.currentTarget ?? ev.target) as ((ev.currentTarget ?? ev.target) as
@ -143,7 +137,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
visibility: "specified", visibility: "specified",
visibleUserIds: props.note.visibleUserIds, visibleUserIds: props.note.visibleUserIds,
}); });
hasRenotedBefore = true; hasRenotedBefore.value = true;
const el = const el =
ev && ev &&
((ev.currentTarget ?? ev.target) as ((ev.currentTarget ?? ev.target) as
@ -168,7 +162,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
renoteId: props.note.id, renoteId: props.note.id,
visibility: "followers", visibility: "followers",
}); });
hasRenotedBefore = true; hasRenotedBefore.value = true;
const el = const el =
ev && ev &&
((ev.currentTarget ?? ev.target) as ((ev.currentTarget ?? ev.target) as
@ -206,7 +200,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
localOnly: true, localOnly: true,
} }
); );
hasRenotedBefore = true; hasRenotedBefore.value = true;
const el = const el =
ev && ev &&
((ev.currentTarget ?? ev.target) as ((ev.currentTarget ?? ev.target) as
@ -245,7 +239,7 @@ const renote = async (viaKeyboard = false, ev?: MouseEvent) => {
os.api("notes/unrenote", { os.api("notes/unrenote", {
noteId: props.note.id, noteId: props.note.id,
}); });
hasRenotedBefore = false; hasRenotedBefore.value = false;
}, },
}); });
} }