Skip to content

Commit

Permalink
feat: Fetch new articles after 'Read all'
Browse files Browse the repository at this point in the history
  • Loading branch information
korapp committed Mar 7, 2024
1 parent 7700710 commit 80abaea
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 2 deletions.
3 changes: 3 additions & 0 deletions package/contents/config/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<entry name="fetchUnreadOnly" type="bool">
<default>true</default>
</entry>
<entry name="readAndFetch" type="bool">
<default>false</default>
</entry>
<entry name="plasmoidHeightFull" type="bool">
<default>true</default>
</entry>
Expand Down
6 changes: 6 additions & 0 deletions package/contents/ui/ConfigGeneral.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Kirigami.FormLayout {
property alias cfg_itemsDownloadLimit: itemsDownloadLimit.value
property alias cfg_autoRead: autoRead.checked
property alias cfg_fetchUnreadOnly: fetchUnreadOnly.checked
property alias cfg_readAndFetch: readAndFetch.checked

signal configurationChanged

Expand Down Expand Up @@ -78,6 +79,11 @@ Kirigami.FormLayout {
Kirigami.FormData.label: i18n("Fetch unread only")
}

CheckBox {
id: readAndFetch
Kirigami.FormData.label: i18n("Fetch articles after 'Read all'")
}

CheckBox {
id: autoRead
Kirigami.FormData.label: i18n("Automatically mark an article as read")
Expand Down
4 changes: 4 additions & 0 deletions package/contents/ui/InoreaderModel.qml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ BaseObject {
readonly property int unreadCount: Math.max(_.unreadCount, 0)
readonly property string unreadCountFormatted: _.kNumber(unreadCount) + (_.unreadMaxReached ? "+" : "")

signal reloaded()

Connections {
target: dispatcher

Expand All @@ -25,6 +27,7 @@ BaseObject {

onSetArticleRead: _.setArticleRead(article, read)
onSetAllArticlesRead: _.setAllArticlesRead(read)
onSetAllArticlesReadAndFetch: _.callPending(() => _.setAllArticlesRead(read).then(_.loadData), 'fetchStream')
onSetArticleStarred: _.setArticleStarred(article, starred)
}

Expand Down Expand Up @@ -110,6 +113,7 @@ BaseObject {

if (!continuation) {
_.articles.clear()
reloaded()
}
_.articles.append(stream.items)
_.unreadNewCount = 0
Expand Down
9 changes: 8 additions & 1 deletion package/contents/ui/Logic.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ QtObject {
signal fetchStreamContinuation()

signal setAllArticlesRead(bool read)
signal setAllArticlesReadAndFetch(bool read)
signal setArticleRead(var article, bool read)
signal setArticleStarred(var article, bool starred)

Expand Down Expand Up @@ -52,7 +53,13 @@ QtObject {
icon.name: "checkbox"
text: i18n("Read all")
onTriggered: setAllArticlesRead(true)
}
}

readonly property Action readAllAndFetchAction: Action {
icon.name: "checkbox"
text: i18n("Read all and fetch")
onTriggered: setAllArticlesReadAndFetch(true)
}

readonly property Action starAction: Action {
readonly property var icons: ({ false: "non-starred-symbolic", true: "starred-symbolic" })
Expand Down
6 changes: 5 additions & 1 deletion package/contents/ui/StreamView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ FocusScope {
Layout.fillWidth: true
}
ToolButton {
action: logic.readAllAction
action: plasmoid.configuration.readAndFetch ? logic.readAllAndFetchAction : logic.readAllAction
}
ToolButton {
action: logic.reloadAction
Expand Down Expand Up @@ -100,6 +100,10 @@ FocusScope {
}
property bool isCurrentItem: GridView.isCurrentItem
}
Connections {
target: stream
onReloaded: Qt.callLater(listView.positionViewAtBeginning)
}
}
}
}

0 comments on commit 80abaea

Please sign in to comment.