Merge pull request #647 from po5/null-checks

client: add null checks
This commit is contained in:
Neo 2024-04-27 21:23:16 +02:00 committed by GitHub
commit d102578b54
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 21 additions and 21 deletions

View file

@ -91,16 +91,16 @@ class PoolController {
_evtUpdate(e) { _evtUpdate(e) {
this._view.clearMessages(); this._view.clearMessages();
this._view.disableForm(); this._view.disableForm();
if (e.detail.names !== undefined) { if (e.detail.names !== undefined && e.detail.names !== null) {
e.detail.pool.names = e.detail.names; e.detail.pool.names = e.detail.names;
} }
if (e.detail.category !== undefined) { if (e.detail.category !== undefined && e.detail.category !== null) {
e.detail.pool.category = e.detail.category; e.detail.pool.category = e.detail.category;
} }
if (e.detail.description !== undefined) { if (e.detail.description !== undefined && e.detail.description !== null) {
e.detail.pool.description = e.detail.description; e.detail.pool.description = e.detail.description;
} }
if (e.detail.posts !== undefined) { if (e.detail.posts !== undefined && e.detail.posts !== null) {
e.detail.pool.posts.clear(); e.detail.pool.posts.clear();
for (let postId of e.detail.posts) { for (let postId of e.detail.posts) {
e.detail.pool.posts.add( e.detail.pool.posts.add(

View file

@ -169,22 +169,22 @@ class PostMainController extends BasePostController {
this._view.sidebarControl.disableForm(); this._view.sidebarControl.disableForm();
this._view.sidebarControl.clearMessages(); this._view.sidebarControl.clearMessages();
const post = e.detail.post; const post = e.detail.post;
if (e.detail.safety !== undefined) { if (e.detail.safety !== undefined && e.detail.safety !== null) {
post.safety = e.detail.safety; post.safety = e.detail.safety;
} }
if (e.detail.flags !== undefined) { if (e.detail.flags !== undefined && e.detail.flags !== null) {
post.flags = e.detail.flags; post.flags = e.detail.flags;
} }
if (e.detail.relations !== undefined) { if (e.detail.relations !== undefined && e.detail.relations !== null) {
post.relations = e.detail.relations; post.relations = e.detail.relations;
} }
if (e.detail.content !== undefined) { if (e.detail.content !== undefined && e.detail.content !== null) {
post.newContent = e.detail.content; post.newContent = e.detail.content;
} }
if (e.detail.thumbnail !== undefined) { if (e.detail.thumbnail !== undefined && e.detail.thumbnail !== null) {
post.newThumbnail = e.detail.thumbnail; post.newThumbnail = e.detail.thumbnail;
} }
if (e.detail.source !== undefined) { if (e.detail.source !== undefined && e.detail.source !== null) {
post.source = e.detail.source; post.source = e.detail.source;
} }
post.save().then( post.save().then(

View file

@ -95,13 +95,13 @@ class TagController {
_evtUpdate(e) { _evtUpdate(e) {
this._view.clearMessages(); this._view.clearMessages();
this._view.disableForm(); this._view.disableForm();
if (e.detail.names !== undefined) { if (e.detail.names !== undefined && e.detail.names !== null) {
e.detail.tag.names = e.detail.names; e.detail.tag.names = e.detail.names;
} }
if (e.detail.category !== undefined) { if (e.detail.category !== undefined && e.detail.category !== null) {
e.detail.tag.category = e.detail.category; e.detail.tag.category = e.detail.category;
} }
if (e.detail.description !== undefined) { if (e.detail.description !== undefined && e.detail.description !== null) {
e.detail.tag.description = e.detail.description; e.detail.tag.description = e.detail.description;
} }
e.detail.tag.save().then( e.detail.tag.save().then(

View file

@ -175,21 +175,21 @@ class UserController {
const isLoggedIn = api.isLoggedIn(e.detail.user); const isLoggedIn = api.isLoggedIn(e.detail.user);
const infix = isLoggedIn ? "self" : "any"; const infix = isLoggedIn ? "self" : "any";
if (e.detail.name !== undefined) { if (e.detail.name !== undefined && e.detail.name !== null) {
e.detail.user.name = e.detail.name; e.detail.user.name = e.detail.name;
} }
if (e.detail.email !== undefined) { if (e.detail.email !== undefined && e.detail.email !== null) {
e.detail.user.email = e.detail.email; e.detail.user.email = e.detail.email;
} }
if (e.detail.rank !== undefined) { if (e.detail.rank !== undefined && e.detail.rank !== null) {
e.detail.user.rank = e.detail.rank; e.detail.user.rank = e.detail.rank;
} }
if (e.detail.password !== undefined) { if (e.detail.password !== undefined && e.detail.password !== null) {
e.detail.user.password = e.detail.password; e.detail.user.password = e.detail.password;
} }
if (e.detail.avatarStyle !== undefined) { if (e.detail.avatarStyle !== undefined && e.detail.avatarStyle !== null) {
e.detail.user.avatarStyle = e.detail.avatarStyle; e.detail.user.avatarStyle = e.detail.avatarStyle;
if (e.detail.avatarContent) { if (e.detail.avatarContent) {
e.detail.user.avatarContent = e.detail.avatarContent; e.detail.user.avatarContent = e.detail.avatarContent;
@ -302,7 +302,7 @@ class UserController {
this._view.clearMessages(); this._view.clearMessages();
this._view.disableForm(); this._view.disableForm();
if (e.detail.note !== undefined) { if (e.detail.note !== undefined && e.detail.note !== null) {
e.detail.userToken.note = e.detail.note; e.detail.userToken.note = e.detail.note;
} }

View file

@ -427,7 +427,7 @@ class PostEditSidebarControl extends events.EventTarget {
: undefined, : undefined,
thumbnail: thumbnail:
this._newPostThumbnail !== undefined this._newPostThumbnail !== undefined && this._newPostThumbnail !== null
? this._newPostThumbnail ? this._newPostThumbnail
: undefined, : undefined,

View file

@ -271,7 +271,7 @@ class Post extends events.EventTarget {
if (this._newContent) { if (this._newContent) {
files.content = this._newContent; files.content = this._newContent;
} }
if (this._newThumbnail !== undefined) { if (this._newThumbnail !== undefined && this._newThumbnail !== null) {
files.thumbnail = this._newThumbnail; files.thumbnail = this._newThumbnail;
} }
if (this._source !== this._orig._source) { if (this._source !== this._orig._source) {