Skip to content

Commit

Permalink
Rename LoadingItem to StatusItem
Browse files Browse the repository at this point in the history
  • Loading branch information
jonamil committed Jun 3, 2024
1 parent 90c28ed commit 1f192d9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
File renamed without changes.
15 changes: 8 additions & 7 deletions src/components/TheCommentsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
/>
</Suspense>
</template>
<LoadingItem
ref="loadingItemInstance"
<StatusItem
ref="statusItemInstance"
v-show="!hasComments || !someThreadInstancesVisible || !allThreadInstancesVisible"
:full-height="!hasDescription && (!hasComments || !someThreadInstancesVisible)"
:message="!hasComments ? 'So far, no comments have been left on this story.' : undefined"
Expand All @@ -62,15 +62,15 @@
</template>

<script setup lang="ts">
import { ref, computed, watch, onMounted, nextTick } from 'vue';
import { ref, computed, watch, onMounted } from 'vue';
import type { ComponentPublicInstance } from 'vue';
import { useInfiniteScroll } from '@vueuse/core';
import type { HackerNewsItem } from '@/types';
import { apiItemUrl } from '@/utils';
import BaseButton from '@/components/BaseButton.vue';
import PageColumnBody from '@/components/PageColumnBody.vue';
import CommentItem from '@/components/CommentItem.vue';
import LoadingItem from '@/components/LoadingItem.vue';
import StatusItem from '@/components/StatusItem.vue';
import { useContentStore } from '@/stores/ContentStore';
const content = useContentStore();
Expand Down Expand Up @@ -124,13 +124,14 @@ async function fetchThreadItems() {
loadThreadGroup();
}
// if this is true, it prevents infinite scrolling callbacks from lading multiple thread groups at once
// if this is true, it prevents infinite scrolling callbacks from loading multiple thread groups at once
const isLoadingThreadGroup = ref(false);
// push the next slice of threadItems as a new thread group
function loadThreadGroup() {
if (isLoadingThreadGroup.value) return;
// when the Suspense component surrounding the thread group's items resolves, this is set back to false
isLoadingThreadGroup.value = true;
threadGroups.value.push(
Expand Down Expand Up @@ -205,7 +206,7 @@ onMounted(() => {
);
});
const loadingItemInstance = ref<ComponentPublicInstance | null>(null);
const statusItemInstance = ref<ComponentPublicInstance | null>(null);
function scrollThreadIntoView(index: number) {
if (index < 0 || index >= threadItemCount.value) return;
Expand All @@ -214,7 +215,7 @@ function scrollThreadIntoView(index: number) {
// (triggering loadThreadGroup)
const element =
index >= threadInstanceCount.value
? loadingItemInstance.value?.$el
? statusItemInstance.value?.$el
: threadInstances.value[index].$el;
element.scrollIntoView({
Expand Down
8 changes: 4 additions & 4 deletions src/components/ThePostsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
:active="postItem.id === content.currentPostItem?.id"
@click="content.setCurrentPostItem(postItem)"
/>
<LoadingItem
<StatusItem
:full-height="!content.currentCategoryHasSomePostItems"
:message="loadingMessage"
:message="statusMessage"
/>
</PageColumnBody>
</template>
Expand All @@ -23,7 +23,7 @@ import { ref, computed, onMounted } from 'vue';
import { useInfiniteScroll } from '@vueuse/core';
import PageColumnBody from '@/components/PageColumnBody.vue';
import PostItem from '@/components/PostItem.vue';
import LoadingItem from '@/components/LoadingItem.vue';
import StatusItem from '@/components/StatusItem.vue';
import { useContentStore } from '@/stores/ContentStore';
const content = useContentStore();
Expand All @@ -42,7 +42,7 @@ onMounted(() => {
);
});
const loadingMessage = computed(() => {
const statusMessage = computed(() => {
if (content.currentCategoryHasAllPostItems)
return `You have browsed all “${content.currentCategoryName.replace(' ', '&nbsp;')}” entries. Refresh the list to view newer posts.`;
else if (content.currentCategoryPostIds?.error)
Expand Down

1 comment on commit 1f192d9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for hackernews-dot-cool ready!

✅ Preview
https://hackernews-dot-cool-9oga9vz05-jonamil-56ba8df7.vercel.app

Built with commit 1f192d9.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.