A platform for community discussion. Free, open, simple.
UX: Drop legacy mobile-mode site settings (#40226)
David Taylor9aa52af4c9d2
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rbindex 45c2714f4db..57dfd0164ff 100644--- a/app/controllers/application_controller.rb+++ b/app/controllers/application_controller.rb@@ -40,7 +40,6 @@ class ApplicationController < ActionController::Basebefore_action :set_mp_snapshot_fieldsbefore_action :clear_notificationsaround_action :with_resolved_locale- before_action :set_mobile_viewbefore_action :block_if_readonly_modebefore_action :authorize_mini_profilerbefore_action :redirect_to_login_if_required@@ -452,10 +451,6 @@ class ApplicationController < ActionController::BaseI18n.with_locale(locale) { yield }end- def set_mobile_view- session[:mobile_view] = params[:mobile_view] if params.has_key?(:mobile_view)- end-NO_THEMES = "no_themes"NO_PLUGINS = "no_plugins"NO_UNOFFICIAL_PLUGINS = "no_unofficial_plugins"@@ -637,7 +632,7 @@ class ApplicationController < ActionController::BaseApplicationLayoutPreloader.new(guardian:,theme_id: @theme_id,- theme_target: view_context.mobile_view? ? :mobile : :desktop,+ theme_target: view_context.mobile_device? ? :mobile : :desktop,login_method:,)enddiff --git a/app/controllers/topics_controller.rb b/app/controllers/topics_controller.rbindex 4dfb4c7b4af..8c8eaf969f9 100644--- a/app/controllers/topics_controller.rb+++ b/app/controllers/topics_controller.rb@@ -1103,7 +1103,7 @@ class TopicsController < ApplicationControllertopic_id,topic_time,timings.map { |post_number, t| [post_number.to_i, t.to_i] },- mobile: view_context.mobile_view?,+ mobile: view_context.mobile_device?,)render body: nilenddiff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rbindex 8ef5f7e8c74..08be8a024c9 100644--- a/app/helpers/application_helper.rb+++ b/app/helpers/application_helper.rb@@ -196,10 +196,6 @@ module ApplicationHelperdef html_classeslist = []- unless SiteSetting.viewport_based_mobile_mode- list << (mobile_view? ? "mobile-view" : "desktop-view")- list << (mobile_device? ? "mobile-device" : "not-mobile-device")- endlist << "rtl" if rtl?list << text_size_classlist << "anon" unless current_user@@ -457,7 +453,7 @@ module ApplicationHelperdef application_logo_url@application_logo_url ||=- if mobile_view?+ if mobile_device?if dark_color_scheme? && SiteSetting.site_mobile_logo_dark_url.present?SiteSetting.site_mobile_logo_dark_urlelsif SiteSetting.site_mobile_logo_url.present?@@ -475,9 +471,9 @@ module ApplicationHelperdef application_logo_dark_url@application_logo_dark_url ||=if dark_scheme_id != -1- if mobile_view? && SiteSetting.site_mobile_logo_dark_url != application_logo_url+ if mobile_device? && SiteSetting.site_mobile_logo_dark_url != application_logo_urlSiteSetting.site_mobile_logo_dark_url- elsif !mobile_view? && SiteSetting.site_logo_dark_url != application_logo_url+ elsif !mobile_device? && SiteSetting.site_logo_dark_url != application_logo_urlSiteSetting.site_logo_dark_urlendend@@ -491,8 +487,8 @@ module ApplicationHelper"#{Discourse.base_path}/login"end- def mobile_view?- MobileDetection.resolve_mobile_view!(request.user_agent, params, session)+ def mobile_device?+ MobileDetection.mobile_device?(request.user_agent)enddef crawler_layout?@@ -505,7 +501,7 @@ module ApplicationHelperelsereturn false if !current_user && SiteSetting.login_required?- crawler_layout? || !mobile_view? || !modern_mobile_device?+ crawler_layout? || !mobile_device? || !modern_mobile_device?endend@@ -513,10 +509,6 @@ module ApplicationHelperMobileDetection.modern_mobile_device?(request.user_agent)end- def mobile_device?- MobileDetection.mobile_device?(request.user_agent)- end-def customization_disabled?request.env[ApplicationController::NO_THEMES]end@@ -793,7 +785,7 @@ module ApplicationHelperdef theme_lookup(name)Theme.lookup_field(theme_id,- mobile_view? ? :mobile : :desktop,+ mobile_device? ? :mobile : :desktop,name,skip_transformation: request.env[:skip_theme_ids_transformation].present?,csp_nonce: csp_nonce_placeholder,diff --git a/app/views/common/_discourse_preload_stylesheet.html.erb b/app/views/common/_discourse_preload_stylesheet.html.erbindex 879cb24f1ff..d1068a34e19 100644--- a/app/views/common/_discourse_preload_stylesheet.html.erb+++ b/app/views/common/_discourse_preload_stylesheet.html.erb@@ -2,10 +2,10 @@<%- if rtl? %><%= discourse_stylesheet_preload_tag(:common_rtl) %>- <%= discourse_stylesheet_preload_tag(mobile_view? ? :mobile_rtl : :desktop_rtl) %>+ <%= discourse_stylesheet_preload_tag(mobile_device? ? :mobile_rtl : :desktop_rtl) %><%- else %><%= discourse_stylesheet_preload_tag(:common) %>- <%= discourse_stylesheet_preload_tag(mobile_view? ? :mobile : :desktop) %>+ <%= discourse_stylesheet_preload_tag(mobile_device? ? :mobile : :desktop) %><%- end %><%- if staff? %>@@ -24,10 +24,10 @@<%- end %><%- end %>-<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_view?, desktop_view: !mobile_view?, request: request, rtl: rtl?).each do |file| %>+<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_device?, desktop_view: !mobile_device?, request: request, rtl: rtl?).each do |file| %><%= discourse_stylesheet_preload_tag(file) %><%- end %><%- if theme_id.present? %>- <%= discourse_stylesheet_preload_tag(mobile_view? ? :mobile_theme : :desktop_theme) %>+ <%= discourse_stylesheet_preload_tag(mobile_device? ? :mobile_theme : :desktop_theme) %><%- end %>diff --git a/app/views/common/_discourse_publish_stylesheet.html.erb b/app/views/common/_discourse_publish_stylesheet.html.erbindex 91df37d864a..be02e40b6c7 100644--- a/app/views/common/_discourse_publish_stylesheet.html.erb+++ b/app/views/common/_discourse_publish_stylesheet.html.erb@@ -4,10 +4,10 @@<%- if theme_id.present? %><%= discourse_stylesheet_link_tag(:common_theme, supports_rtl: true) %>- <%= discourse_stylesheet_link_tag(mobile_view? ? :mobile_theme : :desktop_theme) %>+ <%= discourse_stylesheet_link_tag(mobile_device? ? :mobile_theme : :desktop_theme) %><%- end %>-<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_view?, desktop_view: !mobile_view?, request: request, rtl: rtl?).each do |file| %>+<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_device?, desktop_view: !mobile_device?, request: request, rtl: rtl?).each do |file| %><%= discourse_stylesheet_link_tag(file) %><%- end %>diff --git a/app/views/common/_discourse_stylesheet.html.erb b/app/views/common/_discourse_stylesheet.html.erbindex 9c200c83d5d..a46066316c3 100644--- a/app/views/common/_discourse_stylesheet.html.erb+++ b/app/views/common/_discourse_stylesheet.html.erb@@ -2,12 +2,8 @@<%= discourse_stylesheet_link_tag(:common, supports_rtl: true) %>-<% if SiteSetting.viewport_based_mobile_mode %>- <%= discourse_stylesheet_link_tag(:mobile, supports_rtl: true, media: "(max-width: 39.99999rem)") %>- <%= discourse_stylesheet_link_tag(:desktop, supports_rtl: true, media: "(min-width: 40rem)") %>-<% else %>- <%= discourse_stylesheet_link_tag(mobile_view? ? :mobile : :desktop, supports_rtl: true) %>-<% end %>+<%= discourse_stylesheet_link_tag(:mobile, supports_rtl: true, media: "(max-width: 39.99999rem)") %>+<%= discourse_stylesheet_link_tag(:desktop, supports_rtl: true, media: "(min-width: 40rem)") %><%- if staff? %><%= discourse_stylesheet_link_tag(:admin, supports_rtl: true) %>@@ -17,31 +13,21 @@<%= discourse_stylesheet_link_tag(:wizard, supports_rtl: true) %><%- end %>-<% if SiteSetting.viewport_based_mobile_mode %>- <%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: true, desktop_view: true, request: request, rtl: false).each do |file| %>- <%=- media = if file.end_with?("_mobile")- "(max-width: 39.99999rem)"- elsif file.end_with?("_desktop")- "(min-width: 40rem)"- else- nil- end- discourse_stylesheet_link_tag(file, media: media, supports_rtl: true)- %>- <%- end %>-<% else %>- <%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: mobile_view?, desktop_view: !mobile_view?, request: request, rtl: rtl?).each do |file| %>- <%= discourse_stylesheet_link_tag(file) %>- <%- end %>-<% end %>+<%- Discourse.find_plugin_css_assets(include_official: allow_plugins?, include_unofficial: allow_third_party_plugins?, mobile_view: true, desktop_view: true, request: request, rtl: false).each do |file| %>+ <%=+ media = if file.end_with?("_mobile")+ "(max-width: 39.99999rem)"+ elsif file.end_with?("_desktop")+ "(min-width: 40rem)"+ else+ nil+ end+ discourse_stylesheet_link_tag(file, media: media, supports_rtl: true)+ %>+<%- end %><%- if theme_id.present? %><%= discourse_stylesheet_link_tag(:common_theme, supports_rtl: true) %>- <% if SiteSetting.viewport_based_mobile_mode %>- <%= discourse_stylesheet_link_tag(:mobile_theme, media: "(max-width: 39.99999rem)", supports_rtl: true) %>- <%= discourse_stylesheet_link_tag(:desktop_theme, media: "(min-width: 40rem)", supports_rtl: true) %>- <% else %>- <%= discourse_stylesheet_link_tag(mobile_view? ? :mobile_theme : :desktop_theme, supports_rtl: true) %>- <% end %>+ <%= discourse_stylesheet_link_tag(:mobile_theme, media: "(max-width: 39.99999rem)", supports_rtl: true) %>+ <%= discourse_stylesheet_link_tag(:desktop_theme, media: "(min-width: 40rem)", supports_rtl: true) %><%- end %>diff --git a/config/locales/client.en.yml b/config/locales/client.en.ymlindex 26f7bd38422..c5dd966f09b 100644--- a/config/locales/client.en.yml+++ b/config/locales/client.en.yml@@ -409,7 +409,6 @@ en:since: "(since %{version})"toggle_safe_mode: "Toggle safe mode"toggle_verbose_localization: "Toggle verbose localization"- toggle_mobile_view: "Toggle mobile view"disable_dev_tools: "Disable dev tools"toggle_upcoming_changes_debug: "Toggle upcoming changes debug"@@ -470,8 +469,6 @@ en:tos: "Terms of Service"rules: "Rules"conduct: "Code of Conduct"- mobile_view: "Mobile View"- desktop_view: "Desktop View"now: "just now"read_more: "read more"more: "More"diff --git a/config/locales/server.en.yml b/config/locales/server.en.ymlindex c57b5b90d0a..2a5bb6149e7 100644--- a/config/locales/server.en.yml+++ b/config/locales/server.en.yml@@ -2571,8 +2571,6 @@ en:dont_feed_the_trolls_threshold: "Number of flags from other users before being warned."- enable_mobile_theme: "Mobile devices use a mobile-friendly theme, with the ability to switch to the full site. Disable this if you want to use a custom stylesheet that is fully responsive."-dominating_topic_minimum_percent: "What percentage of posts a user has to make in a topic before being reminded about overly dominating a topic."pm_warn_user_last_seen_months_ago: "When creating a new PM warn users when target recipient has not been seen more than n months ago."@@ -2855,7 +2853,6 @@ en:rich_editor: "Enable the rich editor for the composer so all users can switch between the current Markdown mode and the new rich text editor for more intuitive and user-friendly composition."default_composition_mode: "Set the default mode for your community's composer. Rich text mode provides a more modern, familiar writing experience for most users, while Markdown mode may be suitable for more technical audiences. Members can use a toggle in the composer toolbar to switch between modes."reviewable_ui_refresh: "Groups that can use the experimental new UI in the review queue."- viewport_based_mobile_mode: "Use viewport width to determine mobile/desktop modes. This setting will be removed soon. If you find the need to turn it off, please let us know <a href='https://meta.discourse.org/t/384280'>on Meta</a>."content_localization_enabled: "Displays localized content for users based on their browser or user language preferences. Such content may include categories, tags, posts, and topics. Supported locales are set in 'content localization supported locales'."content_localization_supported_locales: "List of supported locales that user content can be translated to. The site's default locale is always included. Requires 'content localization enabled'."content_localization_allowed_groups: "Groups allowed to update localized content. Requires 'content localization enabled'."diff --git a/config/site_settings.yml b/config/site_settings.ymlindex a1841f062e0..5fd96e1a733 100644--- a/config/site_settings.yml+++ b/config/site_settings.yml@@ -392,10 +392,6 @@ basic:min: 2max: 3hidden: true- enable_mobile_theme:- client: true- default: true- hidden: trueenable_direct_s3_uploads:client: truedefault: false@@ -3333,9 +3329,6 @@ developer:default: 50hidden: trueclient: true- viewport_based_mobile_mode:- default: true- client: truesite_setting_verbose_client_logging:default: falseclient: truediff --git a/frontend/discourse/app/components/d-styles.gjs b/frontend/discourse/app/components/d-styles.gjsindex bacb8bb5918..6e56b60a8af 100644--- a/frontend/discourse/app/components/d-styles.gjs+++ b/frontend/discourse/app/components/d-styles.gjs@@ -10,7 +10,6 @@ export default class DStyles extends Component {@service session;@service site;@service interfaceColor;- @service siteSettings;get categoryColors() {return [@@ -99,12 +98,8 @@ export default class DStyles extends Component {}<template>- {{#if this.siteSettings.viewport_based_mobile_mode}}- {{htmlClass (if this.site.mobileView "mobile-view" "desktop-view")}}- {{htmlClass- (if this.site.mobileView "mobile-device" "not-mobile-device")- }}- {{/if}}+ {{htmlClass (if this.site.mobileView "mobile-view" "desktop-view")}}+ {{htmlClass (if this.site.mobileView "mobile-device" "not-mobile-device")}}{{! eslint-disable ember/template-no-forbidden-elements }}<style id="d-styles">{{#if this.site.categories}}diff --git a/frontend/discourse/app/components/sidebar/footer.gjs b/frontend/discourse/app/components/sidebar/footer.gjsindex 9eaa98a4d78..366ffb140af 100644--- a/frontend/discourse/app/components/sidebar/footer.gjs+++ b/frontend/discourse/app/components/sidebar/footer.gjs@@ -5,16 +5,13 @@ import InterfaceColorSelector from "discourse/components/interface-color-selectoimport KeyboardShortcutsHelp from "discourse/components/modal/keyboard-shortcuts-help";import SidebarSectionForm from "discourse/components/modal/sidebar-section-form";import PluginOutlet from "discourse/components/plugin-outlet";-import mobile from "discourse/lib/mobile";import { MAIN_PANEL } from "discourse/lib/sidebar/panels";import DButton from "discourse/ui-kit/d-button";export default class SidebarFooter extends Component {- @service capabilities;@service currentUser;@service modal;@service site;- @service siteSettings;@service sidebarState;@service interfaceColor;@@ -22,16 +19,6 @@ export default class SidebarFooter extends Component {return this.currentUser && this.sidebarState.isCurrentPanel(MAIN_PANEL);}- get showToggleMobileButton() {- if (this.siteSettings.viewport_based_mobile_mode) {- return false;- }- return (- this.site.mobileView ||- (this.siteSettings.enable_mobile_theme && this.capabilities.touch)- );- }-@actionmanageSections() {this.modal.show(SidebarSectionForm);@@ -42,11 +29,6 @@ export default class SidebarFooter extends Component {this.modal.show(KeyboardShortcutsHelp);}- @action- toggleMobileView() {- mobile.toggleMobileView();- }-<template><div class="sidebar-footer-wrapper"><div class="sidebar-footer-container">@@ -67,20 +49,6 @@ export default class SidebarFooter extends Component {/>{{/if}}- {{#if this.showToggleMobileButton}}- <DButton- @action={{this.toggleMobileView}}- @title={{if this.site.mobileView "desktop_view" "mobile_view"}}- @ariaLabel={{if- this.site.mobileView- "desktop_view"- "mobile_view"- }}- @icon={{if this.site.mobileView "desktop" "mobile-screen-button"}}- class="btn-flat sidebar-footer-actions-button sidebar-footer-actions-toggle-mobile-view"- />- {{/if}}-{{#if this.site.desktopView}}<DButton@action={{this.showKeyboardShortcuts}}diff --git a/frontend/discourse/app/instance-initializers/mobile.js b/frontend/discourse/app/instance-initializers/mobile.jsdeleted file mode 100644index 9fa55187a15..00000000000--- a/frontend/discourse/app/instance-initializers/mobile.js+++ /dev/null@@ -1,16 +0,0 @@-import Mobile from "discourse/lib/mobile";-import { setResolverOption } from "discourse/resolver";--// Initializes the `Mobile` helper object.-export default {- after: "inject-objects",-- initialize(owner) {- if (owner.lookup("service:site-settings").viewport_based_mobile_mode) {- return;- }-- setResolverOption("mobileView", Mobile.mobileView);- Mobile.maybeReload();- },-};diff --git a/frontend/discourse/app/lib/mobile.js b/frontend/discourse/app/lib/mobile.jsindex 98cbff43263..bbe19551f5a 100644--- a/frontend/discourse/app/lib/mobile.js+++ b/frontend/discourse/app/lib/mobile.js@@ -1,88 +1,18 @@-import deprecated from "discourse/lib/deprecated";-import { isTesting } from "discourse/lib/environment";-import { getOwnerWithFallback } from "discourse/lib/get-owner";-let mobileForced = false;// An object that is responsible for logic related to mobile devices.const Mobile = {- mobileView: false,-- init() {- const documentClassList = document.documentElement.classList;- this.mobileView = mobileForced || documentClassList.contains("mobile-view");-- if (isTesting() || mobileForced) {- return;- }-- try {- if (window.location.search.match(/mobile_view=1/)) {- localStorage.mobileView = true;- }- if (window.location.search.match(/mobile_view=0/)) {- localStorage.mobileView = false;- }- if (window.location.search.match(/mobile_view=auto/)) {- localStorage.removeItem("mobileView");- }- } catch {- // localStorage may be disabled, just skip this- // you get security errors if it is disabled- }- },-get mobileForced() {return mobileForced;},-- get isMobileDevice() {- deprecated(- "`Mobile.isMobileDevice` is deprecated. Use `capabilities.isMobileDevice` instead.",- { id: "discourse.site.is-mobile-device", since: "3.5.0.beta9-dev" }- );-- return getOwnerWithFallback(this).lookup("service:capabilities")- .isMobileDevice;- },-- maybeReload() {- if (localStorage.mobileView) {- let savedValue = localStorage.mobileView === "true";- if (savedValue !== this.mobileView) {- this.reloadPage(savedValue);- }- }- },-- toggleMobileView() {- try {- if (localStorage) {- localStorage.mobileView = !this.mobileView;- }- } catch {- // localStorage may be disabled, skip- }- this.reloadPage(!this.mobileView);- },-- reloadPage(mobile) {- window.location.assign(- window.location.pathname + "?mobile_view=" + (mobile ? "1" : "0")- );- },};export function forceMobile() {mobileForced = true;- Mobile.init();}export function resetMobile() {mobileForced = false;- Mobile.init();}-Mobile.init();-export default Mobile;diff --git a/frontend/discourse/app/models/site.js b/frontend/discourse/app/models/site.jsindex b0fa7e3e25e..0178288e4a4 100644--- a/frontend/discourse/app/models/site.js+++ b/frontend/discourse/app/models/site.js@@ -150,14 +150,10 @@ export default class Site extends RestModel {return true;}- if (this.siteSettings.viewport_based_mobile_mode) {- return withSilencedDeprecations(- "discourse.static-viewport-initialization",- () => !this.capabilities.viewport.sm- );- } else {- return Mobile.mobileView;- }+ return withSilencedDeprecations(+ "discourse.static-viewport-initialization",+ () => !this.capabilities.viewport.sm+ );}@dependentKeyCompatdiff --git a/frontend/discourse/app/routes/application.js b/frontend/discourse/app/routes/application.jsindex 888632fc9a8..cc5bfce1d50 100644--- a/frontend/discourse/app/routes/application.js+++ b/frontend/discourse/app/routes/application.js@@ -7,7 +7,6 @@ import deprecated from "discourse/lib/deprecated";import EmbedMode from "discourse/lib/embed-mode";import getURL from "discourse/lib/get-url";import logout from "discourse/lib/logout";-import mobile from "discourse/lib/mobile";import { getCurrentPushSubscription } from "discourse/lib/push-notifications";import identifySource, { consolePrefix } from "discourse/lib/source-identifier";import DiscourseURL from "discourse/lib/url";@@ -73,11 +72,6 @@ export default class ApplicationRoute extends DiscourseRoute {return true;}- @action- toggleMobileView() {- mobile.toggleMobileView();- }-@actiontoggleSidebar() {this.controllerFor("application").send("toggleSidebar");diff --git a/frontend/discourse/app/static/dev-tools/mobile-view/button.gjs b/frontend/discourse/app/static/dev-tools/mobile-view/button.gjsdeleted file mode 100644index 89057791bfb..00000000000--- a/frontend/discourse/app/static/dev-tools/mobile-view/button.gjs+++ /dev/null@@ -1,31 +0,0 @@-import Component from "@glimmer/component";-import { on } from "@ember/modifier";-import { action } from "@ember/object";-import mobile from "discourse/lib/mobile";-import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";-import dIcon from "discourse/ui-kit/helpers/d-icon";-import { i18n } from "discourse-i18n";--export default class MobileViewButton extends Component {- get mobileViewActive() {- return mobile.mobileView;- }-- @action- toggleMobileView() {- mobile.toggleMobileView();- }-- <template>- <button- title={{i18n "dev_tools.toggle_mobile_view"}}- class={{dConcatClass- "toggle-mobile-view"- (if this.mobileViewActive "--active")- }}- {{on "click" this.toggleMobileView}}- >- {{dIcon "mobile-screen-button"}}- </button>- </template>-}diff --git a/frontend/discourse/app/static/dev-tools/toolbar.gjs b/frontend/discourse/app/static/dev-tools/toolbar.gjsindex 6ed230ff02e..9fe9f49e618 100644--- a/frontend/discourse/app/static/dev-tools/toolbar.gjs+++ b/frontend/discourse/app/static/dev-tools/toolbar.gjs@@ -2,7 +2,6 @@ import Component from "@glimmer/component";import { tracked } from "@glimmer/tracking";import { on } from "@ember/modifier";import { action } from "@ember/object";-import { service } from "@ember/service";import { trustHTML } from "@ember/template";import dConcatClass from "discourse/ui-kit/helpers/d-concat-class";import dIcon from "discourse/ui-kit/helpers/d-icon";@@ -10,15 +9,12 @@ import dDraggable from "discourse/ui-kit/modifiers/d-draggable";import dOnResize from "discourse/ui-kit/modifiers/d-on-resize";import I18n, { i18n } from "discourse-i18n";import BlockDebugButton from "./block-debug/button";-import MobileViewButton from "./mobile-view/button";import PluginOutletDebugButton from "./plugin-outlet-debug/button";import SafeModeButton from "./safe-mode/button";import UpcomingChangesDebugButton from "./upcoming-changes-debug/button";import VerboseLocalizationButton from "./verbose-localization/button";export default class Toolbar extends Component {- @service siteSettings;-@tracked activeDragOffset;@tracked ownSize = 0;@tracked top = 250;@@ -85,9 +81,6 @@ export default class Toolbar extends Component {<UpcomingChangesDebugButton /><SafeModeButton /><VerboseLocalizationButton />- {{#unless this.siteSettings.viewport_based_mobile_mode}}- <MobileViewButton />- {{/unless}}<buttontype="button"title={{i18n "dev_tools.disable_dev_tools"}}diff --git a/frontend/discourse/tests/acceptance/sidebar-user-test.js b/frontend/discourse/tests/acceptance/sidebar-user-test.jsindex 08187b0af76..912def5cab1 100644--- a/frontend/discourse/tests/acceptance/sidebar-user-test.js+++ b/frontend/discourse/tests/acceptance/sidebar-user-test.js@@ -1,6 +1,5 @@import { click, visit } from "@ember/test-helpers";import { test } from "qunit";-import Sinon from "sinon";import {acceptance,updateCurrentUser,@@ -155,31 +154,6 @@ acceptance(assert.dom(".sidebar-container").exists("displays the sidebar");});- test("button to toggle between legacy mobile and desktop view on touch devices", async function (assert) {- this.container.lookup(- "service:site-settings"- ).viewport_based_mobile_mode = false;-- const capabilities = this.container.lookup("service:capabilities");- Sinon.stub(capabilities, "touch").value(true);-- await visit("/");-- assert- .dom(- `.sidebar-footer-actions-toggle-mobile-view[title="${i18n(- "mobile_view"- )}"]`- )- .exists("displays the right title for the button");-- assert- .dom(- ".sidebar-footer-actions-toggle-mobile-view .d-icon-mobile-screen-button"- )- .exists("displays the mobile icon for the button");- });-test("clean up topic tracking state state changed callbacks when sidebar is destroyed", async function (assert) {updateCurrentUser({ display_sidebar_tags: true });diff --git a/lib/middleware/anonymous_cache.rb b/lib/middleware/anonymous_cache.rbindex b24c4707b5b..5a4f40c5907 100644--- a/lib/middleware/anonymous_cache.rb+++ b/lib/middleware/anonymous_cache.rb@@ -63,7 +63,6 @@ module Middleware# This gives us an API to insert anonymous cache segmentsclass Helper- RACK_SESSION = "rack.session"USER_AGENT = "HTTP_USER_AGENT"ACCEPT_ENCODING = "HTTP_ACCEPT_ENCODING"DISCOURSE_RENDER = "HTTP_DISCOURSE_RENDER"@@ -103,16 +102,7 @@ module Middlewareenddef is_mobile?- @is_mobile ||=- begin- session = @env[RACK_SESSION]- # don't initialize params until later- # otherwise you get a broken params on the request- params = {}-- MobileDetection.resolve_mobile_view!(@user_agent, params, session) ? :true : :false- end-+ @is_mobile ||= MobileDetection.mobile_device?(@user_agent) ? :true : :false@is_mobile == :trueendalias_method :key_is_mobile?, :is_mobile?diff --git a/lib/mobile_detection.rb b/lib/mobile_detection.rbindex 78193e06a36..b50335dfcb6 100644--- a/lib/mobile_detection.rb+++ b/lib/mobile_detection.rb@@ -1,27 +1,12 @@# frozen_string_literal: truemodule MobileDetection- # if the criteria for mobile_device? changes, update the code for `mobileDevice` in- # `javascripts/discourse/app/lib/mobile.js`+ # if the criteria for mobile_device? changes, update the code for `isMobileDevice` in+ # `frontend/discourse/app/services/capabilities.js`def self.mobile_device?(user_agent)user_agent =~ /Mobile/ && !(user_agent =~ /iPad/)end- # we need this as a reusable chunk that is called from the cache- def self.resolve_mobile_view!(user_agent, params, session)- return false unless SiteSetting.enable_mobile_theme-- session[:mobile_view] = params[:mobile_view] if params && params.has_key?(:mobile_view)- session[:mobile_view] = nil if params && params.has_key?(:mobile_view) &&- params[:mobile_view] == "auto"-- if session && session[:mobile_view]- session[:mobile_view] == "1"- else- mobile_device?(user_agent)- end- end-MODERN_MOBILE_REGEX =%r{\(.*iPhone\ OS\ 1[6-9].*\)|diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rbindex 4eb43bcb457..1c71b9eebc3 100644--- a/lib/site_setting_extension.rb+++ b/lib/site_setting_extension.rb@@ -1230,7 +1230,7 @@ module SiteSettingExtension## @example# {- # enable_mobile_theme: true,+ # enable_badges: true,# topics_per_period_in_top_page: 50,# title: "My awesome forum"# }diff --git a/lib/site_settings/type_supervisor.rb b/lib/site_settings/type_supervisor.rbindex 475d0d2d989..9c732572755 100644--- a/lib/site_settings/type_supervisor.rb+++ b/lib/site_settings/type_supervisor.rb@@ -177,7 +177,7 @@ class SiteSettings::TypeSupervisor# @return [Object] the Ruby value of the setting## @example- # to_rb_value(:enable_mobile_theme, "true") # => true+ # to_rb_value(:enable_badges, "true") # => true# to_rb_value(:topics_per_period_in_top_page, "50") # => 50# to_rb_value(:title, "My awesome forum") # => "My awesome forum"def to_rb_value(name, value, override_type = nil)diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rbindex 9bac7413aca..4aeddd95dfc 100644--- a/spec/helpers/application_helper_spec.rb+++ b/spec/helpers/application_helper_spec.rb@@ -257,7 +257,7 @@ RSpec.describe ApplicationHelper doendcontext "when on desktop" do- before { session[:mobile_view] = "0" }+ before { helper.stubs(:mobile_device?).returns(false) }context "when logo_dark is not set" doit "will return site_logo_url instead" do@@ -275,7 +275,7 @@ RSpec.describe ApplicationHelper doendcontext "when on mobile" do- before { session[:mobile_view] = "1" }+ before { helper.stubs(:mobile_device?).returns(true) }context "when mobile_logo_dark is not set" doit "will return site_mobile_logo_url instead" do@@ -351,153 +351,75 @@ RSpec.describe ApplicationHelper doendend- describe "#mobile_view?" do- context "when enable_mobile_theme is true" do- before { SiteSetting.enable_mobile_theme = true }-- it "is true if mobile_view is '1' in the session" do- session[:mobile_view] = "1"- expect(helper.mobile_view?).to eq(true)- end-- it "is false if mobile_view is '0' in the session" do- session[:mobile_view] = "0"- expect(helper.mobile_view?).to eq(false)- end-- context "when mobile_view session is cleared" do- before { params[:mobile_view] = "auto" }-- it "is false if user agent is not mobile" do- session[:mobile_view] = "1"- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36",- )- expect(helper.mobile_view?).to be_falsey- end-- it "is true for iPhone" do- session[:mobile_view] = "0"- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13D15 Safari/601.1",- )- expect(helper.mobile_view?).to eq(true)- end- end-- context "when mobile_view is not set" do- it "is false if user agent is not mobile" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36",- )- expect(helper.mobile_view?).to be_falsey- end-- it "is true for iPhone" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13D15 Safari/601.1",- )- expect(helper.mobile_view?).to eq(true)- end-- it "is true for Android Samsung Galaxy" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Linux; Android 5.0.2; SAMSUNG SM-G925F Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36",- )- expect(helper.mobile_view?).to eq(true)- end-- it "is true for Android Google Nexus 5X" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Linux; Android 6.0; Nexus 5X Build/MDB08I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.43 Mobile Safari/537.36",- )- expect(helper.mobile_view?).to eq(true)- end-- it "is false for iPad" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B14 3 Safari/601.1",- )- expect(helper.mobile_view?).to eq(false)- end-- it "is false for Nexus 10 tablet" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 10 Build/LMY49G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36",- )- expect(helper.mobile_view?).to be_falsey- end+ describe "#mobile_device?" do+ it "is false if user agent is not mobile" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.87 Safari/537.36",+ )+ expect(helper.mobile_device?).to be_falsey+ end- it "is false for Nexus 7 tablet" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36",- )- expect(helper.mobile_view?).to be_falsey- end- end+ it "is true for iPhone" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13D15 Safari/601.1",+ )+ expect(helper.mobile_device?).to eq(true)end- context "when enable_mobile_theme is false" do- before { SiteSetting.enable_mobile_theme = false }+ it "is true for Android Samsung Galaxy" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (Linux; Android 5.0.2; SAMSUNG SM-G925F Build/LRX22G) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/4.0 Chrome/44.0.2403.133 Mobile Safari/537.36",+ )+ expect(helper.mobile_device?).to eq(true)+ end- it "is false if mobile_view is '1' in the session" do- session[:mobile_view] = "1"- expect(helper.mobile_view?).to eq(false)- end+ it "is true for Android Google Nexus 5X" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (Linux; Android 6.0; Nexus 5X Build/MDB08I) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.43 Mobile Safari/537.36",+ )+ expect(helper.mobile_device?).to eq(true)+ end- it "is false if mobile_view is '0' in the session" do- session[:mobile_view] = "0"- expect(helper.mobile_view?).to eq(false)- end+ it "is false for iPad" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (iPad; CPU OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B14 3 Safari/601.1",+ )+ expect(helper.mobile_device?).to eq(false)+ end- context "when mobile_view is not set" do- it "is false if user agent is not mobile" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.17 Safari/537.36",- )- expect(helper.mobile_view?).to eq(false)- end+ it "is false for Nexus 10 tablet" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (Linux; Android 5.1.1; Nexus 10 Build/LMY49G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36",+ )+ expect(helper.mobile_device?).to be_falsey+ end- it "is false for iPhone" do- controller- .request- .stubs(:user_agent)- .returns(- "Mozilla/5.0 (iPhone; U; ru; CPU iPhone OS 4_2_1 like Mac OS X; ru) AppleWebKit/533.17.9 (KHTML, like Gecko) Version/5.0.2 Mobile/8C148a Safari/6533.18.5",- )- expect(helper.mobile_view?).to eq(false)- end- end+ it "is false for Nexus 7 tablet" do+ controller+ .request+ .stubs(:user_agent)+ .returns(+ "Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36",+ )+ expect(helper.mobile_device?).to be_falseyendenddiff --git a/spec/system/mobile_mode_spec.rb b/spec/system/mobile_mode_spec.rbindex 4b647e06a39..33777c8619a 100644--- a/spec/system/mobile_mode_spec.rb+++ b/spec/system/mobile_mode_spec.rb@@ -1,8 +1,6 @@# frozen_string_literal: trueRSpec.describe "Viewport-based mobile mode" do- before { SiteSetting.viewport_based_mobile_mode = true }-it "has both stylesheets, and updates classes at runtime" dovisit "/"diff --git a/spec/system/page_objects/components/sidebar_header_dropdown.rb b/spec/system/page_objects/components/sidebar_header_dropdown.rbindex c8ff910652e..2bd69da20da 100644--- a/spec/system/page_objects/components/sidebar_header_dropdown.rb+++ b/spec/system/page_objects/components/sidebar_header_dropdown.rb@@ -31,13 +31,6 @@ module PageObjectsfind(".sidebar-section-link[data-link-name='everything']").clickend- def click_toggle_to_desktop_view_button- page.click_button(- I18n.t("js.desktop_view"),- class: "sidebar-footer-actions-toggle-mobile-view",- )- end-def click_outsidewidth = page.evaluate_script("document.body.clientWidth")page.find("body").click(x: width - 1, y: 1)diff --git a/spec/system/viewing_sidebar_mobile_spec.rb b/spec/system/viewing_sidebar_mobile_spec.rbindex 6b1e4aefea9..c5b73bc57a5 100644--- a/spec/system/viewing_sidebar_mobile_spec.rb+++ b/spec/system/viewing_sidebar_mobile_spec.rb@@ -57,19 +57,4 @@ describe "Viewing sidebar mobile", mobile: true doexpect(sidebar_dropdown).to be_hiddenend-- it "toggles to desktop view after clicking on the toggle to desktop view button" do- SiteSetting.viewport_based_mobile_mode = false-- visit("/latest")-- expect(page).to have_css(".mobile-view")-- sidebar_dropdown.click- sidebar_dropdown.click_toggle_to_desktop_view_button-- visit("/latest")-- expect(page).to have_css(".desktop-view")- endend