fix(frontend): create channel under selected guild and surface errors via modal
- createChannel falls back to selectedGuildId when guildDbId is unknown, so the first channel of a guild can be created (no chicken-and-egg) - channel is created under the currently selected guild - errors now show in a dismissible modal instead of the Messages pane Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -143,15 +143,16 @@ export default function ChatPage() {
|
|||||||
|
|
||||||
async function createChannel() {
|
async function createChannel() {
|
||||||
if (!guild || !guildToken || !newChannelName.trim()) return
|
if (!guild || !guildToken || !newChannelName.trim()) return
|
||||||
if (!guildDbId) {
|
const effectiveGuildId = guildDbId || selectedGuildId
|
||||||
setError('Cannot create channel: guildId is missing')
|
if (!effectiveGuildId) {
|
||||||
|
setError('Cannot create channel: no guild selected')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
setError('')
|
setError('')
|
||||||
try {
|
try {
|
||||||
const payload = {
|
const payload = {
|
||||||
name: newChannelName.trim(),
|
name: newChannelName.trim(),
|
||||||
guildId: guildDbId,
|
guildId: effectiveGuildId,
|
||||||
memberUserIds: selectedMemberIds,
|
memberUserIds: selectedMemberIds,
|
||||||
}
|
}
|
||||||
const res = await guildApi().post('/channels', payload)
|
const res = await guildApi().post('/channels', payload)
|
||||||
@@ -242,7 +243,6 @@ export default function ChatPage() {
|
|||||||
<div className="panel chat-history">
|
<div className="panel chat-history">
|
||||||
<h3>Messages</h3>
|
<h3>Messages</h3>
|
||||||
{loading ? <p className="muted">Loading...</p> : null}
|
{loading ? <p className="muted">Loading...</p> : null}
|
||||||
{error ? <p className="error-text">{error}</p> : null}
|
|
||||||
<ul className="list-reset">
|
<ul className="list-reset">
|
||||||
{messages.map((m) => (
|
{messages.map((m) => (
|
||||||
<li key={m.messageId} className="card" style={{ marginTop: 8 }}>
|
<li key={m.messageId} className="card" style={{ marginTop: 8 }}>
|
||||||
@@ -298,6 +298,18 @@ export default function ChatPage() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
|
||||||
|
{error ? (
|
||||||
|
<div className="modal-backdrop" onClick={() => setError('')}>
|
||||||
|
<div className="modal-card" onClick={(e) => e.stopPropagation()}>
|
||||||
|
<h3>Error</h3>
|
||||||
|
<p className="error-text">{error}</p>
|
||||||
|
<div className="row-wrap" style={{ marginTop: 12 }}>
|
||||||
|
<button className="btn" onClick={() => setError('')}>OK</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</section>
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user