mirror of
https://github.com/ilyakooo0/urbit.git
synced 2025-01-03 20:52:23 +03:00
chat: style and safety fixes for nested objects
This commit is contained in:
parent
0014a48d74
commit
8166115751
@ -240,9 +240,11 @@ export class ChatScreen extends Component {
|
||||
|
||||
let title = props.station.substr(1);
|
||||
|
||||
if ((props.association) && (props.association.metadata)) {
|
||||
title = (props.association.metadata.title !== "")
|
||||
? props.association.metadata.title : props.station.substr(1);
|
||||
if (props.association && "metadata" in props.association) {
|
||||
title =
|
||||
props.association.metadata.title !== ""
|
||||
? props.association.metadata.title
|
||||
: props.station.substr(1);
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -52,9 +52,11 @@ export class MemberScreen extends Component {
|
||||
|
||||
let title = props.station.substr(1);
|
||||
|
||||
if ((props.association) && (props.association.metadata)) {
|
||||
title = (props.association.metadata.title !== "")
|
||||
? props.association.metadata.title : props.station.substr(1);
|
||||
if (props.association && "metadata" in props.association) {
|
||||
title =
|
||||
props.association.metadata.title !== ""
|
||||
? props.association.metadata.title
|
||||
: props.station.substr(1);
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -154,16 +154,18 @@ export class Root extends Component {
|
||||
};
|
||||
|
||||
let roomContacts = {};
|
||||
let associatedGroup = ((associations.chat[station]) &&
|
||||
(associations.chat[station]["group-path"]))
|
||||
? associations.chat[station]["group-path"] : "";
|
||||
let associatedGroup =
|
||||
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]
|
||||
}
|
||||
|
||||
let association = (associations.chat[station])
|
||||
? associations.chat[station] : {};
|
||||
let association =
|
||||
station in associations["chat"] ? associations.chat[station] : {};
|
||||
|
||||
|
||||
let group = state.groups[station] || new Set([]);
|
||||
@ -215,8 +217,8 @@ export class Root extends Component {
|
||||
};
|
||||
let popout = props.match.url.includes("/popout/");
|
||||
|
||||
let association = (associations.chat[station])
|
||||
? associations.chat[station] : {};
|
||||
let association =
|
||||
station in associations["chat"] ? associations.chat[station] : {};
|
||||
|
||||
return (
|
||||
<Skeleton
|
||||
@ -255,8 +257,8 @@ export class Root extends Component {
|
||||
|
||||
let popout = props.match.url.includes("/popout/");
|
||||
|
||||
let association = (associations.chat[station])
|
||||
? associations.chat[station] : {};
|
||||
let association =
|
||||
station in associations["chat"] ? associations.chat[station] : {};
|
||||
|
||||
return (
|
||||
<Skeleton
|
||||
|
@ -26,11 +26,12 @@ export class SettingsScreen extends Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
if ((this.props.association) && (this.props.association.metadata)) {
|
||||
const { props } = this;
|
||||
if (props.association && "metadata" in props.association) {
|
||||
this.setState({
|
||||
title: this.props.association.metadata.title,
|
||||
description: this.props.association.metadata.description,
|
||||
color: uxToHex(this.props.association.metadata.color)
|
||||
title: props.association.metadata.title,
|
||||
description: props.association.metadata.description,
|
||||
color: uxToHex(props.association.metadata.color)
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -47,11 +48,12 @@ export class SettingsScreen extends Component {
|
||||
}
|
||||
|
||||
if ((this.state.title === "") && (prevProps !== this.props)) {
|
||||
if ((props.association) && (props.association.metadata))
|
||||
this.setState({
|
||||
title: props.association.metadata.title,
|
||||
description: props.association.metadata.description,
|
||||
color: uxToHex(props.association.metadata.color)});
|
||||
if (props.association && "metadata" in props.association)
|
||||
this.setState({
|
||||
title: props.association.metadata.title,
|
||||
description: props.association.metadata.description,
|
||||
color: uxToHex(props.association.metadata.color)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +111,7 @@ export class SettingsScreen extends Component {
|
||||
|
||||
let chatOwner = (deSig(props.match.params.ship) === window.ship);
|
||||
|
||||
let association = ((props.association) && (props.association.metadata))
|
||||
let association = (props.association) && ("metadata" in props.association)
|
||||
? props.association : {};
|
||||
|
||||
return(
|
||||
@ -236,7 +238,7 @@ export class SettingsScreen extends Component {
|
||||
|
||||
let title = props.station.substr(1);
|
||||
|
||||
if ((props.association) && (props.association.metadata)) {
|
||||
if ((props.association) && ("metadata" in props.association)) {
|
||||
title = (props.association.metadata.title !== "")
|
||||
? props.association.metadata.title : props.station.substr(1);
|
||||
}
|
||||
@ -279,7 +281,7 @@ export class SettingsScreen extends Component {
|
||||
|
||||
let title = props.station.substr(1);
|
||||
|
||||
if ((props.association) && (props.association.metadata)) {
|
||||
if ((props.association) && ("metadata" in props.association)) {
|
||||
title = (props.association.metadata.title !== "")
|
||||
? props.association.metadata.title : props.station.substr(1);
|
||||
}
|
||||
|
@ -40,15 +40,20 @@ export class Sidebar extends Component {
|
||||
let when = !!msg ? msg.when : 0;
|
||||
|
||||
let title = box.substr(1);
|
||||
if ((props.associations.chat[box]) && (props.associations.chat[box].metadata)) {
|
||||
title = (props.associations.chat[box].metadata.title)
|
||||
? props.associations.chat[box].metadata.title : box.substr(1);
|
||||
if (
|
||||
box in props.associations["chat"] &&
|
||||
props.associations.chat[box].metadata
|
||||
) {
|
||||
title = props.associations.chat[box].metadata.title
|
||||
? props.associations.chat[box].metadata.title
|
||||
: box.substr(1);
|
||||
}
|
||||
|
||||
let nickname = author;
|
||||
if ((props.contacts[box]) && (author in props.contacts[box])) {
|
||||
nickname = (props.contacts[box][author].nickname)
|
||||
? props.contacts[box][author].nickname : author;
|
||||
if (box in props.contacts && author in props.contacts[box]) {
|
||||
nickname = props.contacts[box][author].nickname
|
||||
? props.contacts[box][author].nickname
|
||||
: author;
|
||||
}
|
||||
|
||||
return {
|
||||
|
@ -18,7 +18,7 @@ export class MetadataReducer {
|
||||
Object.keys(data).map((channel) => {
|
||||
let channelObj = data[channel];
|
||||
let app = data[channel]["app-name"];
|
||||
if (!metadata[app]) {
|
||||
if (!(app in metadata)) {
|
||||
metadata[app] = {};
|
||||
}
|
||||
metadata[app][channelObj["app-path"]] = channelObj;
|
||||
@ -32,7 +32,7 @@ export class MetadataReducer {
|
||||
if (data) {
|
||||
let metadata = state.associations;
|
||||
let app = data["app-name"];
|
||||
if (!metadata[app]) {
|
||||
if (!(app in metadata)) {
|
||||
metadata[app] = {};
|
||||
}
|
||||
metadata[app][data["app-path"]] = data;
|
||||
@ -55,7 +55,7 @@ export class MetadataReducer {
|
||||
if (data) {
|
||||
let metadata = state.associations;
|
||||
let app = data["app-name"];
|
||||
if (!metadata[app]) {
|
||||
if (!(app in metadata)) {
|
||||
return false;
|
||||
}
|
||||
delete metadata[app][data["app-path"]];
|
||||
|
Loading…
Reference in New Issue
Block a user