DEV: Move toggleAnonymous out of app route (#24077)

This commit is contained in:
Jarek Radosz
2023-10-24 17:54:56 +02:00
committed by GitHub
parent 49c6671b60
commit 9a497d9e22
4 changed files with 10 additions and 10 deletions
@@ -102,7 +102,7 @@
}}
>
<DButton
@action={{route-action "toggleAnonymous"}}
@action={{this.toggleAnonymous}}
class="btn-flat profile-tab-btn"
>
{{#if this.currentUser.is_anonymous}}
@@ -3,7 +3,9 @@ import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import DoNotDisturbModal from "discourse/components/modal/do-not-disturb";
import UserStatusModal from "discourse/components/modal/user-status";
import { ajax } from "discourse/lib/ajax";
import DoNotDisturb from "discourse/lib/do-not-disturb";
import { userPath } from "discourse/lib/url";
const _extraItems = [];
@@ -92,4 +94,10 @@ export default class UserMenuProfileTabContent extends Component {
},
});
}
@action
async toggleAnonymous() {
await ajax(userPath("toggle-anon"), { type: "POST" });
window.location.reload();
}
}
@@ -3,13 +3,12 @@ import { inject as service } from "@ember/service";
import ForgotPassword from "discourse/components/modal/forgot-password";
import KeyboardShortcutsHelp from "discourse/components/modal/keyboard-shortcuts-help";
import LoginModal from "discourse/components/modal/login";
import { ajax } from "discourse/lib/ajax";
import { setting } from "discourse/lib/computed";
import cookie from "discourse/lib/cookie";
import logout from "discourse/lib/logout";
import mobile from "discourse/lib/mobile";
import showModal from "discourse/lib/show-modal";
import DiscourseURL, { userPath } from "discourse/lib/url";
import DiscourseURL from "discourse/lib/url";
import Category from "discourse/models/category";
import Composer from "discourse/models/composer";
import { findAll } from "discourse/models/login-method";
@@ -66,12 +65,6 @@ const ApplicationRoute = DiscourseRoute.extend({
},
actions: {
toggleAnonymous() {
ajax(userPath("toggle-anon"), { type: "POST" }).then(() => {
window.location.reload();
});
},
toggleMobileView() {
mobile.toggleMobileView();
},
@@ -15,7 +15,6 @@
@showLogin={{route-action "showLogin"}}
@showKeyboard={{route-action "showKeyboardShortcutsHelp"}}
@toggleMobileView={{route-action "toggleMobileView"}}
@toggleAnonymous={{route-action "toggleAnonymous"}}
@logout={{route-action "logout"}}
@sidebarEnabled={{this.sidebarEnabled}}
@navigationMenuQueryParamOverride={{this.navigationMenuQueryParamOverride}}