feat: 메시지 패널에 모바일용 '접기' 기능 추가

- 접는다기 보다는 '삭제'에 가까움
- 메모리 절약을 위해..
This commit is contained in:
2023-03-09 02:20:24 +09:00
parent aaa075c042
commit 4bce4d45ea
+75 -8
View File
@@ -49,6 +49,12 @@
:nationID="nationID" :nationID="nationID"
:permissionLevel="permissionLevel" :permissionLevel="permissionLevel"
></MessagePlate> ></MessagePlate>
<div class="d-grid Actions">
<button type="button" class="btn btn-dark only-mobile" @click="foldMessage($event, 'public')">접기</button>
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'public')">
이전 메시지 불러오기
</button>
</div>
</template> </template>
</div> </div>
<div class="NationalTalk"> <div class="NationalTalk">
@@ -67,6 +73,12 @@
:nationID="nationID" :nationID="nationID"
:permissionLevel="permissionLevel" :permissionLevel="permissionLevel"
></MessagePlate> ></MessagePlate>
<div class="d-grid Actions">
<button type="button" class="btn btn-dark only-mobile" @click="foldMessage($event, 'national')">접기</button>
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'national')">
이전 메시지 불러오기
</button>
</div>
</template> </template>
</div> </div>
<div class="PrivateTalk"> <div class="PrivateTalk">
@@ -85,6 +97,12 @@
:nationID="nationID" :nationID="nationID"
:permissionLevel="permissionLevel" :permissionLevel="permissionLevel"
></MessagePlate> ></MessagePlate>
<div class="d-grid Actions">
<button type="button" class="btn btn-dark only-mobile" @click="foldMessage($event, 'private')">접기</button>
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'private')">
이전 메시지 불러오기
</button>
</div>
</template> </template>
</div> </div>
<div class="DiplomacyTalk"> <div class="DiplomacyTalk">
@@ -103,6 +121,12 @@
:nationID="nationID" :nationID="nationID"
:permissionLevel="permissionLevel" :permissionLevel="permissionLevel"
></MessagePlate> ></MessagePlate>
<div class="d-grid Actions">
<button type="button" class="btn btn-dark only-mobile" @click="foldMessage($event, 'diplomacy')">접기</button>
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'diplomacy')">
이전 메시지 불러오기
</button>
</div>
</template> </template>
</div> </div>
</div> </div>
@@ -429,6 +453,43 @@ function refreshMailboxList(obj: MabilboxListResponse) {
mailboxList.value = [favoriteBox, diplomacyMailboxList, ...nationMailboxList]; mailboxList.value = [favoriteBox, diplomacyMailboxList, ...nationMailboxList];
} }
function foldMessage($event: MouseEvent, type: MsgType) {
const target = messageIndexedList[type].value;
if (target.length < 10) {
return;
}
const remain = target.slice(10);
target.length = 10;
for(const msg of remain){
messageStorage.delete(msg.id);
}
}
async function loadOldMessage($event: MouseEvent, type: MsgType) {
const target = messageIndexedList[type].value;
if (target.length == 0) {
return;
}
const last = target[target.length - 1].id;
try {
const response = await SammoAPI.Message.GetOldMessage({
to: last,
type,
});
updateMsgResponse(response);
} catch (e) {
if (isString(e)) {
toasts.warning({
title: "이전 메시지 불러오기 실패",
body: e,
});
}
console.error(e);
}
}
async function sendMessage() { async function sendMessage() {
const text = newMessageText.value; const text = newMessageText.value;
if (!text) { if (!text) {
@@ -495,9 +556,6 @@ onMounted(async () => {
outline-color: gray; outline-color: gray;
} }
.PublicTalk {
}
@include media-1000px { @include media-1000px {
.MessagePanel { .MessagePanel {
display: grid; display: grid;
@@ -515,27 +573,36 @@ onMounted(async () => {
.PrivateTalk { .PrivateTalk {
border-right: 1px solid gray; border-right: 1px solid gray;
} }
.only-mobile{
display: none;
}
} }
@include media-500px{ @include media-500px {
#msg_submit-col {
#msg_submit-col{
order: 2; order: 2;
} }
#msg_input-col { #msg_input-col {
order: 3; order: 3;
} }
.MessageInputForm{ .MessageInputForm {
position: sticky; position: sticky;
top: 0px; top: 0px;
z-index: 5; z-index: 5;
} }
.stickyAnchor{ .stickyAnchor {
position: relative; position: relative;
top: -68px; top: -68px;
visibility: hidden; visibility: hidden;
} }
.d-grid.Actions {
grid-template-columns: 1fr 1fr;
}
} }
</style> </style>