refactor: un-hardcode file urls
This commit is contained in:
@@ -42,7 +42,7 @@ watch(() => message.children.length, (newCount, oldCount) => {
|
||||
}
|
||||
|
||||
if (oldCount > newCount) {
|
||||
const activeChild = message.children.find(c => c.id === message.activeChildId);
|
||||
const activeChild = message.children.find(c => c?.id === message.activeChildId);
|
||||
if (!activeChild) {
|
||||
emit('patch', { activeChildId: message.children[newCount - 1]?.id ?? null });
|
||||
}
|
||||
@@ -57,7 +57,7 @@ watch(() => message.children.length, (newCount, oldCount) => {
|
||||
|
||||
const activeMessage = computed(() => {
|
||||
if (message.activeChildId && message.children.length > 0) {
|
||||
const child = message.children.find(c => c.id === message.activeChildId);
|
||||
const child = message.children.find(c => c?.id === message.activeChildId);
|
||||
if (child) return child;
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ const messageCount = computed(() => {
|
||||
|
||||
const currentChildIndex = computed(() => {
|
||||
if (!message.activeChildId) return 0;
|
||||
const idx = message.children.findIndex(c => c.id === message.activeChildId);
|
||||
const idx = message.children.findIndex(c => c?.id === message.activeChildId);
|
||||
return idx >= 0 ? idx + 1 : 0;
|
||||
});
|
||||
|
||||
@@ -150,7 +150,7 @@ const navigateChild = (direction: -1 | 1) => {
|
||||
: [null, ...message.children];
|
||||
|
||||
const currentIdx = allItems.findIndex(item =>
|
||||
item === null ? !message.activeChildId : item.id === message.activeChildId
|
||||
!item ? !message.activeChildId : item.id === message.activeChildId
|
||||
);
|
||||
|
||||
const newIdx = Math.max(0, Math.min(allItems.length - 1, currentIdx + direction));
|
||||
|
||||
Reference in New Issue
Block a user