Browse Source

fix: coderabbit suggestions

pull/9323/head
DarkPhoenix2704 2 months ago
parent
commit
c498ee63cc
  1. 5
      packages/nc-gui/components/nc/Popover.vue
  2. 9
      packages/nc-gui/composables/useProductFeed.ts
  3. 14
      packages/nocodb/src/services/utils.service.ts

5
packages/nc-gui/components/nc/Popover.vue

@ -38,7 +38,8 @@ const emit = defineEmits(['update:modelValue'])
const triggerRef = ref(null)
const popoverRef = ref(null)
const isOpen = ref(props.modelValue)
const isOpen = useVModel(props, 'modelValue', emit)
const popoverStyle = computed(() => ({
position: 'fixed',
@ -117,7 +118,6 @@ const updatePopoverPosition = () => {
const openPopover = () => {
isOpen.value = true
emit('update:modelValue', true)
nextTick(() => {
updatePopoverPosition()
variant.value = 'enter'
@ -128,7 +128,6 @@ const closePopover = () => {
variant.value = 'leave'
setTimeout(() => {
isOpen.value = false
emit('update:modelValue', false)
}, 300)
}

9
packages/nc-gui/composables/useProductFeed.ts

@ -82,8 +82,11 @@ export const useProductFeed = createSharedComposable(() => {
try {
const newFeeds = await $api.utils.feed({ last_published_at: lastPublishedAt })
newFeedCount.value = newFeeds as unknown as number
if (typeof newFeeds === 'number') {
newFeedCount.value = newFeeds
} else if (typeof newFeeds === 'string') {
newFeedCount.value = 100
}
} catch (error) {
console.error(error)
}
@ -103,7 +106,7 @@ export const useProductFeed = createSharedComposable(() => {
})
onUnmounted(() => {
if (intervalId) clearTimeout(intervalId.value)
if (intervalId.value) clearTimeout(intervalId.value)
})
return {

14
packages/nocodb/src/services/utils.service.ts

@ -491,7 +491,10 @@ export class UtilsService {
per_page: string;
};
const cacheKey = `${CacheScope.PRODUCT_FEED}:${type}:${page}:${per_page}`;
const perPage = Math.min(Math.max(parseInt(per_page, 10) || 10, 1), 100);
const pageNum = Math.max(parseInt(page, 10) || 1, 1);
const cacheKey = `${CacheScope.PRODUCT_FEED}:${type}:${pageNum}:${perPage}`;
const cachedData = await NocoCache.get(cacheKey, 'json');
@ -500,13 +503,14 @@ export class UtilsService {
return JSON.parse(cachedData);
} catch (e) {
this.logger.error(e?.message, e);
await NocoCache.del(cacheKey);
}
}
let payload = null;
if (dayjs().isAfter(this.lastSyncTime.add(3, 'hours'))) {
this.lastSyncTime = dayjs();
payload = await T.payload();
this.lastSyncTime = dayjs();
}
let response;
@ -517,8 +521,8 @@ export class UtilsService {
payload,
{
params: {
per_page,
page,
per_page: perPage,
page: pageNum,
type,
},
},
@ -533,7 +537,7 @@ export class UtilsService {
await NocoCache.setExpiring(
cacheKey,
JSON.stringify(response.data, getCircularReplacer),
isNaN(parseInt(process.env.NC_ATTACHMENT_EXPIRE_SECONDS))
Number.isNaN(parseInt(process.env.NC_ATTACHMENT_EXPIRE_SECONDS))
? 2 * 60 * 60
: parseInt(process.env.NC_ATTACHMENT_EXPIRE_SECONDS),
);

Loading…
Cancel
Save