Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
Update simpler use
Browse files Browse the repository at this point in the history
- Better navigation
  • Loading branch information
lepLinus committed Oct 7, 2022
1 parent e17187a commit fed884a
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 96 deletions.
2 changes: 0 additions & 2 deletions src/js/components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ class Footer extends Component<Props, State> {
return (
<footer class="visible-xs-flex nav footer">
<div class="header-content" onClick={() => State.local.get('scrollUp').put(true)}>
<a href="/" class={`btn ${activeRoute === '/' ? 'active' : ''}`}>{Icons.home}</a>
<a href="/chat" class={`btn ${activeRoute.indexOf('/chat') === 0 ? 'active' : ''}`}>
{this.state.unseenMsgsTotal ? <span class="unseen unseen-total">{this.state.unseenMsgsTotal}</span>: ''}
{Icons.chat}
</a>
<a href="/post/new" class={`btn ${activeRoute === '/post/new' ? 'active' : ''}`}>{plusIcon}</a>
<a href="/contacts" class={`btn ${activeRoute === '/contacts' ? 'active' : ''}`}>{Icons.user}</a>
<a href={`/profile/${key}`} class={`${activeRoute === `/profile/${ key}` ? 'active' : ''} my-profile`}>
<Identicon str={key} width={34} />
Expand Down
18 changes: 10 additions & 8 deletions src/js/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Component from '../BaseComponent';
import Helpers from '../Helpers';
import { html } from 'htm/preact';
import { translate as t } from '../translations/Translation';
import State from 'iris-lib/src/State';
Expand Down Expand Up @@ -137,13 +136,7 @@ class Header extends Component {
</div>
` : ''}
<div class="header-content">
<div class="mobile-search-hidden ${this.state.showMobileSearch ? 'hidden-xs':''}">
${Helpers.isElectron || chatting ? '' : html`
<a href="/" onClick=${e => this.onLogoClick(e)} class="visible-xs-flex logo">
<div class="mobile-menu-icon">${Icons.menu}</div>
</a>
`}
</div>
${chatting ? '' : html`
<a class="mobile-search-visible ${this.state.showMobileSearch ? '' : 'hidden-xs'}" href="" onClick=${e => {
e.preventDefault();
Expand All @@ -152,6 +145,15 @@ class Header extends Component {
<span class="visible-xs-inline-block">${Icons.backArrow}</span>
</a>
`}
${
window.innerWidth > 624 ? html`
<a href="/" style="margin-right: 15px;">
<small>
<span class="icon">${Icons.home}</span>
</small>
</a>`
: ''
}
<a href="/settings/peer" class="connected-peers tooltip mobile-search-hidden ${this.state.showMobileSearch ? 'hidden-xs' : ''} ${peerCount ? 'connected' : ''}">
<span class="tooltiptext">${t('connected_peers')}</span>
<small>
Expand Down
80 changes: 80 additions & 0 deletions src/js/components/NotificationsComponent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { html } from 'htm/preact';
import State from 'iris-lib/src/State';
import Identicon from '../components/Identicon';
import Button from '../components/basic/Button';
import {translate as t} from '../translations/Translation';
import Name from '../components/Name';
import NotificationTools from "iris-lib/src/Notifications";
import util from "iris-lib/src/util";
import { Component } from 'preact';
const PAGE_SIZE = 10;

export default class NotificationsComponent extends Component{
notifications = {};
class = 'public-messages-view';
state = {
displayCount: PAGE_SIZE
}

componentDidMount() {
NotificationTools.changeUnseenNotificationCount(0);
State.local.get('notifications').map(
(notification, time) => {
if (notification) {
this.notifications[time] = notification;
NotificationTools.getNotificationText(notification).then(text => {
this.notifications[time].text = text;
this.setState({});
});
} else {
delete this.notifications[time];
}
this.setState({d:new Date().toISOString()});
}
);
}

shouldComponentUpdate() {
return true;
}

render() {
const displayCount = this.state.displayCount;
const notificationKeys = Object.keys(this.notifications).sort().reverse();
return html`
<div class="centered-container" style="margin-bottom: 15px;">
<h3>${t('notifications')}</h3>
${Object.keys(this.notifications).length === 0 ? html`
<p> ${t('no_notifications_yet')}</p>
`:''}
${notificationKeys.slice(0, this.state.displayCount).map(k => {
const notification = this.notifications[k];
return html`
<div class="msg" key=${(notification.time||'') + (notification.from||'') + (notification.target||'')}>
<div class="msg-content">
<div class="msg-sender">
<a class="msg-sender-link" href="/profile/${notification.from}">
<${Identicon} str=${notification.from} width=30 />${' '}
<small class="msgSenderName"><${Name} pub=${notification.from} /></small>
</a>
</div>
${notification.text || ''}
<div class="below-text">
<div class="time">${util.formatDate(new Date(notification.time))}</div><br/>
</div>
</div>
</div>
`;
})}
${displayCount < notificationKeys.length ? html`
<div>
<${Button} onClick=${() => this.setState({displayCount: displayCount + PAGE_SIZE})}>
${t('show_more')}
<//>
</div>
` : ''}
</div>
`;
}
}
77 changes: 3 additions & 74 deletions src/js/views/Notifications.js
Original file line number Diff line number Diff line change
@@ -1,80 +1,9 @@
import { html } from 'htm/preact';
import State from 'iris-lib/src/State';
import Identicon from '../components/Identicon';
import Button from '../components/basic/Button';
import {translate as t} from '../translations/Translation';
import Name from '../components/Name';
import View from './View';
import NotificationTools from "iris-lib/src/Notifications";
import util from "iris-lib/src/util";
const PAGE_SIZE = 10;
import NotificationsComponent from '../components/NotificationsComponent';

export default class Notifications extends View {
notifications = {};
class = 'public-messages-view';
state = {
displayCount: PAGE_SIZE
}

componentDidMount() {
NotificationTools.changeUnseenNotificationCount(0);
State.local.get('notifications').map(this.sub(
(notification, time) => {
if (notification) {
this.notifications[time] = notification;
NotificationTools.getNotificationText(notification).then(text => {
this.notifications[time].text = text;
this.setState({});
});
} else {
delete this.notifications[time];
}
this.setState({d:new Date().toISOString()});
}
));
}

shouldComponentUpdate() {
return true;
}

renderView() {
const displayCount = this.state.displayCount;
const notificationKeys = Object.keys(this.notifications).sort().reverse();
return html`
<div class="centered-container" style="margin-bottom: 15px;">
<h3>${t('notifications')}</h3>
${Object.keys(this.notifications).length === 0 ? html`
<p> ${t('no_notifications_yet')}</p>
`:''}
${notificationKeys.slice(0, this.state.displayCount).map(k => {
const notification = this.notifications[k];
return html`
<div class="msg" key=${(notification.time||'') + (notification.from||'') + (notification.target||'')}>
<div class="msg-content">
<div class="msg-sender">
<a class="msg-sender-link" href="/profile/${notification.from}">
<${Identicon} str=${notification.from} width=30 />${' '}
<small class="msgSenderName"><${Name} pub=${notification.from} /></small>
</a>
</div>
${notification.text || ''}
<div class="below-text">
<div class="time">${util.formatDate(new Date(notification.time))}</div><br/>
</div>
</div>
</div>
`;
})}
${displayCount < notificationKeys.length ? html`
<div>
<${Button} onClick=${() => this.setState({displayCount: displayCount + PAGE_SIZE})}>
${t('show_more')}
<//>
</div>
` : ''}
</div>
`;
return (<NotificationsComponent />);
}
}

24 changes: 13 additions & 11 deletions src/js/views/Profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import Web3 from 'web3';
import styled from 'styled-components';
import Channel from 'iris-lib/src/Channel';
import Attribute from 'iris-lib/src/Attribute';
import NotificationsComponent from '../components/NotificationsComponent';

const ImageGrid = styled.div`
display: grid;
Expand Down Expand Up @@ -365,20 +366,21 @@ class Profile extends View {
const title = this.state.name || 'Profile';
const ogTitle = `${title} | Iris`;
const description = `Latest posts by ${this.state.name || 'user'}. ${this.state.about || ''}`;
return html`
return (
<div class="content">
<${Helmet}>
<title>${title}</title>
<meta name="description" content=${description} />
<Helmet>
<title>{title}</title>
<meta name="description" content={description} />
<meta property="og:type" content="profile" />
${this.state.ogImageUrl ? html`<meta property="og:image" content=${this.state.ogImageUrl} />` : ''}
<meta property="og:title" content=${ogTitle} />
<meta property="og:description" content=${description} />
<//>
${this.renderDetails()}
${this.state.blocked ? '' : this.renderTab()}
{this.state.ogImageUrl ? html`<meta property="og:image" content=${this.state.ogImageUrl} />` : ''}
<meta property="og:title" content={ogTitle} />
<meta property="og:description" content={description} />
</Helmet>
{this.renderDetails()}
{this.isMyProfile? <div style="padding: 15px"> <NotificationsComponent /> </div> : ''}
{this.state.blocked ? '' : this.renderTab()}
</div>
`;
);
}

async getNfts(address) {
Expand Down
5 changes: 4 additions & 1 deletion src/js/views/settings/SettingsMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ export default class SettingsMenu extends Component{
);
}
)}
<a href="#" onClick={() => route(`/`)} >
<span class="text">Back</span>
</a>
</div>
</>
</>
);
}
}

0 comments on commit fed884a

Please sign in to comment.