Fix navbar links not rendering active when thread is open

This commit is contained in:
thepaperpilot 2024-05-27 22:45:05 -05:00
parent cf3fb3e6ef
commit a3494184c8
3 changed files with 61 additions and 9 deletions

View file

@ -239,9 +239,11 @@ function deleteItem() {
function openThread(e: MouseEvent | TouchEvent, index: number) { function openThread(e: MouseEvent | TouchEvent, index: number) {
e.preventDefault(); e.preventDefault();
if (!dragged.value) { if (!dragged.value) {
router.push( if (isSelected(index)) {
isSelected(index) ? props.baseUrl : emits("deselect");
`${props.baseUrl}/${props.item.source}/${props.item.sourceItem}/${index}`); } else {
router.push(`${props.baseUrl}/${props.item.source}/${props.item.sourceItem}/${index}`);
}
} }
} }

View file

@ -11,11 +11,61 @@ import Unsorted from "./components/pages/Unsorted.vue";
const routes: RouteRecordRaw[] = [ const routes: RouteRecordRaw[] = [
{ path: '/', component: Todo, name: 'home' }, { path: '/', component: Todo, name: 'home' },
{ path: '/todo/:source(\\d+)?/:sourceItem(\\d+)?/:thread(\\d+)?', component: Todo, name: 'todo' }, {
{ path: '/snoozed/:source(\\d+)?/:sourceItem(\\d+)?/:thread(\\d+)?', component: Snoozed, name: 'snoozed' }, path: '/todo',
{ path: '/low/:source(\\d+)?/:sourceItem(\\d+)?/:thread(\\d+)?', component: LowPriority, name: 'low' }, component: Todo,
{ path: '/source/:source(\\d+)/:sourceItem(\\d+)?/:thread(\\d+)?/:event(\\d+)?', component: Source, name: 'source' }, name: 'todo',
{ path: '/unsorted/:source(\\d+)?/:sourceItem(\\d+)?/:thread(\\d+)?', component: Unsorted, name: 'unsorted' }, children: [
{
path: ':source(\\d+)/:sourceItem(\\d+)/:thread(\\d+)',
component: Todo
}
]
},
{
path: '/snoozed',
component: Snoozed,
name: 'snoozed',
children: [
{
path: ':source(\\d+)/:sourceItem(\\d+)/:thread(\\d+)',
component: Snoozed
}
]
},
{
path: '/low',
component: LowPriority,
name: 'low',
children: [
{
path: ':source(\\d+)/:sourceItem(\\d+)/:thread(\\d+)',
component: LowPriority
}
]
},
{
path: '/source/:source(\\d+)',
component: Source,
name: 'source',
children: [
{
path: ':sourceItem(\\d+)/:thread(\\d+)/:event(\\d+)?',
component: Source
}
]
},
{
path: '/unsorted',
component: Unsorted,
name: 'unsorted',
children: [
{
path: ':source(\\d+)/:sourceItem(\\d+)/:thread(\\d+)',
component: Unsorted
}
]
}
]; ];
const router = createRouter({ const router = createRouter({