Kaynağa Gözat

Better view mode

- Seperate view mode from default state in conf
- Load read articles if no unread articles only if view is adaptive

See https://github.com/marienfressinaud/FreshRSS/issues/634
Marien Fressinaud 11 yıl önce
ebeveyn
işleme
9551145200

+ 1 - 1
app/Controllers/configureController.php

@@ -104,7 +104,7 @@ class FreshRSS_configure_Controller extends Minz_ActionController {
 		if (Minz_Request::isPost()) {
 			FreshRSS_Context::$conf->_posts_per_page(Minz_Request::param('posts_per_page', 10));
 			FreshRSS_Context::$conf->_view_mode(Minz_Request::param('view_mode', 'normal'));
-			FreshRSS_Context::$conf->_default_view((int)Minz_Request::param('default_view', FreshRSS_Entry::STATE_ALL));
+			FreshRSS_Context::$conf->_default_view(Minz_Request::param('default_view', 'adaptive'));
 			FreshRSS_Context::$conf->_auto_load_more(Minz_Request::param('auto_load_more', false));
 			FreshRSS_Context::$conf->_display_posts(Minz_Request::param('display_posts', false));
 			FreshRSS_Context::$conf->_display_categories(Minz_Request::param('display_categories', false));

+ 3 - 3
app/Controllers/indexController.php

@@ -126,13 +126,13 @@ class FreshRSS_index_Controller extends Minz_ActionController {
 	private function updateContext() {
 		FreshRSS_Context::_get(Minz_Request::param('get', 'a'));
 
-		// TODO: change default_view by default_state.
 		FreshRSS_Context::$state = Minz_Request::param(
-			'state', FreshRSS_Context::$conf->default_view
+			'state', FreshRSS_Context::$conf->default_state
 		);
 		$state_forced_by_user = Minz_Request::param('state', false) !== false;
-		if (FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_NOT_READ) &&
+		if (FreshRSS_Context::$conf->default_view === 'adaptive' &&
 				FreshRSS_Context::$get_unread <= 0 &&
+				!FreshRSS_Context::isStateEnabled(FreshRSS_Entry::STATE_READ) &&
 				!$state_forced_by_user) {
 			FreshRSS_Context::$state |= FreshRSS_Entry::STATE_READ;
 		}

+ 13 - 8
app/Models/Configuration.php

@@ -14,7 +14,8 @@ class FreshRSS_Configuration {
 		'apiPasswordHash' => '',	//CRYPT_BLOWFISH
 		'posts_per_page' => 20,
 		'view_mode' => 'normal',
-		'default_view' => FreshRSS_Entry::STATE_NOT_READ,
+		'default_view' => 'adaptive',
+		'default_state' => FreshRSS_Entry::STATE_NOT_READ,
 		'auto_load_more' => true,
 		'display_posts' => false,
 		'display_categories' => false,
@@ -153,18 +154,22 @@ class FreshRSS_Configuration {
 	}
 	public function _default_view($value) {
 		switch ($value) {
-		case FreshRSS_Entry::STATE_ALL:
-			// left blank on purpose
-		case FreshRSS_Entry::STATE_NOT_READ:
-			// left blank on purpose
-		case FreshRSS_Entry::STATE_STRICT + FreshRSS_Entry::STATE_NOT_READ:
+		case 'all':
 			$this->data['default_view'] = $value;
+			$this->data['default_state'] = (FreshRSS_Entry::STATE_READ +
+			                                FreshRSS_Entry::STATE_NOT_READ);
 			break;
+		case 'adaptive':
+		case 'unread':
 		default:
-			$this->data['default_view'] = FreshRSS_Entry::STATE_ALL;
-			break;
+			$this->data['default_view'] = $value;
+			$this->data['default_state'] = FreshRSS_Entry::STATE_NOT_READ;
 		}
 	}
+	public function _default_state($value) {
+		$this->data['default_state'] = (int)$value;
+	}
+
 	public function _display_posts($value) {
 		$this->data['display_posts'] = ((bool)$value) && $value !== 'no';
 	}

+ 3 - 3
app/views/configure/reading.phtml

@@ -39,9 +39,9 @@
 			<label class="group-name" for="view_mode"><?php echo _t('articles_to_display'); ?></label>
 			<div class="group-controls">
 				<select name="default_view" id="default_view">
-					<option value="<?php echo FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo FreshRSS_Context::$conf->default_view === FreshRSS_Entry::STATE_NOT_READ ? ' selected="selected"' : ''; ?>><?php echo _t('show_adaptive'); ?></option>
-					<option value="<?php echo FreshRSS_Entry::STATE_ALL; ?>"<?php echo FreshRSS_Context::$conf->default_view === FreshRSS_Entry::STATE_ALL ? ' selected="selected"' : ''; ?>><?php echo _t('show_all_articles'); ?></option>
-					<option value="<?php echo FreshRSS_Entry::STATE_STRICT + FreshRSS_Entry::STATE_NOT_READ; ?>"<?php echo FreshRSS_Context::$conf->default_view === FreshRSS_Entry::STATE_STRICT + FreshRSS_Entry::STATE_NOT_READ ? ' selected="selected"' : ''; ?>><?php echo _t('show_not_reads'); ?></option>
+					<option value="adaptive"<?php echo FreshRSS_Context::$conf->default_view === 'adaptive' ? ' selected="selected"' : ''; ?>><?php echo _t('show_adaptive'); ?></option>
+					<option value="all"<?php echo FreshRSS_Context::$conf->default_view === 'all' ? ' selected="selected"' : ''; ?>><?php echo _t('show_all_articles'); ?></option>
+					<option value="unread"<?php echo FreshRSS_Context::$conf->default_view === 'unread' ? ' selected="selected"' : ''; ?>><?php echo _t('show_not_reads'); ?></option>
 				</select>
 			</div>
 		</div>