Skip to content

Commit

Permalink
更新を実装
Browse files Browse the repository at this point in the history
  • Loading branch information
ZOI-dayo committed Jun 16, 2024
1 parent 9e4f525 commit 24c9661
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions frontend/src/views/PostView.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script setup lang="ts">
import MainLayout from '@/components/MainLayout.vue';
import { useRoute } from 'vue-router';
import { onBeforeRouteUpdate, type RouteLocationNormalizedLoaded, useRoute } from 'vue-router';

Check warning on line 3 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'RouteLocationNormalizedLoaded' is defined but never used
import { getPost, type GetPostResponse } from '@/features/api';
import {ref, watch} from 'vue';
import { computed, onMounted, onRenderTriggered, ref, watch } from 'vue';

Check warning on line 5 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'computed' is defined but never used

Check warning on line 5 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'onMounted' is defined but never used

Check warning on line 5 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'onRenderTriggered' is defined but never used

Check warning on line 5 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'watch' is defined but never used
import Post from '@/components/Post.vue';
import NewPostSection from '@/components/NewPostSection.vue';
import { convertReactions } from '@/features/reactions';
Expand All @@ -11,15 +11,15 @@ const route = useRoute();
if (route.params.id == undefined) {
// TODO: error, id not found
}
const id = route.params.id as string;
// const id = route.params.id as string;
const postContent = ref<GetPostResponse>();
const loadPost = () => {
const loadPost = (id: string) => {
getPost(id).then((e) => (postContent.value = e));
};
loadPost();
loadPost(useRoute().params.id as string);
watch(useRoute(), (_, __) => {
location.reload();
onBeforeRouteUpdate((to, from, next) => {

Check warning on line 21 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'from' is defined but never used

Check warning on line 21 in frontend/src/views/PostView.vue

View workflow job for this annotation

GitHub Actions / lint

'next' is defined but never used
loadPost(to.params.id as string);
});
</script>

Expand All @@ -34,7 +34,7 @@ watch(useRoute(), (_, __) => {
:name="ancestor.post.user_name"
:reactions="convertReactions(ancestor.post.reactions, ancestor.post.my_reactions)"
:id="ancestor.post.id"
@react="loadPost"
@react="() => loadPost(useRoute().params.id as string)"
/>
</div>
<hr />
Expand All @@ -44,10 +44,14 @@ watch(useRoute(), (_, __) => {
:name="postContent.user_name"
:reactions="convertReactions(postContent.reactions, postContent.my_reactions)"
:id="postContent.id"
@react="loadPost"
@react="() => loadPost(useRoute().params.id as string)"
/>
<hr />
<NewPostSection name="" :parent-id="postContent.id" @submit="loadPost" />
<NewPostSection
name=""
:parent-id="postContent.id"
@submit="() => loadPost(useRoute().params.id as string)"
/>
<!-- TODO: -->
<div v-for="child in postContent.children" :key="child.post.id">
<Post
Expand All @@ -56,7 +60,7 @@ watch(useRoute(), (_, __) => {
:name="child.post.user_name"
:reactions="convertReactions(child.post.reactions, child.post.my_reactions)"
:id="child.post.id"
@react="loadPost"
@react="() => loadPost(useRoute().params.id as string)"
/>
</div>
</div>
Expand Down

0 comments on commit 24c9661

Please sign in to comment.