interface: always show sidebar on nav

This commit is contained in:
Liam Fitzgerald 2020-06-23 10:43:13 +10:00
parent 555857513a
commit 292c5625e3
3 changed files with 57 additions and 49 deletions

View File

@ -1,20 +1,20 @@
import React from "react";
import { Route, Switch } from "react-router-dom";
import React from 'react';
import { Route, Switch } from 'react-router-dom';
import "./css/custom.css";
import './css/custom.css';
import { Skeleton } from "./components/skeleton";
import { Sidebar } from "./components/sidebar";
import { ChatScreen } from "./components/chat";
import { MemberScreen } from "./components/member";
import { SettingsScreen } from "./components/settings";
import { NewScreen } from "./components/new";
import { JoinScreen } from "./components/join";
import { NewDmScreen } from "./components/new-dm";
import { PatpNoSig } from "../../types/noun";
import GlobalApi from "../../api/global";
import { StoreState } from "../../store/type";
import GlobalSubscription from "../../subscription/global";
import { Skeleton } from './components/skeleton';
import { Sidebar } from './components/sidebar';
import { ChatScreen } from './components/chat';
import { MemberScreen } from './components/member';
import { SettingsScreen } from './components/settings';
import { NewScreen } from './components/new';
import { JoinScreen } from './components/join';
import { NewDmScreen } from './components/new-dm';
import { PatpNoSig } from '../../types/noun';
import GlobalApi from '../../api/global';
import { StoreState } from '../../store/type';
import GlobalSubscription from '../../subscription/global';
type ChatAppProps = StoreState & {
ship: PatpNoSig;
@ -30,13 +30,15 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
}
componentDidMount() {
document.title = "OS1 - Chat";
document.title = 'OS1 - Chat';
// preload spinner asset
new Image().src = "/~landscape/img/Spinner.png";
new Image().src = '/~landscape/img/Spinner.png';
this.props.subscription.startApp('chat');
if (!this.props.sidebarShown) {
this.props.api.local.sidebarToggle();
}
}
componentWillUnmount() {
@ -76,8 +78,8 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
.map((e) => {
return e[0];
})
.includes(associations.chat?.[stat]?.["group-path"]) ||
associations.chat?.[stat]?.["group-path"].startsWith("/~/"))
.includes(associations.chat?.[stat]?.['group-path']) ||
associations.chat?.[stat]?.['group-path'].startsWith('/~/'))
) {
totalUnreads += unread;
}
@ -85,11 +87,10 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
if (totalUnreads !== this.totalUnreads) {
document.title =
totalUnreads > 0 ? `OS1 - Chat (${totalUnreads})` : "OS1 - Chat";
totalUnreads > 0 ? `OS1 - Chat (${totalUnreads})` : 'OS1 - Chat';
this.totalUnreads = totalUnreads;
}
const {
invites,
s3,
@ -110,7 +111,7 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
associations={associations}
selectedGroups={selectedGroups}
contacts={contacts}
invites={invites["/chat"] || {}}
invites={invites['/chat'] || {}}
unreads={unreads}
api={api}
station={station}
@ -118,7 +119,6 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
/>
);
return (
<Switch>
<Route
@ -202,9 +202,9 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
path="/~chat/join/(~)?/:ship?/:station?"
render={(props) => {
let station = `/${props.match.params.ship}/${props.match.params.station}`;
const sig = props.match.url.includes("/~/");
const sig = props.match.url.includes('/~/');
if (sig) {
station = "/~" + station;
station = '/~' + station;
}
return (
@ -231,40 +231,40 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
path="/~chat/(popout)?/room/(~)?/:ship/:station+"
render={(props) => {
let station = `/${props.match.params.ship}/${props.match.params.station}`;
const sig = props.match.url.includes("/~/");
const sig = props.match.url.includes('/~/');
if (sig) {
station = "/~" + station;
station = '/~' + station;
}
const mailbox = inbox[station] || {
config: {
read: 0,
length: 0,
length: 0
},
envelopes: [],
envelopes: []
};
let roomContacts = {};
const associatedGroup =
station in associations["chat"] &&
"group-path" in associations.chat[station]
? associations.chat[station]["group-path"]
: "";
station in associations['chat'] &&
'group-path' in associations.chat[station]
? associations.chat[station]['group-path']
: '';
if (associations.chat[station] && associatedGroup in contacts) {
roomContacts = contacts[associatedGroup];
}
const association =
station in associations["chat"] ? associations.chat[station] : {};
station in associations['chat'] ? associations.chat[station] : {};
const permission =
station in permissions
? permissions[station]
: {
who: new Set([]),
kind: "white",
kind: 'white'
};
const popout = props.match.url.includes("/popout/");
const popout = props.match.url.includes('/popout/');
return (
<Skeleton
@ -302,19 +302,19 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
path="/~chat/(popout)?/members/(~)?/:ship/:station+"
render={(props) => {
let station = `/${props.match.params.ship}/${props.match.params.station}`;
const sig = props.match.url.includes("/~/");
const sig = props.match.url.includes('/~/');
if (sig) {
station = "/~" + station;
station = '/~' + station;
}
const permission = permissions[station] || {
kind: "",
who: new Set([]),
kind: '',
who: new Set([])
};
const popout = props.match.url.includes("/popout/");
const popout = props.match.url.includes('/popout/');
const association =
station in associations["chat"] ? associations.chat[station] : {};
station in associations['chat'] ? associations.chat[station] : {};
return (
<Skeleton
@ -345,20 +345,20 @@ export default class ChatApp extends React.Component<ChatAppProps, {}> {
path="/~chat/(popout)?/settings/(~)?/:ship/:station+"
render={(props) => {
let station = `/${props.match.params.ship}/${props.match.params.station}`;
const sig = props.match.url.includes("/~/");
const sig = props.match.url.includes('/~/');
if (sig) {
station = "/~" + station;
station = '/~' + station;
}
const popout = props.match.url.includes("/popout/");
const popout = props.match.url.includes('/popout/');
const permission = permissions[station] || {
kind: "",
who: new Set([]),
kind: '',
who: new Set([])
};
const association =
station in associations["chat"] ? associations.chat[station] : {};
station in associations['chat'] ? associations.chat[station] : {};
return (
<Skeleton

View File

@ -32,6 +32,9 @@ export class LinksApp extends Component {
this.props.api.links.getPage('', 0);
this.props.subscription.startApp('link');
if (!this.props.sidebarShown) {
this.props.api.local.sidebarToggle();
}
}
componentWillUnmount() {

View File

@ -30,6 +30,11 @@ export default class PublishApp extends React.Component {
this.props.subscription.startApp('publish');
this.props.api.publish.fetchNotebooks();
if (!this.props.sidebarShown) {
this.props.api.local.sidebarToggle();
}
}
componentWillUnmount() {