From 9f80f9788e3e0c4c49aa61165d597615c70e6eb7 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Thu, 3 Oct 2024 14:48:37 +0000 Subject: [PATCH 01/12] fix: add user settings (compact and compactExpand are hidden at the moment) Signed-off-by: Wolfgang --- lib/AppInfo/Application.php | 5 + lib/Controller/PageController.php | 67 ++++- lib/Listeners/UserSettingsListener.php | 29 +++ src/components/Sidebar.vue | 150 ++++++++++++ .../feed-display/FeedItemDisplayList.vue | 6 +- src/components/modals/HelpModal.vue | 229 ++++++++++++++++++ src/dataservices/item.service.ts | 21 +- src/store/app.ts | 51 ++++ 8 files changed, 538 insertions(+), 20 deletions(-) create mode 100644 lib/Listeners/UserSettingsListener.php create mode 100644 src/components/modals/HelpModal.vue diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index df52cdeb5b..6c307a7820 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -25,6 +25,7 @@ use OCA\News\Search\FolderSearchProvider; use OCA\News\Search\ItemSearchProvider; use OCA\News\Listeners\AddMissingIndicesListener; +use OCA\News\Listeners\UserSettingsListener; use OCA\News\Utility\Cache; use OCP\AppFramework\Bootstrap\IBootContext; @@ -36,6 +37,8 @@ use OCA\News\Fetcher\FeedFetcher; use OCA\News\Fetcher\Fetcher; use OCP\User\Events\BeforeUserDeletedEvent; +use OCP\Config\BeforePreferenceDeletedEvent; +use OCP\Config\BeforePreferenceSetEvent; use OCP\DB\Events\AddMissingIndicesEvent; use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; @@ -91,6 +94,8 @@ public function register(IRegistrationContext $context): void $context->registerEventListener(BeforeUserDeletedEvent::class, UserDeleteHook::class); $context->registerEventListener(AddMissingIndicesEvent::class, AddMissingIndicesListener::class); + $context->registerEventListener(BeforePreferenceDeletedEvent::class, UserSettingsListener::class); + $context->registerEventListener(BeforePreferenceSetEvent::class, UserSettingsListener::class); // parameters $context->registerParameter('exploreDir', __DIR__ . '/../Explore/feeds'); diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 8af00664c9..75582d2788 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -24,6 +24,7 @@ use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http; use OCP\AppFramework\Http\ContentSecurityPolicy; +use OCP\AppFramework\Services\IInitialState; use OCA\News\Service\StatusService; use OCA\News\Explore\RecommendedSites; @@ -34,17 +35,53 @@ class PageController extends Controller { use JSONHttpErrorTrait; + /** + * @var IConfig + */ + private $settings; + + /** + * @var IL10N + */ + private $l10n; + + /** + * @var IURLGenerator + */ + private $urlGenerator; + + /** + * @var RecommendedSites + */ + private $recommendedSites; + + /** + * @var StatusService + */ + private $statusService; + + /* + * @var IInitialState + */ + private $initialState; + public function __construct( IRequest $request, - ?IUserSession $userSession, - private IAppConfig $settings, - private IConfig $config, - private IURLGenerator $urlGenerator, - private IL10N $l10n, - private RecommendedSites $recommendedSites, - private StatusService $statusService + IConfig $settings, + IURLGenerator $urlGenerator, + IL10N $l10n, + RecommendedSites $recommendedSites, + StatusService $statusService, + IInitialState $initialState, + ?IUserSession $userSession ) { parent::__construct($request, $userSession); + $this->settings = $settings; + $this->urlGenerator = $urlGenerator; + $this->l10n = $l10n; + $this->recommendedSites = $recommendedSites; + $this->statusService = $statusService; + $this->initialState = $initialState; } @@ -73,6 +110,22 @@ public function index(): TemplateResponse ] ); + $usersettings = [ + 'compact', + 'compactExpand', + 'preventReadOnScroll', + 'oldestFirst', + 'showAll' + ]; + foreach ($usersettings as $setting) { + $this->initialState->provideInitialState($setting, $this->settings->getUserValue( + $this->getUserId(), + $this->appName, + $setting, + '0') + ); + } + $csp = new ContentSecurityPolicy(); $csp->addAllowedImageDomain('*') ->addAllowedMediaDomain('*') diff --git a/lib/Listeners/UserSettingsListener.php b/lib/Listeners/UserSettingsListener.php new file mode 100644 index 0000000000..35f3abb44f --- /dev/null +++ b/lib/Listeners/UserSettingsListener.php @@ -0,0 +1,29 @@ + */ +class UserSettingsListener implements IEventListener { + + public function handle(Event $event): void { + if ($event instanceof BeforePreferenceSetEvent) { + if ($event->getAppId() === 'news') { + $event->setValid(true); + } + } elseif ($event instanceof BeforePreferenceDeletedEvent) { + if ($event->getAppId() === 'news') { + $event->setValid(true); + } + } + } +} diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index d425717f9a..8ba2b9abe2 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -111,6 +111,63 @@ + @@ -118,13 +175,19 @@ import { mapState } from 'vuex' import Vue from 'vue' +import axios from '@nextcloud/axios' +import { generateOcsUrl } from '@nextcloud/router' +import { showError, showSuccess } from '@nextcloud/dialogs' import NcAppNavigation from '@nextcloud/vue/dist/Components/NcAppNavigation.js' import NcAppNavigationNew from '@nextcloud/vue/dist/Components/NcAppNavigationNew.js' import NcAppNavigationItem from '@nextcloud/vue/dist/Components/NcAppNavigationItem.js' import NcAppNavigationNewItem from '@nextcloud/vue/dist/Components/NcAppNavigationNewItem.js' +import NcAppNavigationSettings from '@nextcloud/vue/dist/Components/NcAppNavigationSettings.js' +import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js' import NcCounterBubble from '@nextcloud/vue/dist/Components/NcCounterBubble.js' import NcActionButton from '@nextcloud/vue/dist/Components/NcActionButton.js' +import NcButton from '@nextcloud/vue/dist/Components/NcButton.js' import RssIcon from 'vue-material-design-icons/Rss.vue' import FolderIcon from 'vue-material-design-icons/Folder.vue' @@ -139,6 +202,8 @@ import { ACTIONS, AppState } from '../store' import AddFeed from './AddFeed.vue' import SidebarFeedLinkActions from './SidebarFeedLinkActions.vue' +import HelpModal from './modals/HelpModal.vue' +import { subscribe } from '@nextcloud/event-bus' import { Folder } from '../types/Folder' import { Feed } from '../types/Feed' @@ -168,8 +233,11 @@ export default Vue.extend({ NcAppNavigationNew, NcAppNavigationItem, NcAppNavigationNewItem, + NcAppNavigationSettings, + NcCheckboxRadioSwitch, NcCounterBubble, NcActionButton, + NcButton, AddFeed, RssIcon, FolderIcon, @@ -178,23 +246,105 @@ export default Vue.extend({ FolderPlusIcon, PlusIcon, SidebarFeedLinkActions, + HelpModal, }, data: () => { return { showAddFeed: false, ROUTES, + showHelp: false, } }, computed: { ...mapState(['feeds', 'folders', 'items']), ...mapState(SideBarState), + compact: { + get() { + return this.$store.getters.compact + }, + set(newValue) { + this.saveSetting('compact', newValue) + }, + }, + compactExpand: { + get() { + return this.$store.getters.compactExpand + }, + set(newValue) { + this.saveSetting('compactExpand', newValue) + }, + }, + oldestFirst: { + get() { + return this.$store.getters.oldestFirst + + }, + set(newValue) { + this.saveSetting('oldestFirst', newValue) + }, + }, + preventReadOnScroll: { + get() { + return this.$store.getters.preventReadOnScroll + + }, + set(newValue) { + this.saveSetting('preventReadOnScroll', newValue) + }, + }, + showAll: { + get() { + return this.$store.getters.showAll + + }, + set(newValue) { + this.saveSetting('showAll', newValue) + }, + }, }, created() { if (this.$route.query.subscribe_to) { this.showAddFeed = true } }, + mounted() { + subscribe('news:global:toggle-help-dialog', () => { + this.showHelp = !this.showHelp + }) + }, methods: { + async saveSetting(key, value) { + this.$store.commit(key, {value: value}) + const url = generateOcsUrl( + '/apps/provisioning_api/api/v1/config/users/{appId}/{key}', + { + appId: 'news', + key, + }, + ) + value = value ? '1' : '0' + try { + const { data } = await axios.post(url, { + configValue: value, + }) + this.handleResponse({ + status: data.ocs?.meta?.status, + }) + } catch (e) { + this.handleResponse({ + errorMessage: t('news', 'Unable to update news config'), + error: e, + }) + } + }, + handleResponse({ status, errorMessage, error }) { + if (status !== 'ok') { + showError(errorMessage) + console.error(errorMessage, error) + } else { + showSuccess(t('news', 'Successfully updated news configuration')) + } + }, newFolder(value: string) { const folderName = value.trim() const folder = { name: folderName } diff --git a/src/components/feed-display/FeedItemDisplayList.vue b/src/components/feed-display/FeedItemDisplayList.vue index d2fd722f5e..32798760a6 100644 --- a/src/components/feed-display/FeedItemDisplayList.vue +++ b/src/components/feed-display/FeedItemDisplayList.vue @@ -118,10 +118,10 @@ export default Vue.extend({ // Always want to sort by date (most recent first) sort: (a: FeedItem, b: FeedItem) => { - if (a.pubDate > b.pubDate) { - return -1 + if (this.$store.getters.oldestFirst) { + return a.pubDate < b.pubDate ? -1 : 1 } else { - return 1 + return a.pubDate > b.pubDate ? -1 : 1 } }, cache: [] as FeedItem[] | undefined, diff --git a/src/components/modals/HelpModal.vue b/src/components/modals/HelpModal.vue new file mode 100644 index 0000000000..4a9fde964f --- /dev/null +++ b/src/components/modals/HelpModal.vue @@ -0,0 +1,229 @@ + + + + + + diff --git a/src/dataservices/item.service.ts b/src/dataservices/item.service.ts index 348cb936f8..ad012cbe91 100644 --- a/src/dataservices/item.service.ts +++ b/src/dataservices/item.service.ts @@ -1,6 +1,7 @@ import _ from 'lodash' import { AxiosResponse } from 'axios' import axios from '@nextcloud/axios' +import store from './../store/app.ts' import { API_ROUTES } from '../types/ApiRoutes' import { FeedItem } from '../types/FeedItem' @@ -31,9 +32,9 @@ export class ItemService { return await axios.get(API_ROUTES.ITEMS, { params: { limit: 40, - oldestFirst: false, + oldestFirst: store.state.oldestFirst, search: '', - showAll: true, + showAll: store.state.showAll, type: ITEM_TYPES.ALL, offset: start, }, @@ -50,9 +51,9 @@ export class ItemService { return await axios.get(API_ROUTES.ITEMS, { params: { limit: 40, - oldestFirst: false, + oldestFirst: store.state.oldestFirst, search: '', - showAll: true, + showAll: store.state.showAll, type: ITEM_TYPES.STARRED, offset: start, }, @@ -69,9 +70,9 @@ export class ItemService { return await axios.get(API_ROUTES.ITEMS, { params: { limit: 40, - oldestFirst: false, + oldestFirst: store.state.oldestFirst, search: '', - showAll: false, + showAll: store.state.showAll, type: ITEM_TYPES.UNREAD, offset: start, }, @@ -89,9 +90,9 @@ export class ItemService { return await axios.get(API_ROUTES.ITEMS, { params: { limit: 40, - oldestFirst: false, + oldestFirst: store.state.oldestFirst, search: '', - showAll: true, + showAll: store.state.showAll, type: ITEM_TYPES.FEED, offset: start, id: feedId, @@ -110,9 +111,9 @@ export class ItemService { return await axios.get(API_ROUTES.ITEMS, { params: { limit: 40, - oldestFirst: false, + oldestFirst: store.state.oldestFirst, search: '', - showAll: true, + showAll: store.state.showAll, type: ITEM_TYPES.FOLDER, offset: start, id: folderId, diff --git a/src/store/app.ts b/src/store/app.ts index 2b470c9469..d24aef793c 100644 --- a/src/store/app.ts +++ b/src/store/app.ts @@ -1,3 +1,4 @@ +import { loadState } from '@nextcloud/initial-state' import { APPLICATION_MUTATION_TYPES } from '../types/MutationTypes' export const APPLICATION_ACTION_TYPES = { @@ -10,12 +11,32 @@ export type AppInfoState = { const state: AppInfoState = { error: undefined, + compact: loadState('news', 'compact') === '1', + compactExpand: loadState('news', 'compactExpand') === '1', + oldestFirst: loadState('news', 'oldestFirst') === '1', + preventReadOnScroll: loadState('news', 'preventReadOnScroll') === '1', + showAll: loadState('news', 'showAll') === '1' } const getters = { error(state: AppInfoState) { return state.error }, + compact() { + return state.compact + }, + compactExpand() { + return state.compactExpand + }, + oldestFirst() { + return state.oldestFirst + }, + preventReadOnScroll() { + return state.preventReadOnScroll + }, + showAll() { + return state.showAll + } } export const actions = { @@ -31,6 +52,36 @@ export const mutations = { ) { state.error = error }, + compact ( + state: AppInfoState, + { value }: { value: newValue }, + ) { + state.compact = value + }, + compactExpand ( + state: AppInfoState, + { value }: { value: newValue }, + ) { + state.compactExpand = value + }, + oldestFirst ( + state: AppInfoState, + { value }: { value: newValue }, + ) { + state.oldestFirst = value + }, + preventReadOnScroll ( + state: AppInfoState, + { value }: { value: newValue }, + ) { + state.preventReadOnScroll = value + }, + showAll( + state: AppInfoState, + { value }: { value: newValue }, + ) { + state.showAll = value + } } export default { From c133e7ff3e6fb98aad41635ab5fdd56a58e4230b Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Thu, 3 Oct 2024 18:15:02 +0000 Subject: [PATCH 02/12] fix: eslint errors Signed-off-by: Wolfgang --- package.json | 1 + src/components/Sidebar.vue | 12 +++++------- src/store/app.ts | 14 +++++++------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index da31b701f0..2c68245bc0 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "@nextcloud/auth": "^2.4.0", "@nextcloud/axios": "^2.5.0", "@nextcloud/dialogs": "^4.2.7", + "@nextcloud/event-bus": "^3.3.1", "@nextcloud/initial-state": "^2.2.0", "@nextcloud/l10n": "^3.1.0", "@nextcloud/moment": "^1.3.1", diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 8ba2b9abe2..65d8caf0d4 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -127,7 +127,7 @@ {{ t('news', 'Disable mark read through scrolling') }} - + --->
Date: Sat, 5 Oct 2024 14:00:10 +0000 Subject: [PATCH 03/12] fix: items loaded after are not sorted sequentially The backend sends the items to the frontend in packets of 40 sorted by item id. In the unread, all articles or folder view this leads to the fact that new items that have been loaded can also be sorted above the items already displayed. Signed-off-by: Wolfgang --- src/components/feed-display/FeedItemDisplayList.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/feed-display/FeedItemDisplayList.vue b/src/components/feed-display/FeedItemDisplayList.vue index 32798760a6..9699314109 100644 --- a/src/components/feed-display/FeedItemDisplayList.vue +++ b/src/components/feed-display/FeedItemDisplayList.vue @@ -116,12 +116,12 @@ export default Vue.extend({ // Show unread items at start filter: () => { return this.unreadFilter }, - // Always want to sort by date (most recent first) + // Always want to sort by id sort: (a: FeedItem, b: FeedItem) => { if (this.$store.getters.oldestFirst) { - return a.pubDate < b.pubDate ? -1 : 1 + return a.id < b.id ? -1 : 1 } else { - return a.pubDate > b.pubDate ? -1 : 1 + return a.id > b.id ? -1 : 1 } }, cache: [] as FeedItem[] | undefined, From 51cde484fa486b52eaad5d8da929ed0d0780c467 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Sat, 5 Oct 2024 14:23:24 +0000 Subject: [PATCH 04/12] fix: hide items read and all articles view when showAll setting is disabled Signed-off-by: Wolfgang --- src/components/Sidebar.vue | 6 +++++- src/components/feed-display/FeedItemDisplayList.vue | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 65d8caf0d4..1ccc33d152 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -34,7 +34,10 @@ - + @@ -389,6 +392,7 @@ export default Vue.extend({ isFolder(item: Feed | Folder) { return (item as Folder).name !== undefined }, + }, }) diff --git a/src/components/feed-display/FeedItemDisplayList.vue b/src/components/feed-display/FeedItemDisplayList.vue index 9699314109..c5c32ff31c 100644 --- a/src/components/feed-display/FeedItemDisplayList.vue +++ b/src/components/feed-display/FeedItemDisplayList.vue @@ -189,8 +189,8 @@ export default Vue.extend({ fetchMore() { this.$emit('load-more') }, - noFilter(): boolean { - return true + noFilter(item: FeedItem): boolean { + return this.$store.getters.showAll ? true : item.unread || item.starred }, starFilter(item: FeedItem): boolean { return item.starred From e7a7914aa2221196c8ee6ba11656570037fc2c8f Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Sat, 5 Oct 2024 14:53:31 +0000 Subject: [PATCH 05/12] fix: load-more not working after changing item ordering Signed-off-by: Wolfgang --- src/components/Sidebar.vue | 1 + src/store/item.ts | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 1ccc33d152..48a36edad3 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -282,6 +282,7 @@ export default Vue.extend({ }, set(newValue) { this.saveSetting('oldestFirst', newValue) + this.$store.dispatch(ACTIONS.RESET_ITEMS) }, }, preventReadOnScroll: { diff --git a/src/store/item.ts b/src/store/item.ts index 2aa22c59af..9a4ec22484 100644 --- a/src/store/item.ts +++ b/src/store/item.ts @@ -16,6 +16,7 @@ export const FEED_ITEM_ACTION_TYPES = { FETCH_FEED_ITEMS: 'FETCH_FEED_ITEMS', FETCH_FOLDER_FEED_ITEMS: 'FETCH_FOLDER_FEED_ITEMS', FETCH_ITEMS: 'FETCH_ITEMS', + RESET_ITEMS: 'RESET_ITEMS', } export type ItemState = { @@ -289,6 +290,25 @@ export const actions = { commit(FEED_ITEM_MUTATION_TYPES.UPDATE_ITEM, { item }) commit(FEED_ITEM_MUTATION_TYPES.SET_STARRED_COUNT, state.starredCount - 1) }, + + /** + * Remove all loaded items from memory and reset ItemsLoaded counters + * + * @param param0 ActionParams + * @param param0.dispatch Dispatch + * @param param1 ActionArgs + * @param param1.start Start data + */ + [FEED_ITEM_ACTION_TYPES.RESET_ITEMS]( + { dispatch }: ActionParams, + { start }: { start: number } = { start: 0 }, + ) { + state.allItems.splice(start, state.allItems.length) + state.allItemsLoaded = {} + state.lastItemLoaded = {} + dispatch(FEED_ITEM_ACTION_TYPES.FETCH_STARRED) + dispatch(FEED_ITEM_ACTION_TYPES.FETCH_ITEMS) + }, } export const mutations = { From 38f50ece48a27ec17cb29f59b90621ff09afe455 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Sat, 5 Oct 2024 15:07:47 +0000 Subject: [PATCH 06/12] fix: mark all read with reverse ordering Signed-off-by: Wolfgang --- src/store/feed.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/store/feed.ts b/src/store/feed.ts index 72d3aba222..8b5ed0a17d 100644 --- a/src/store/feed.ts +++ b/src/store/feed.ts @@ -115,9 +115,9 @@ export const actions = { { commit }: ActionParams, { feed }: { feed: Feed }, ) { - // want to fetch feed so that we can retrieve the "highestItemId" + // want to fetch feed so that we can retrieve the "newestItemId" const response = await ItemService.fetchFeedItems(feed.id as number) - await FeedService.markRead({ feedId: feed.id as number, highestItemId: response.data.items[0].id }) + await FeedService.markRead({ feedId: feed.id as number, highestItemId: response.data.newestItemId }) if (feed.folderId) { commit(FOLDER_MUTATION_TYPES.MODIFY_FOLDER_UNREAD_COUNT, { folderId: feed.folderId, delta: -feed.unreadCount }) From 26557e4a61f8ed2372cbe955f6ce7660f904f44d Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Sat, 5 Oct 2024 15:16:29 +0000 Subject: [PATCH 07/12] fix: add missing keys for navigation Signed-off-by: Wolfgang --- src/components/feed-display/FeedItemDisplayList.vue | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/components/feed-display/FeedItemDisplayList.vue b/src/components/feed-display/FeedItemDisplayList.vue index c5c32ff31c..dfe6b4861b 100644 --- a/src/components/feed-display/FeedItemDisplayList.vue +++ b/src/components/feed-display/FeedItemDisplayList.vue @@ -28,12 +28,24 @@ + + + +
Date: Mon, 7 Oct 2024 14:20:51 +0200 Subject: [PATCH 08/12] Update lib/Listeners/UserSettingsListener.php Co-authored-by: Sean Molenaar Signed-off-by: Wolfgang --- lib/Listeners/UserSettingsListener.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Listeners/UserSettingsListener.php b/lib/Listeners/UserSettingsListener.php index 35f3abb44f..1ed809be43 100644 --- a/lib/Listeners/UserSettingsListener.php +++ b/lib/Listeners/UserSettingsListener.php @@ -16,14 +16,14 @@ class UserSettingsListener implements IEventListener { public function handle(Event $event): void { - if ($event instanceof BeforePreferenceSetEvent) { - if ($event->getAppId() === 'news') { - $event->setValid(true); - } - } elseif ($event instanceof BeforePreferenceDeletedEvent) { - if ($event->getAppId() === 'news') { - $event->setValid(true); - } + if (!($event instanceof BeforePreferenceSetEvent || $event instanceof BeforePreferenceDeletedEvent)) { + return; } + + if ($event->getAppId() !== 'news') { + return; + } + + $event->setValid(true); } } From ea380f19992158f884dd2c2198b36288d2d2e272 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Thu, 10 Oct 2024 17:39:39 +0000 Subject: [PATCH 09/12] fix: only show unread when showAll is disabled and no extra filter is set Signed-off-by: Wolfgang --- src/components/feed-display/FeedItemDisplayList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/feed-display/FeedItemDisplayList.vue b/src/components/feed-display/FeedItemDisplayList.vue index dfe6b4861b..26ff5a97f7 100644 --- a/src/components/feed-display/FeedItemDisplayList.vue +++ b/src/components/feed-display/FeedItemDisplayList.vue @@ -202,7 +202,7 @@ export default Vue.extend({ this.$emit('load-more') }, noFilter(item: FeedItem): boolean { - return this.$store.getters.showAll ? true : item.unread || item.starred + return this.$store.getters.showAll ? true : item.unread }, starFilter(item: FeedItem): boolean { return item.starred From d4397c5967c375de62089ab22de60711f6124a61 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Sun, 13 Oct 2024 14:07:54 +0000 Subject: [PATCH 10/12] fix: remove unused options for non existing compact mode add changelog entry Signed-off-by: Wolfgang Signed-off-by: Benjamin Brahmer --- CHANGELOG.md | 1 + lib/Controller/PageController.php | 5 ++--- src/components/Sidebar.vue | 20 -------------------- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fe4ba5e1f6..86cdb0bcf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ You can also check [on GitHub](https://github.com/nextcloud/news/releases), the ### Changed ### Fixed +- First features for user settings after vue migration (#2795) # Releases ## [25.0.0-alpha10] - 2024-10-14 diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 75582d2788..223682a011 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -18,7 +18,6 @@ use OCP\IRequest; use OCP\IAppConfig; use OCP\Util; -use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; use OCP\AppFramework\Http\TemplateResponse; @@ -36,7 +35,7 @@ class PageController extends Controller use JSONHttpErrorTrait; /** - * @var IConfig + * @var IAppConfig */ private $settings; @@ -67,7 +66,7 @@ class PageController extends Controller public function __construct( IRequest $request, - IConfig $settings, + IAppConfig $settings, IURLGenerator $urlGenerator, IL10N $l10n, RecommendedSites $recommendedSites, diff --git a/src/components/Sidebar.vue b/src/components/Sidebar.vue index 48a36edad3..b6fd72522a 100644 --- a/src/components/Sidebar.vue +++ b/src/components/Sidebar.vue @@ -130,26 +130,6 @@ {{ t('news', 'Disable mark read through scrolling') }}
-
Date: Mon, 14 Oct 2024 10:54:14 +0200 Subject: [PATCH 11/12] fix test, code and style Signed-off-by: Benjamin Brahmer --- lib/Controller/PageController.php | 61 +++++--------------- lib/Listeners/UserSettingsListener.php | 20 ++++--- tests/Unit/Controller/PageControllerTest.php | 12 +++- 3 files changed, 36 insertions(+), 57 deletions(-) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 223682a011..9ec6065652 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -18,6 +18,7 @@ use OCP\IRequest; use OCP\IAppConfig; use OCP\Util; +use OCP\IConfig; use OCP\IL10N; use OCP\IURLGenerator; use OCP\AppFramework\Http\TemplateResponse; @@ -34,53 +35,18 @@ class PageController extends Controller { use JSONHttpErrorTrait; - /** - * @var IAppConfig - */ - private $settings; - - /** - * @var IL10N - */ - private $l10n; - - /** - * @var IURLGenerator - */ - private $urlGenerator; - - /** - * @var RecommendedSites - */ - private $recommendedSites; - - /** - * @var StatusService - */ - private $statusService; - - /* - * @var IInitialState - */ - private $initialState; - public function __construct( IRequest $request, - IAppConfig $settings, - IURLGenerator $urlGenerator, - IL10N $l10n, - RecommendedSites $recommendedSites, - StatusService $statusService, - IInitialState $initialState, - ?IUserSession $userSession + ?IUserSession $userSession, + private IAppConfig $settings, + private IConfig $config, + private IURLGenerator $urlGenerator, + private IL10N $l10n, + private RecommendedSites $recommendedSites, + private StatusService $statusService, + private IInitialState $initialState ) { parent::__construct($request, $userSession); - $this->settings = $settings; - $this->urlGenerator = $urlGenerator; - $this->l10n = $l10n; - $this->recommendedSites = $recommendedSites; - $this->statusService = $statusService; - $this->initialState = $initialState; } @@ -116,13 +82,14 @@ public function index(): TemplateResponse 'oldestFirst', 'showAll' ]; + foreach ($usersettings as $setting) { - $this->initialState->provideInitialState($setting, $this->settings->getUserValue( + $this->initialState->provideInitialState($setting, $this->config->getUserValue( $this->getUserId(), $this->appName, - $setting, - '0') - ); + $setting, + '0' + )); } $csp = new ContentSecurityPolicy(); diff --git a/lib/Listeners/UserSettingsListener.php b/lib/Listeners/UserSettingsListener.php index 1ed809be43..92d57871ab 100644 --- a/lib/Listeners/UserSettingsListener.php +++ b/lib/Listeners/UserSettingsListener.php @@ -13,17 +13,19 @@ use OCP\EventDispatcher\IEventListener; /** @template-implements IEventListener */ -class UserSettingsListener implements IEventListener { +class UserSettingsListener implements IEventListener +{ - public function handle(Event $event): void { - if (!($event instanceof BeforePreferenceSetEvent || $event instanceof BeforePreferenceDeletedEvent)) { - return; - } + public function handle(Event $event): void + { + if (!($event instanceof BeforePreferenceSetEvent || $event instanceof BeforePreferenceDeletedEvent)) { + return; + } - if ($event->getAppId() !== 'news') { + if ($event->getAppId() !== 'news') { return; - } + } - $event->setValid(true); - } + $event->setValid(true); + } } diff --git a/tests/Unit/Controller/PageControllerTest.php b/tests/Unit/Controller/PageControllerTest.php index 7f0b144a06..af0399fa45 100644 --- a/tests/Unit/Controller/PageControllerTest.php +++ b/tests/Unit/Controller/PageControllerTest.php @@ -26,6 +26,7 @@ use OCP\IURLGenerator; use OCP\IUser; use OCP\IUserSession; +use OCP\AppFramework\Services\IInitialState; use PHPUnit\Framework\TestCase; class PageControllerTest extends TestCase @@ -86,6 +87,11 @@ class PageControllerTest extends TestCase */ private $userSession; + /** + * @var \PHPUnit\Framework\MockObject\MockObject|IInitialState + */ + private $initialState; + /** * Gets run before each test */ @@ -131,6 +137,9 @@ public function setUp(): void $this->userSession->expects($this->any()) ->method('getUser') ->will($this->returnValue($this->user)); + $this->initialState = $this->getMockBuilder(IInitialState::class) + ->disableOriginalConstructor() + ->getMock(); $this->controller = new PageController( $this->request, $this->userSession, @@ -139,7 +148,8 @@ public function setUp(): void $this->urlGenerator, $this->l10n, $this->recommended, - $this->status + $this->status, + $this->initialState ); } From e6ed7282a54addf24091a75067a5b339e40b59e5 Mon Sep 17 00:00:00 2001 From: Wolfgang Date: Mon, 14 Oct 2024 18:58:15 +0000 Subject: [PATCH 12/12] fix: code and style Signed-off-by: Wolfgang --- src/components/modals/HelpModal.vue | 3 ++- src/dataservices/item.service.ts | 2 +- src/store/app.ts | 25 +++++++++++++++---------- src/store/item.ts | 6 +++--- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/components/modals/HelpModal.vue b/src/components/modals/HelpModal.vue index 4a9fde964f..10d1aea1a3 100644 --- a/src/components/modals/HelpModal.vue +++ b/src/components/modals/HelpModal.vue @@ -148,7 +148,8 @@