simonk
(Simon King)
7 أغسطس 2026، 2:36م
1
استمرار النقاش من إنشاء رابط لبدء موضوع جديد بمعلومات مُسبقة التعبئة :
لست متأكداً مما إذا كان هذا خطأً أم ميزة، ولكن إذا تضمن رابط new-topic معلمة category أو category_id، فإن النقر على الرابط ينقلك إلى تلك الفئة قبل فتح محرر الكتابة. على سبيل المثال، ينقلك النقر على هذا الرابط إلى فئة الدعم قبل فتح محرر الكتابة:
https://meta.discourse.org/new-topic?title=topic%20title&category=Support
أفضل أن لا يقوم Discourse بالتنقل بعيداً عن الصفحة الحالية. هل هناك أي طريقة لتحقيق ذلك؟
simonk
(Simon King)
7 أغسطس 2026، 2:49م
2
هذا التغيير يلغي التنقل إذا كان المستخدم موجودًا بالفعل على Discourse:
committed 12:03AM - 27 Jun 23 UTC
Why is this change required?
The `/new-topic` route is a special route which … we use to open the
composer by loading a URL. By default, the `new-topic` route is replaced with the
`discovery.latest` route. On a fresh page load, this makes sense since
there is no template for the `new-topic` route to render. However, this
behavior does not make sense if we're transition from another route.
There is no need to replace the current route with the `discovery.latest` when all we want
is to open the composer.
What does this commit do?
This commit fixes the undesirable behaviour described above by aborting
the existing transition to the `new-topic` route if `transition.from` is
present. This indicates that we're navigating from an existing route and
we can just open the composer.
تغير الكود منذ ذلك الحين ويبدو الآن كالتالي:
async beforeModel(transition) {
if (!this.currentUser) {
transition.send("showLogin");
return;
}
const { queryParams: params } = transition.to;
const category = await this.#loadCategoryFromTransition(params);
if (category) {
// Using URL-based transition to avoid bug with dynamic segments and refreshModel query params
// https://github.com/emberjs/ember.js/issues/16992
this.router
.replaceWith(`/c/${category.id}`)
.followRedirects()
.then(() => {
if (this.currentUser.can_create_topic) {
this.#openComposer(params, category);
}
});
تنفذ كتلة if (category) { قبل الكتلة التي تتحقق مما إذا كان المستخدم موجودًا بالفعل على Discourse، لذا يتابع التنقل. يبدو لي أن هذا الترتيب خاطئ.