fix: 메시지 삭제 안되는 버그
- GetRecentMessage에서 keepRecent 관련 오동작 수정 - 왜 이걸 넣었는지 생각해보기로..
This commit is contained in:
@@ -83,7 +83,6 @@ class GetRecentMessage extends \sammo\BaseAPI
|
|||||||
|
|
||||||
$result = [];
|
$result = [];
|
||||||
$result['result'] = true;
|
$result['result'] = true;
|
||||||
$result['keepRecent'] = false;
|
|
||||||
$nextSequence = $reqSequence;
|
$nextSequence = $reqSequence;
|
||||||
$minSequence = $reqSequence;
|
$minSequence = $reqSequence;
|
||||||
$lastType = null;
|
$lastType = null;
|
||||||
@@ -139,9 +138,6 @@ class GetRecentMessage extends \sammo\BaseAPI
|
|||||||
|
|
||||||
if ($lastType !== null) {
|
if ($lastType !== null) {
|
||||||
array_pop($result[$lastType]);
|
array_pop($result[$lastType]);
|
||||||
$result['keepRecent'] = true;
|
|
||||||
} else if ($reqSequence <= 0) {
|
|
||||||
$result['keepRecent'] = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$result['sequence'] = $nextSequence;
|
$result['sequence'] = $nextSequence;
|
||||||
|
|||||||
@@ -47,16 +47,19 @@
|
|||||||
<div>메시지가 없습니다.</div>
|
<div>메시지가 없습니다.</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-else class="MessageList">
|
<div v-else class="MessageList">
|
||||||
<MessagePlate
|
<template v-for="msg of messagePublic" :key="msg.id">
|
||||||
v-for="msg of messagePublic"
|
<MessagePlate
|
||||||
:key="msg.id"
|
v-if="!msg.option.hide"
|
||||||
:modelValue="msg"
|
:modelValue="msg"
|
||||||
:generalID="generalID"
|
:generalID="generalID"
|
||||||
:generalName="generalName"
|
:generalName="generalName"
|
||||||
:nationID="nationID"
|
:nationID="nationID"
|
||||||
:permissionLevel="permissionLevel"
|
:permissionLevel="permissionLevel"
|
||||||
@setTarget="setTarget"
|
:deleted="deletedMessage.has(msg.id)"
|
||||||
></MessagePlate>
|
@setTarget="setTarget"
|
||||||
|
@request-refresh="tryRefresh"
|
||||||
|
></MessagePlate>
|
||||||
|
</template>
|
||||||
<div class="d-grid Actions">
|
<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-dark only-mobile" @click="foldMessage($event, 'public')">접기</button>
|
||||||
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'public')">
|
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'public')">
|
||||||
@@ -79,16 +82,19 @@
|
|||||||
<div>메시지가 없습니다.</div>
|
<div>메시지가 없습니다.</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-else class="MessageList">
|
<div v-else class="MessageList">
|
||||||
<MessagePlate
|
<template v-for="msg of messageNational" :key="msg.id">
|
||||||
v-for="msg of messageNational"
|
<MessagePlate
|
||||||
:key="msg.id"
|
v-if="!msg.option.hide"
|
||||||
:modelValue="msg"
|
:modelValue="msg"
|
||||||
:generalID="generalID"
|
:generalID="generalID"
|
||||||
:generalName="generalName"
|
:generalName="generalName"
|
||||||
:nationID="nationID"
|
:nationID="nationID"
|
||||||
:permissionLevel="permissionLevel"
|
:permissionLevel="permissionLevel"
|
||||||
@setTarget="setTarget"
|
:deleted="deletedMessage.has(msg.id)"
|
||||||
></MessagePlate>
|
@setTarget="setTarget"
|
||||||
|
@request-refresh="tryRefresh"
|
||||||
|
></MessagePlate>
|
||||||
|
</template>
|
||||||
<div class="d-grid Actions">
|
<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-dark only-mobile" @click="foldMessage($event, 'national')">접기</button>
|
||||||
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'national')">
|
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'national')">
|
||||||
@@ -116,21 +122,19 @@
|
|||||||
<div>메시지가 없습니다.</div>
|
<div>메시지가 없습니다.</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-else class="MessageList">
|
<div v-else class="MessageList">
|
||||||
<MessagePlate
|
<template v-for="msg of messagePrivate" :key="msg.id">
|
||||||
v-for="msg of messagePrivate"
|
<MessagePlate
|
||||||
:key="msg.id"
|
v-if="!msg.option.hide"
|
||||||
:modelValue="msg"
|
:modelValue="msg"
|
||||||
:generalID="generalID"
|
:generalID="generalID"
|
||||||
:generalName="generalName"
|
:generalName="generalName"
|
||||||
:nationID="nationID"
|
:nationID="nationID"
|
||||||
:permissionLevel="permissionLevel"
|
:permissionLevel="permissionLevel"
|
||||||
@response="
|
:deleted="deletedMessage.has(msg.id)"
|
||||||
() => {
|
@setTarget="setTarget"
|
||||||
readLatestMsg('private');
|
@request-refresh="tryRefresh"
|
||||||
}
|
></MessagePlate>
|
||||||
"
|
</template>
|
||||||
@setTarget="setTarget"
|
|
||||||
></MessagePlate>
|
|
||||||
<div class="d-grid Actions">
|
<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-dark only-mobile" @click="foldMessage($event, 'private')">접기</button>
|
||||||
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'private')">
|
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'private')">
|
||||||
@@ -158,21 +162,19 @@
|
|||||||
<div>메시지가 없습니다.</div>
|
<div>메시지가 없습니다.</div>
|
||||||
</template>
|
</template>
|
||||||
<div v-else class="MessageList">
|
<div v-else class="MessageList">
|
||||||
<MessagePlate
|
<template v-for="msg of messageDiplomacy" :key="msg.id">
|
||||||
v-for="msg of messageDiplomacy"
|
<MessagePlate
|
||||||
:key="msg.id"
|
v-if="!msg.option.hide"
|
||||||
:modelValue="msg"
|
:modelValue="msg"
|
||||||
:generalID="generalID"
|
:generalID="generalID"
|
||||||
:generalName="generalName"
|
:generalName="generalName"
|
||||||
:nationID="nationID"
|
:nationID="nationID"
|
||||||
:permissionLevel="permissionLevel"
|
:permissionLevel="permissionLevel"
|
||||||
@response="
|
:deleted="deletedMessage.has(msg.id)"
|
||||||
() => {
|
@setTarget="setTarget"
|
||||||
readLatestMsg('diplomacy');
|
@request-refresh="tryRefresh"
|
||||||
}
|
></MessagePlate>
|
||||||
"
|
</template>
|
||||||
@setTarget="setTarget"
|
|
||||||
></MessagePlate>
|
|
||||||
<div class="d-grid Actions">
|
<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-dark only-mobile" @click="foldMessage($event, 'diplomacy')">접기</button>
|
||||||
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'diplomacy')">
|
<button type="button" class="btn btn-secondary" @click="loadOldMessage($event, 'diplomacy')">
|
||||||
@@ -244,6 +246,8 @@ const messageNational = ref<MsgItem[]>([]);
|
|||||||
const messagePrivate = ref<MsgItem[]>([]);
|
const messagePrivate = ref<MsgItem[]>([]);
|
||||||
const messageDiplomacy = ref<MsgItem[]>([]);
|
const messageDiplomacy = ref<MsgItem[]>([]);
|
||||||
|
|
||||||
|
const deletedMessage = ref(new Set<number>());
|
||||||
|
|
||||||
const messageIndexedList: Record<MsgType, Ref<MsgItem[]>> = {
|
const messageIndexedList: Record<MsgType, Ref<MsgItem[]>> = {
|
||||||
public: messagePublic,
|
public: messagePublic,
|
||||||
national: messageNational,
|
national: messageNational,
|
||||||
@@ -375,16 +379,21 @@ function processMsg(msg: MsgItem) {
|
|||||||
targetMsg.option.invalid = true;
|
targetMsg.option.invalid = true;
|
||||||
})();
|
})();
|
||||||
}
|
}
|
||||||
|
if (msg.option.overwrite) {
|
||||||
|
(() => {
|
||||||
|
for(const targetID of msg.option.overwrite) {
|
||||||
|
const targetMsg = messageStorage.get(targetID);
|
||||||
|
if (!targetMsg) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
deletedMessage.value.add(targetID);
|
||||||
|
targetMsg.option.invalid = true;
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function updateMsgResponse(response: MsgResponse) {
|
function updateMsgResponse(response: MsgResponse) {
|
||||||
if (!response.keepRecent) {
|
|
||||||
messageStorage.clear();
|
|
||||||
for (const msgList of Object.values(messageIndexedList)) {
|
|
||||||
msgList.value.length = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (response.generalName != generalName.value) {
|
if (response.generalName != generalName.value) {
|
||||||
emit("request-refresh");
|
emit("request-refresh");
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
import type { MsgItem, MsgTarget, MsgType } from "@/defs/API/Message";
|
import type { MsgItem, MsgTarget, MsgType } from "@/defs/API/Message";
|
||||||
import { parseTime } from "@/util/parseTime";
|
import { parseTime } from "@/util/parseTime";
|
||||||
import { differenceInMilliseconds, addMinutes } from "date-fns/esm";
|
import { differenceInMilliseconds, addMinutes } from "date-fns/esm";
|
||||||
import { computed, ref, toRef, watch, type ComputedRef, type Ref } from "vue";
|
import { computed, onMounted, ref, toRef, watch, type ComputedRef, type Ref } from "vue";
|
||||||
import linkifyStr from "linkify-string";
|
import linkifyStr from "linkify-string";
|
||||||
import { SammoAPI } from "@/SammoAPI";
|
import { SammoAPI } from "@/SammoAPI";
|
||||||
import { isError, isString } from "lodash-es";
|
import { isError, isString } from "lodash-es";
|
||||||
@@ -203,11 +203,10 @@ function testDeletable(msg: MsgItem): boolean {
|
|||||||
if (msg.option.action) return false;
|
if (msg.option.action) return false;
|
||||||
if (msg.src.id != props.generalID) return false;
|
if (msg.src.id != props.generalID) return false;
|
||||||
if (msg.option.invalid) return false;
|
if (msg.option.invalid) return false;
|
||||||
if (!msg.option.deletable) return false;
|
if (!(msg.option.deletable ?? true)) return false;
|
||||||
|
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const last5min = addMinutes(parseTime(msg.time), 5);
|
const last5min = addMinutes(parseTime(msg.time), 5);
|
||||||
|
|
||||||
const timeDiff = differenceInMilliseconds(last5min, now);
|
const timeDiff = differenceInMilliseconds(last5min, now);
|
||||||
|
|
||||||
if (timeDiff <= 0) return false;
|
if (timeDiff <= 0) return false;
|
||||||
@@ -219,6 +218,11 @@ function testDeletable(msg: MsgItem): boolean {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
isValidMsg.value = testValidMsg(msg.value);
|
||||||
|
deletable.value = testDeletable(msg.value);
|
||||||
|
});
|
||||||
|
|
||||||
const nationType: ComputedRef<"local" | "src" | "dest"> = computed(() => {
|
const nationType: ComputedRef<"local" | "src" | "dest"> = computed(() => {
|
||||||
if (msg.value.src.nation_id === msg.value.dest?.nation_id) {
|
if (msg.value.src.nation_id === msg.value.dest?.nation_id) {
|
||||||
return "local";
|
return "local";
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ export type MsgResponse = {
|
|||||||
[v in MsgType]: MsgItem[];
|
[v in MsgType]: MsgItem[];
|
||||||
} & {
|
} & {
|
||||||
result: true;
|
result: true;
|
||||||
keepRecent: boolean;
|
|
||||||
nationID: number;
|
nationID: number;
|
||||||
generalName: string;
|
generalName: string;
|
||||||
sequence: number;
|
sequence: number;
|
||||||
|
|||||||
@@ -227,18 +227,6 @@ function redrawMsg(msgResponse: MsgResponse, addFront: boolean): MsgResponse {
|
|||||||
})
|
})
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
function checkClear(obj: MsgResponse): MsgResponse {
|
|
||||||
if (!obj.keepRecent) {
|
|
||||||
$('.msg_plate').detach();
|
|
||||||
lastSequence = undefined;
|
|
||||||
console.log('refresh!');
|
|
||||||
void fetchRecentMsg().then(async (data) => {
|
|
||||||
redrawMsg(data, true);
|
|
||||||
})
|
|
||||||
throw true;
|
|
||||||
}
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
function registerSequence(obj: MsgResponse): MsgResponse {
|
function registerSequence(obj: MsgResponse): MsgResponse {
|
||||||
lastSequence = Math.max(lastSequence ?? 0, obj.sequence);
|
lastSequence = Math.max(lastSequence ?? 0, obj.sequence);
|
||||||
for (const msgType of ['public', 'private', 'national', 'diplomacy'] as MsgType[]) {
|
for (const msgType of ['public', 'private', 'national', 'diplomacy'] as MsgType[]) {
|
||||||
@@ -438,7 +426,6 @@ function redrawMsg(msgResponse: MsgResponse, addFront: boolean): MsgResponse {
|
|||||||
|
|
||||||
|
|
||||||
msgResponse = checkErasable(msgResponse);
|
msgResponse = checkErasable(msgResponse);
|
||||||
msgResponse = checkClear(msgResponse);
|
|
||||||
msgResponse = registerSequence(msgResponse);
|
msgResponse = registerSequence(msgResponse);
|
||||||
printTemplate(msgResponse);
|
printTemplate(msgResponse);
|
||||||
return msgResponse;
|
return msgResponse;
|
||||||
|
|||||||
Reference in New Issue
Block a user