Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion apps/web/src/routes/_authenticated/$guildSlug/$channelId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,14 @@ function ChannelView() {
const currentUserId = session?.user.id

useEffect(() => {
localStorage.setItem(`last-channel:${guildSlug}`, channelId)
if (!guildSlug || !channelId) return
try {
if (typeof window !== "undefined") {
localStorage.setItem(`last-channel:${guildSlug}`, channelId)
}
} catch {
// localStorage may be unavailable in restricted environments
}
}, [guildSlug, channelId])

useEffect(() => {
Expand Down
9 changes: 8 additions & 1 deletion apps/web/src/routes/_authenticated/$guildSlug/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ function GuildHome() {
const navigate = useNavigate()

useEffect(() => {
const lastChannelId = localStorage.getItem(`last-channel:${guildSlug}`)
let lastChannelId: string | null = null
try {
if (typeof window !== "undefined") {
lastChannelId = localStorage.getItem(`last-channel:${guildSlug}`)
}
} catch {
// localStorage may be unavailable in restricted environments
}
if (lastChannelId) {
void navigate({
to: "/$guildSlug/$channelId",
Expand Down