@@ -94,15 +94,13 @@ import { ref, computed } from 'vue';
9494import { IdCard , UserRound } from ' @lucide/vue' ;
9595import { useStyleStore } from ' @/stores/project/styleStore' ;
9696import { useLogStore } from ' @/stores/project/logStore' ;
97- import { useHistoryStore } from ' @/stores/editor/historyStore' ;
98- import { useLogEditorStore } from ' @/stores/project/logEditorStore' ;
97+ import { useLogCommands } from ' @/stores/project/logCommands' ;
9998import type { RoleType } from ' @/types/log' ;
10099import type { ColorMode , ColorRule } from ' @/types/style' ;
101100import { useWindowStore } from ' @/stores/ui/windowStore' ;
102101import {
103102 buildIdentityStats ,
104103 collectMessageIdsByIdentity ,
105- findFirstRoleByIdentity ,
106104} from ' @/editor/identity' ;
107105import { vClickOutside } from ' @/directives/clickOutside' ;
108106
@@ -115,8 +113,7 @@ interface IdentityListItem {
115113
116114const styleStore = useStyleStore ();
117115const logStore = useLogStore ();
118- const historyStore = useHistoryStore ();
119- const logEditorStore = useLogEditorStore ();
116+ const logCommands = useLogCommands ();
120117const windowStore = useWindowStore ();
121118const localDisplayMode = ref <ColorMode >(styleStore .viewSettings .colorMode );
122119const editingId = ref <string | null >(null );
@@ -163,44 +160,14 @@ function saveRename(oldVal: string) {
163160 }
164161
165162 const mode = localDisplayMode .value ;
166- const sourceIds = getMessageIdsForIdentity (oldVal );
167- const existingTargetIds = getMessageIdsForIdentity (newVal );
168-
169- const mergedRole =
170- existingTargetIds .size > 0
171- ? (getRoleForIdentity (newVal ) ?? getRoleForIdentity (oldVal ))
172- : null ;
173-
174- if (sourceIds .size > 0 ) {
175- historyStore .captureSnapshot ();
176- historyStore .runWithoutCapture (() => {
177- logEditorStore .batchUpdateMessages (
178- sourceIds ,
179- buildRenameUpdate (mode , newVal ),
180- );
181- const isMerged = styleStore .updateSystemRuleTarget (
182- mode ,
183- oldVal ,
184- newVal ,
185- );
186- if (isMerged && mergedRole ) {
187- const mergedIds = new Set <string >([
188- ... sourceIds ,
189- ... existingTargetIds ,
190- ]);
191- logEditorStore .batchUpdateMessages (mergedIds , {
192- role: mergedRole ,
193- });
194- }
195- });
196- }
163+ logCommands .renameIdentity (mode , oldVal , newVal );
197164 editingId .value = null ;
198165}
199166
200167function updateRole(id : string , newRole : RoleType ) {
201168 const targetIds = getMessageIdsForIdentity (id );
202169 if (targetIds .size > 0 ) {
203- logEditorStore .batchUpdateMessages (targetIds , { role: newRole });
170+ logCommands .batchUpdateMessages (targetIds , { role: newRole });
204171 }
205172}
206173
@@ -215,16 +182,6 @@ function getMessageIdsForIdentity(id: string) {
215182 id ,
216183 );
217184}
218- function getRoleForIdentity(id : string ): RoleType | null {
219- return findFirstRoleByIdentity (
220- logStore .allMessages ,
221- localDisplayMode .value ,
222- id ,
223- );
224- }
225- function buildRenameUpdate(mode : ColorMode , value : string ) {
226- return mode === ' playerName' ? { playerName: value } : { account: value };
227- }
228185function getRoleFromSelectEvent(event : Event ): RoleType {
229186 const value = (event .target as HTMLSelectElement ).value ;
230187 return value as RoleType ;
0 commit comments