mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-05 17:40:33 +08:00
This commit introduces deprecation warnings for accessing Site.mobileView or Site.desktopView during application initialization to prevent layout-related errors and improve code reliability. The changes include: * Added deprecation warnings for Site.mobileView and Site.desktopView access during the initialization phase. * Updated multiple plugins and components to avoid these deprecated calls during startup. * Refactored initialization logic across discourse-ai, discourse-chat, discourse-calendar, discourse-reactions, discourse-assign, discourse-subscriptions, and discourse-user-notes plugins * Improved error prevention by discouraging early access to view-dependent properties before the application is fully initialized * Enhanced code maintainability by establishing clearer boundaries between initialization and runtime phases This deprecation helps prevent subtle bugs that can occur when components try to determine the view type before the application context is properly established, leading to more robust plugin initialization patterns.
65 lines
1.8 KiB
JavaScript
65 lines
1.8 KiB
JavaScript
import { click, visit } from "@ember/test-helpers";
|
|
import { skip } from "qunit";
|
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
acceptance(
|
|
"Discourse Chat - Chat live pane - handling 429 errors",
|
|
function (needs) {
|
|
needs.user({
|
|
username: "eviltrout",
|
|
id: 1,
|
|
has_chat_enabled: true,
|
|
});
|
|
needs.settings({
|
|
chat_enabled: true,
|
|
navigation_menu: "legacy",
|
|
enable_emoji: true,
|
|
});
|
|
|
|
needs.pretender((server, helper) => {
|
|
server.get("/chat/:chatChannelId/messages.json", () => {
|
|
return helper.response(429);
|
|
});
|
|
|
|
server.get("/chat/chat_channels.json", () =>
|
|
helper.response({
|
|
public_channels: [
|
|
{
|
|
id: 1,
|
|
title: "something",
|
|
current_user_membership: { following: true },
|
|
message_bus_last_ids: { new_mentions: 0, new_messages: 0 },
|
|
},
|
|
],
|
|
direct_message_channels: [],
|
|
message_bus_last_ids: {
|
|
channel_metadata: 0,
|
|
channel_edits: 0,
|
|
channel_status: 0,
|
|
new_channel: 0,
|
|
user_tracking_state: 0,
|
|
},
|
|
})
|
|
);
|
|
|
|
server.get("/chat/chat_channels/:chatChannelId", () =>
|
|
helper.response({ id: 1, title: "something" })
|
|
);
|
|
|
|
server.post("/chat/drafts", () => {
|
|
return helper.response([]);
|
|
});
|
|
|
|
server.post("/chat/:chatChannelId.json", () => {
|
|
return helper.response({ success: "OK" });
|
|
});
|
|
});
|
|
|
|
skip("Handles 429 errors by displaying an alert", async function (assert) {
|
|
await visit("/chat/c/cat/1");
|
|
|
|
assert.dom(".dialog-content").exists("displays the 429 error");
|
|
await click(".dialog-footer .btn-primary");
|
|
});
|
|
}
|
|
);
|