This commit is contained in:
Martti Malmi 2023-03-17 18:03:16 +02:00
parent 807d5e1208
commit cb9148ff48
5 changed files with 12 additions and 49 deletions

View File

@ -155,7 +155,7 @@ class Main extends Component<Props, ReactState> {
<div className="view-area">
<Router onChange={(e) => this.handleRoute(e)}>
<FeedList path="/" />
<Feed path="/following" name="follows" />
<Feed path="/following" name="following" />
<Feed path="/global" name="global" />
<Feed path="/search/:term?/:type?" />
<Feed path="/feed/:name" />

View File

@ -71,8 +71,8 @@ class Feed extends Component {
getSettings(override = {}) {
// override default & saved settings with url params
let settings = { ...DEFAULT_SETTINGS };
if (['global', 'follows'].includes(this.props?.name)) {
let settings = Object.assign({ ...DEFAULT_SETTINGS }, override);
if (['global', 'following'].includes(this.props?.name)) {
settings = Object.assign(settings, override);
}
if (this.props?.name !== 'notifications' && override.display) {
@ -270,7 +270,7 @@ class Feed extends Component {
const callback = throttle(() => {
const since = Math.floor(Date.now() / 1000) - TIMESPANS[this.state.settings.timespan];
let includeReplies = true;
if (['global', 'follows'].includes(this.props.name)) {
if (['global', 'following'].includes(this.props.name)) {
includeReplies = this.state.settings.replies;
} else if (['posts', 'postsAndReplies'].includes(this.props.name)) {
includeReplies = this.props.name === 'postsAndReplies';
@ -279,7 +279,7 @@ class Feed extends Component {
.data()
.filter((e) => {
const maxFollowDistance =
this.state.settings.maxFollowDistance || this.props.name === 'follows' ? 1 : 0;
this.state.settings.maxFollowDistance || this.props.name === 'following' ? 1 : 0;
if (maxFollowDistance) {
const followDistance = SocialNetwork.followDistanceByUser.get(e.pubkey);
if (followDistance === undefined || followDistance > maxFollowDistance) {
@ -608,7 +608,7 @@ class Feed extends Component {
/>
</ErrorBoundary>
));
const isGeneralFeed = ['global', 'follows'].includes(this.props.name);
const isGeneralFeed = ['global', 'following'].includes(this.props.name);
return (
<div className="msg-feed">
<div>

View File

@ -1,38 +0,0 @@
import Component from '../BaseComponent';
import localState from '../LocalState';
import { translate as t } from '../translations/Translation';
type Props = Record<string, unknown>;
type State = {
group: string;
};
export default class Filters extends Component<Props, State> {
componentDidMount(): void {
localState.get('filters').get('group').on(this.inject());
}
toggleGroup(group: string): void {
localState.get('filters').get('group').put(group);
}
render() {
const s = this.state;
return (
<div className="msg filters">
<div className="msg-content">
<input checked={s.group === 'follows'} type="radio" />
<label onClick={() => this.toggleGroup('follows')} style="margin-right:15px">
{t('follows')}
</label>
<input checked={s.group === 'everyone'} type="radio" />
<label for="filterGroupChoice3" onClick={() => this.toggleGroup('everyone')}>
{t('everyone')}
</label>
</div>
</div>
);
}
}

View File

@ -12,7 +12,7 @@ class Feed extends View {
constructor() {
super();
this.eventListeners = {};
this.state = { sortedMessages: [], group: 'follows' };
this.state = { sortedMessages: [] };
this.messages = {};
this.id = 'message-view';
this.class = 'public-messages-view';
@ -32,7 +32,6 @@ class Feed extends View {
componentDidMount() {
this.restoreScrollPosition();
this.search();
localState.get('filters').get('group').on(this.inject());
}
filter(msg) {

View File

@ -2,7 +2,6 @@ import { route } from 'preact-router';
import Icons from '../Icons';
import localState from '../LocalState';
import { translate as t } from '../translations/Translation';
import View from './View';
@ -24,10 +23,13 @@ class FeedList extends View {
}
renderView() {
console.log('feeds', this.state.feeds);
return (
<div className="centered-container">
{Object.keys(this.state.feeds).map((key) => {
const feed = this.state.feeds[key];
{Object.entries(this.state.feeds).map((entry) => {
const key = entry[0];
const feed = entry[1];
console.log('key feed', key, feed);
if (!feed) {
return null;
}