Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
Update(admin/chat): クラス名昇順で表示させる
Browse files Browse the repository at this point in the history
  • Loading branch information
a01sa01to committed Jun 3, 2022
1 parent aa96187 commit ab3db2e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion public/bundle.js

Large diffs are not rendered by default.

26 changes: 17 additions & 9 deletions src/admin/chat/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
doc,
getDoc,
getDocs,
orderBy,
query,
Timestamp,
updateDoc,
} from 'firebase/firestore'
Expand All @@ -24,7 +26,9 @@ window.addEventListener('DOMContentLoaded', () => {
log('ClassInfoLoaded')

// 初期化
const allDocsData = await getDocs(collection(db, 'chat'))
const allDocsData = await getDocs(
query(collection(db, 'chat'), orderBy('name', 'asc'))
)
allDocsData.forEach((doc) => {
const saveData = doc.data() as type_chatAllData

Expand Down Expand Up @@ -63,9 +67,12 @@ window.addEventListener('DOMContentLoaded', () => {
const d = new Date()
const dateFormat = formatDate(d)
$('main div.chat div.history').append(
`<div class="msg-cont"><div class="rec"><p class="msg">${String(
k.data
)}</p><p class="time">${dateFormat}</p></div></div>`
`<div class="msg-cont">
<div class="rec">
<p class="msg">${String(k.data)}</p>
<p class="time">${dateFormat}</p>
</div>
</div>`
)
scrollBtm()
}
Expand Down Expand Up @@ -107,11 +114,12 @@ window.addEventListener('DOMContentLoaded', () => {
const time = e.time.toDate()
const dateFormat = formatDate(time)
$('main div.chat div.history').append(
`<div class="msg-cont"><div class="${
e.fromAdmin ? 'send' : 'rec'
}"><p class="msg">${String(
e.message
)}</p><p class="time">${dateFormat}</p></div></div>`
`<div class="msg-cont">
<div class="${e.fromAdmin ? 'send' : 'rec'}">
<p class="msg">${String(e.message)}</p>
<p class="time">${dateFormat}</p>
</div>
</div>`
)
}
scrollBtm()
Expand Down

0 comments on commit ab3db2e

Please sign in to comment.