[core] Generalize markAllAboveAsRead()
This is needed when using a RemorseItem on sailfish as the selected item might have changed between starting the RemorseItem and its execution.
This commit is contained in:
parent
7860121a56
commit
16d8811cfd
2 changed files with 10 additions and 5 deletions
|
|
@ -142,12 +142,16 @@ ListModel {
|
|||
return root.get(root.selectedIndex)
|
||||
}
|
||||
|
||||
function markAllAboveAsRead() {
|
||||
/**
|
||||
* Mark all items above an index as read, i.e. item with an index less than
|
||||
* the given index.
|
||||
* @param {int} The index above which items should be marked read.
|
||||
*/
|
||||
function markAllAboveAsRead(index) {
|
||||
var ttrss = rootWindow.getTTRSS()
|
||||
var sel = root.selectedIndex
|
||||
|
||||
var ids = ""
|
||||
for (var i = 0; i < sel; i++) {
|
||||
for (var i = 0; i < index; i++) {
|
||||
var item = root.get(i)
|
||||
// Only include items that are unread.
|
||||
if (item.unread) {
|
||||
|
|
@ -165,7 +169,7 @@ ListModel {
|
|||
|
||||
ttrss.updateFeedUnread(ids, false, function(successful, errorMessage) {
|
||||
if (successful) {
|
||||
for (var i = 0; i < sel; i++) {
|
||||
for (var i = 0; i < index; i++) {
|
||||
var item = root.get(i)
|
||||
if (item.unread) {
|
||||
root.setProperty(i, "unread", false)
|
||||
|
|
|
|||
|
|
@ -163,7 +163,8 @@ ListItem {
|
|||
text: qsTr("Mark all above read")
|
||||
enabled: index > 0
|
||||
onClicked: {
|
||||
feedItemModel.markAllAboveAsRead()
|
||||
var index = feedItemModel.selectedIndex
|
||||
feedItemModel.markAllAboveAsRead(index)
|
||||
} }
|
||||
MenuItem {
|
||||
id: openInBrowserMenuItem
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue