diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index b2c99a02b..e6b557efe 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -36,6 +36,14 @@ Kirigami.ScrollablePage { } } + function pageIndex(pageToFind) { + for (var i = 0; i < pageStack.contentItem.contentChildren.length; i++) { + if (pageStack.contentItem.contentChildren[i] === pageToFind) + return i + } + return -1 + } + Component { id: diveDelegate Kirigami.AbstractListItem { @@ -112,7 +120,12 @@ Kirigami.ScrollablePage { if (detailsWindow.state === "view") { diveListView.currentIndex = index detailsWindow.showDiveIndex(index); - pageStack.push(detailsWindow); + // switch to detailsWindow (or push it if it's not in the stack) + var i = pageIndex(detailsWindow) + if (i === -1) + pageStack.push(detailsWindow) + else + pageStack.currentIndex = i } }