From 11099434b5fab005e6339f4977c0ed202004afe3 Mon Sep 17 00:00:00 2001 From: Jarek Radosz Date: Mon, 18 Mar 2024 23:29:42 +0100 Subject: [PATCH] DEV: Clean up mobileView/desktopView uses (#26229) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Inspired by a piece of "do not do x if it's not a mobile view" code 🙃 --- .../app/components/basic-topic-list.js | 2 +- .../discourse/app/components/bookmark-list.hbs | 8 ++++---- .../app/components/composer-container.hbs | 18 +++++++++--------- .../app/components/composer-editor.js | 2 +- .../app/components/discourse-banner.hbs | 4 ++-- .../app/components/discourse-topic.js | 2 +- .../app/components/glimmer-header.gjs | 6 ++---- .../components/glimmer-header/topic/info.gjs | 2 +- .../app/components/glimmer-site-header.gjs | 2 +- .../discourse/app/components/mobile-nav.js | 2 +- .../discourse/app/components/modal/history.hbs | 1 - .../app/components/modal/history/revision.hbs | 17 +++++++++-------- .../app/components/modal/history/revision.js | 6 ++++++ .../app/components/modal/share-topic.js | 2 +- .../components/sidebar/section-form-link.hbs | 4 ++-- .../app/components/topic-list-item.js | 2 +- .../discourse/app/components/topic-progress.js | 4 ++-- .../app/controllers/edit-category-tabs.js | 3 +-- .../discourse/app/controllers/review-index.js | 2 +- .../instance-initializers/mobile-keyboard.js | 2 +- .../discourse/app/models/composer.js | 2 +- .../discourse/app/models/nav-item.js | 2 +- .../app/models/topic-tracking-state.js | 2 +- .../app/routes/discovery-categories.js | 2 +- .../discourse/app/services/composer.js | 2 +- .../discourse/app/services/navigation-menu.js | 2 +- .../app/templates/edit-category-tabs.hbs | 18 ++++++++---------- .../app/templates/user-invited-show.hbs | 4 ++-- .../discourse/app/widgets/header-topic-info.js | 2 +- .../discourse/app/widgets/header.js | 5 ++--- .../discourse/app/widgets/topic-admin-menu.js | 2 +- .../select-kit/addon/components/select-kit.js | 4 ++-- .../components/select-kit/select-kit-row.js | 4 ++-- .../components/chat-channel-leave-btn.gjs | 3 ++- .../discourse/components/chat/header/icon.gjs | 4 ++-- .../components/chat/thread/header.gjs | 2 +- .../discourse/services/chat-state-manager.js | 7 ++++--- .../components/chat-channel-leave-btn-test.js | 6 +++--- .../components/modal/local-dates-create.hbs | 4 ++-- 39 files changed, 85 insertions(+), 83 deletions(-) create mode 100644 app/assets/javascripts/discourse/app/components/modal/history/revision.js diff --git a/app/assets/javascripts/discourse/app/components/basic-topic-list.js b/app/assets/javascripts/discourse/app/components/basic-topic-list.js index 6ef44008076..36b305921a0 100644 --- a/app/assets/javascripts/discourse/app/components/basic-topic-list.js +++ b/app/assets/javascripts/discourse/app/components/basic-topic-list.js @@ -81,7 +81,7 @@ export default Component.extend({ click(e) { // Mobile basic-topic-list doesn't use the `topic-list-item` view so // the event for the topic entrance is never wired up. - if (!this.site.mobileView) { + if (this.site.desktopView) { return; } diff --git a/app/assets/javascripts/discourse/app/components/bookmark-list.hbs b/app/assets/javascripts/discourse/app/components/bookmark-list.hbs index 351b8b8c4ad..69c5dadac97 100644 --- a/app/assets/javascripts/discourse/app/components/bookmark-list.hbs +++ b/app/assets/javascripts/discourse/app/components/bookmark-list.hbs @@ -5,7 +5,7 @@ > - {{#unless this.site.mobileView}} + {{#if this.site.desktopView}} @@ -15,7 +15,7 @@ - {{/unless}} + {{/if}} {{#each this.content as |bookmark|}} @@ -98,7 +98,7 @@ {{on "click" this.screenExcerptForExternalLink}} >{{html-safe bookmark.excerpt}}

- {{#unless this.site.mobileView}} + {{#if this.site.desktopView}}
{{i18n "topic.title"}}    
{{#if bookmark.user.avatar_template}} {{i18n "close"}} {{/if}} - {{#if this.composer.site.mobileView}} + {{#if this.site.mobileView}} {{#if this.composer.whisperOrUnlistTopic}} {{d-icon "far-eye-slash"}} @@ -306,7 +306,7 @@ - {{#if this.composer.site.mobileView}} + {{#if this.site.mobileView}} {{/if}} - {{#unless this.site.mobileView}} + {{#if this.site.desktopView}} - {{/unless}} + {{/if}} {{else}} diff --git a/app/assets/javascripts/discourse/app/components/composer-editor.js b/app/assets/javascripts/discourse/app/components/composer-editor.js index 544f7f87dda..a1b3a08743a 100644 --- a/app/assets/javascripts/discourse/app/components/composer-editor.js +++ b/app/assets/javascripts/discourse/app/components/composer-editor.js @@ -899,7 +899,7 @@ export default Component.extend(ComposerUploadUppy, { unshift: true, }); - if (this.allowUpload && this.uploadIcon && !this.site.mobileView) { + if (this.allowUpload && this.uploadIcon && this.site.desktopView) { toolbar.addButton({ id: "upload", group: "insertions", diff --git a/app/assets/javascripts/discourse/app/components/discourse-banner.hbs b/app/assets/javascripts/discourse/app/components/discourse-banner.hbs index 82a5ea19427..4e4c98ae62b 100644 --- a/app/assets/javascripts/discourse/app/components/discourse-banner.hbs +++ b/app/assets/javascripts/discourse/app/components/discourse-banner.hbs @@ -5,9 +5,9 @@ {{#if this.currentUser.staff}} {{d-icon "pencil-alt"}} - {{#unless this.site.mobileView}} + {{#if this.site.desktopView}} {{html-safe (i18n "banner.edit")}} - {{/unless}} + {{/if}} {{/if}} diff --git a/app/assets/javascripts/discourse/app/components/discourse-topic.js b/app/assets/javascripts/discourse/app/components/discourse-topic.js index b20a7876bc6..4253cbb8034 100644 --- a/app/assets/javascripts/discourse/app/components/discourse-topic.js +++ b/app/assets/javascripts/discourse/app/components/discourse-topic.js @@ -153,7 +153,7 @@ export default Component.extend(Scrolling, MobileScrollDirection, { // On desktop the user only needs to scroll past the topic title. return ( offset > this.dockAt && - (!this.site.mobileView || this.mobileScrollDirection === "down") + (this.site.desktopView || this.mobileScrollDirection === "down") ); }, diff --git a/app/assets/javascripts/discourse/app/components/glimmer-header.gjs b/app/assets/javascripts/discourse/app/components/glimmer-header.gjs index 7d5be71afa4..8cc17788b24 100644 --- a/app/assets/javascripts/discourse/app/components/glimmer-header.gjs +++ b/app/assets/javascripts/discourse/app/components/glimmer-header.gjs @@ -161,10 +161,9 @@ export default class GlimmerHeader extends Component { @action toggleBodyScrolling(bool) { - if (!this.site.mobileView) { - return; + if (this.site.mobileView) { + scrollLock(bool); } - scrollLock(bool); } @action @@ -180,7 +179,6 @@ export default class GlimmerHeader extends Component { @toggleHamburger={{this.toggleHamburger}} @showSidebar={{@showSidebar}} > - {{#each (headerButtons.resolve) as |entry|}} {{#if (and (eq entry.key "auth") (not this.currentUser))}} diff --git a/app/assets/javascripts/discourse/app/components/glimmer-header/topic/info.gjs b/app/assets/javascripts/discourse/app/components/glimmer-header/topic/info.gjs index e733977aecc..95a5e7b976a 100644 --- a/app/assets/javascripts/discourse/app/components/glimmer-header/topic/info.gjs +++ b/app/assets/javascripts/discourse/app/components/glimmer-header/topic/info.gjs @@ -129,7 +129,7 @@ export default class Info extends Component { {{#if (and @topic.category.parentCategory.parentCategory - (not this.site.mobileView) + this.site.desktopView ) }} {{categoryLink diff --git a/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs b/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs index 3a8781ef727..ddaa54f25a8 100644 --- a/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs +++ b/app/assets/javascripts/discourse/app/components/glimmer-site-header.gjs @@ -432,7 +432,7 @@ export default class GlimmerSiteHeader extends Component {