From dbab94bc6e9b6c78e05a3ca8edbe8b4a1bdbd6c7 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Tue, 28 Feb 2023 00:02:48 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EB=9D=84?= =?UTF-8?q?=EC=9A=B0=EA=B8=B0(wip)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/Message/GetRecentMessage.php | 2 +- hwe/ts/components/MessagePanel.vue | 59 ++++++++++++++++++---- 2 files changed, 51 insertions(+), 10 deletions(-) diff --git a/hwe/sammo/API/Message/GetRecentMessage.php b/hwe/sammo/API/Message/GetRecentMessage.php index 815ba283..b157fcc1 100644 --- a/hwe/sammo/API/Message/GetRecentMessage.php +++ b/hwe/sammo/API/Message/GetRecentMessage.php @@ -29,7 +29,7 @@ class GetRecentMessage extends \sammo\BaseAPI public function getRequiredSessionMode(): int { - return static::REQ_GAME_LOGIN; + return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY; } private function delayFrequentCall(Session $session): void diff --git a/hwe/ts/components/MessagePanel.vue b/hwe/ts/components/MessagePanel.vue index 32e01ff1..287b191e 100644 --- a/hwe/ts/components/MessagePanel.vue +++ b/hwe/ts/components/MessagePanel.vue @@ -20,18 +20,45 @@ +
개인 메시지
+
외교 메시지
+
@@ -42,6 +69,10 @@ import { SammoAPI } from "@/SammoAPI"; import { isString } from "lodash"; import type { MsgItem, MsgResponse, MsgType } from "@/defs/API/Message"; import MessagePlate from "@/components/MessagePlate.vue"; +import { useToast } from "bootstrap-vue-3"; +import { unwrap } from "@/util/unwrap"; + +const toasts = unwrap(useToast()); const emit = defineEmits<{ (event: "request-refresh"): void; @@ -66,7 +97,7 @@ onMounted(() => { const lastSequence = ref(-1); -const initRefreshLimit = 5; +const initRefreshLimit = 20; let refreshLimit = initRefreshLimit; const refreshP: Set> = new Set(); let lastRefreshDone = 0; @@ -93,11 +124,11 @@ function updateMsgResponse(response: MsgResponse) { } } - if(response.generalName != generalName.value){ + if (response.generalName != generalName.value) { emit("request-refresh"); return; } - if(response.nationID != nationID.value){ + if (response.nationID != nationID.value) { emit("request-refresh"); return; } @@ -107,7 +138,6 @@ function updateMsgResponse(response: MsgResponse) { for (const msgType of Object.keys(messageIndexedList) as (keyof typeof messageIndexedList)[]) { const msgList = messageIndexedList[msgType]; - const newMsgList = response[msgType]; console.log(msgType, msgList, newMsgList); if (newMsgList.length == 0) { @@ -171,11 +201,19 @@ function beginRefreshTimer() { if (refreshP.size > refreshLimit && refreshTimer) { clearInterval(refreshTimer); refreshTimer = null; - alert("서버 응답이 없습니다. 새로고침을 해주세요."); + toasts.danger( + { + title: "메시지 자동 갱신 실패", + body: "서버 응답이 없습니다. 새로고침을 해주세요.", + }, + { + delay: 1000 * 3600, + } + ); return; } - refreshP.add(tryRefresh()); + void tryRefresh(); } }, 2500); } @@ -196,15 +234,17 @@ async function tryRefresh() { if (lastRefreshDone < now) { lastRefreshDone = now; } - } catch (e) { if (isString(e)) { - alert(e); + toasts.warning({ + title: '갱신 실패', + body: e, + }); } console.error(e); } - if(!response){ + if (!response) { return false; } @@ -214,6 +254,7 @@ async function tryRefresh() { })(); void waiterP.then((result) => { if (!result) { + console.error("?! result"); refreshLimit--; } else { refreshLimit = initRefreshLimit;