Forum: Allow replying from any page
parent
49468b6d11
commit
1ce9283f81
|
@ -66,7 +66,7 @@ final class ForumTopic(env: Env) extends LilaController(env) with ForumControlle
|
|||
env.team.cached.isLeader(teamId, me.id)
|
||||
}
|
||||
form <- ctx.me.ifTrue(
|
||||
!posts.hasNextPage && canWrite && topic.open && !topic.isOld
|
||||
canWrite && topic.open && !topic.isOld
|
||||
) ?? { me => forms.postWithCaptcha(me, inOwnTeam) map some }
|
||||
canModCateg <- isGrantedMod(categ.slug)
|
||||
_ <- env.user.lightUserApi preloadMany posts.currentPageResults.flatMap(_.userId)
|
||||
|
|
|
@ -86,7 +86,11 @@ object post {
|
|||
)
|
||||
)
|
||||
},
|
||||
canReply option button(cls := "mod quote button button-empty text", tpe := "button", dataIcon := "❝")("Quote")
|
||||
canReply option button(
|
||||
cls := "mod quote button button-empty text",
|
||||
tpe := "button",
|
||||
dataIcon := "❝"
|
||||
)("Quote")
|
||||
),
|
||||
a(cls := "anchor", href := url)(s"#${post.number}")
|
||||
),
|
||||
|
|
|
@ -120,8 +120,7 @@ object topic {
|
|||
}
|
||||
),
|
||||
div(cls := "forum-topic__actions")(
|
||||
if (posts.hasNextPage) emptyFrag
|
||||
else if (topic.isOld)
|
||||
if (topic.isOld)
|
||||
p(trans.thisTopicIsArchived())
|
||||
else if (formWithCaptcha.isDefined)
|
||||
h2(id := "reply")(trans.replyToThisTopic())
|
||||
|
|
|
@ -64,11 +64,11 @@ lichess.load.then(() => {
|
|||
message = $post.find('.forum-post__message')[0] as HTMLElement,
|
||||
response = $('.reply .post-text-area')[0] as HTMLTextAreaElement;
|
||||
|
||||
const quoteContent = message.innerText
|
||||
let quote = message.innerText
|
||||
.split('\n')
|
||||
.map(line => '> ' + line)
|
||||
.join('\n');
|
||||
const quote = `@${author} said in ${anchor}:\n${quoteContent}\n`;
|
||||
quote = `@${author} said in ${anchor}:\n${quote}\n`;
|
||||
response.value =
|
||||
response.value.substring(0, response.selectionStart) + quote + response.value.substring(response.selectionEnd);
|
||||
});
|
||||
|
@ -142,4 +142,19 @@ lichess.load.then(() => {
|
|||
);
|
||||
}
|
||||
});
|
||||
|
||||
const replyStorage = lichess.tempStorage.make('forum.reply');
|
||||
const replyEl = $('.reply .post-text-area')[0] as HTMLTextAreaElement | undefined;
|
||||
const storedReply = replyStorage.get();
|
||||
let submittingReply = false;
|
||||
if (replyEl && storedReply) replyEl.value = storedReply;
|
||||
|
||||
window.addEventListener('unload', () => {
|
||||
if (!submittingReply && replyEl?.value) replyStorage.set(replyEl.value);
|
||||
});
|
||||
|
||||
$('form.reply').on('submit', () => {
|
||||
replyStorage.remove();
|
||||
submittingReply = true;
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue