# 系統通知 - 使用情境 ###### tags: `架構說明` --- #### 前端 > 監聽 socket 事件命名與對應執行內容 1. `update_unshown_notification_count` -- 更新小鈴鐺數字 -- 如果通知清單是開啟中的狀態下,執行取回通知資料並顯示,寫入通知已看過時間 2. `pop_notifications_with_snack_bar` -- 按照接收到的通知陣列檢查 state.popedList,不存在時跳出 snack bar -- 出現過的通知,紀錄 id 到 state.popedList > 介面動作與顯示/讀取更新時機 1. 顯示通知列表時 -- 取回通知資料並顯示 -- 寫入通知已顯示時間(showed) 2. 點開通知內容或是判定已讀時 -- 更新通知已讀時間(watched) -- 消除該筆通知未讀紅點 3. 點擊 snack bar 或是判定已讀時 -- 更新 snack bar 通知已顯示時間(showed) -- 更新 snack bar 通知已讀取時間(watched) --- #### 後端 > 發送 socket 事件命名與對應執行內容 1. `update_unshown_notification_count` -- 提供特定用戶未讀通知數量 2. `pop_notifications_with_snack_bar` -- 發送要跳出 snack bar 的通知陣列 [update_unwatched_notification_count 數量 > 0 才觸發show_notifications_with_snack_bar]() > 執行時間點與觸發情境 1. 用戶透過 socket 連線後,完成 auth 時,接著進行上述兩個事件的發送 2. 後台通知建立時,針對連線中的用戶發送上述兩個事件 > 後端更新資料庫 api 功能 1. `writeShowedAtByIds` -- 寫入觸發時間到所有屬於該用戶之通知的 showed_at 欄位 2. `writeWatchedAtById` -- 寫入觸發時間到屬於該用戶之特定通知的 watched_at 欄位
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up