merge: upstream

This commit is contained in:
Marie 2023-12-23 02:09:23 +01:00
commit 5db583a3eb
701 changed files with 50809 additions and 13660 deletions

View file

@ -29,7 +29,8 @@ SPDX-License-Identifier: AGPL-3.0-only
<div class="other">
<button v-if="$i && $i.id === post.user.id" v-tooltip="i18n.ts.edit" v-click-anime class="_button" @click="edit"><i class="ph-pencil ph-bold ph-lg ti-fw"></i></button>
<button v-tooltip="i18n.ts.shareWithNote" v-click-anime class="_button" @click="shareWithNote"><i class="ph-repeat ph-bold ph-lg ti-fw"></i></button>
<button v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network ph-bold ph-lg ti-fw"></i></button>
<button v-tooltip="i18n.ts.copyLink" v-click-anime class="_button" @click="copyLink"><i class="ph-share-network ph-bold ph-lg ti-fw"></i></button>
<button v-if="isSupportShare()" v-tooltip="i18n.ts.share" v-click-anime class="_button" @click="share"><i class="ph-share-network ph-bold ph-lg ti-fw"></i></button>
</div>
</div>
<div class="user">
@ -61,7 +62,7 @@ SPDX-License-Identifier: AGPL-3.0-only
</template>
<script lang="ts" setup>
import { computed, watch } from 'vue';
import { computed, watch, ref } from 'vue';
import MkButton from '@/components/MkButton.vue';
import * as os from '@/os.js';
import MkContainer from '@/components/MkContainer.vue';
@ -74,6 +75,8 @@ import { i18n } from '@/i18n.js';
import { definePageMetadata } from '@/scripts/page-metadata.js';
import { defaultStore } from '@/store.js';
import { $i } from '@/account.js';
import { isSupportShare } from '@/scripts/navigator.js';
import copyToClipboard from '@/scripts/copy-to-clipboard.js';
const router = useRouter();
@ -81,38 +84,43 @@ const props = defineProps<{
postId: string;
}>();
let post = $ref(null);
let error = $ref(null);
const post = ref(null);
const error = ref(null);
const otherPostsPagination = {
endpoint: 'users/gallery/posts' as const,
limit: 6,
params: computed(() => ({
userId: post.user.id,
userId: post.value.user.id,
})),
};
function fetchPost() {
post = null;
post.value = null;
os.api('gallery/posts/show', {
postId: props.postId,
}).then(_post => {
post = _post;
post.value = _post;
}).catch(_error => {
error = _error;
error.value = _error;
});
}
function copyLink() {
copyToClipboard(`${url}/gallery/${post.value.id}`);
os.success();
}
function share() {
navigator.share({
title: post.title,
text: post.description,
url: `${url}/gallery/${post.id}`,
title: post.value.title,
text: post.value.description,
url: `${url}/gallery/${post.value.id}`,
});
}
function shareWithNote() {
os.post({
initialText: `${post.title} ${url}/gallery/${post.id}`,
initialText: `${post.value.title} ${url}/gallery/${post.value.id}`,
});
}
@ -120,8 +128,8 @@ function like() {
os.apiWithDialog('gallery/posts/like', {
postId: props.postId,
}).then(() => {
post.isLiked = true;
post.likedCount++;
post.value.isLiked = true;
post.value.likedCount++;
});
}
@ -134,28 +142,28 @@ async function unlike() {
os.apiWithDialog('gallery/posts/unlike', {
postId: props.postId,
}).then(() => {
post.isLiked = false;
post.likedCount--;
post.value.isLiked = false;
post.value.likedCount--;
});
}
function edit() {
router.push(`/gallery/${post.id}/edit`);
router.push(`/gallery/${post.value.id}/edit`);
}
watch(() => props.postId, fetchPost, { immediate: true });
const headerActions = $computed(() => [{
const headerActions = computed(() => [{
icon: 'ph-pencil ph-bold ph-lg',
text: i18n.ts.edit,
handler: edit,
}]);
const headerTabs = $computed(() => []);
const headerTabs = computed(() => []);
definePageMetadata(computed(() => post ? {
title: post.title,
avatar: post.user,
definePageMetadata(computed(() => post.value ? {
title: post.value.title,
avatar: post.value.user,
} : null));
</script>