mirror of
https://github.com/aclist/dztui.git
synced 2026-08-29 19:27:13 +02:00
fix: break after 10th record
This commit is contained in:
parent
2c9b36ba84
commit
1ea30270ce
@ -55,12 +55,22 @@ class ConfigManager:
|
|||||||
|
|
||||||
def update_history_file(self, fqip: str) -> None:
|
def update_history_file(self, fqip: str) -> None:
|
||||||
with open(self.prefs.paths.history, "r") as f:
|
with open(self.prefs.paths.history, "r") as f:
|
||||||
lines = [line.rstrip() for line in f.readlines()]
|
ips = [line.rstrip() for line in f.readlines()]
|
||||||
lines.append(fqip)
|
|
||||||
lines = set(lines)
|
seen = set()
|
||||||
dq = deque(lines, maxlen=10)
|
ips.append(fqip)
|
||||||
|
# NOTE: Preserve linear order of records while deduplicating
|
||||||
|
unique = deque(maxlen=10)
|
||||||
|
for i in range(len(ips) - 1, -1, -1):
|
||||||
|
if ips[i] not in seen:
|
||||||
|
seen.add(ips[i])
|
||||||
|
unique.appendleft(ips[i])
|
||||||
|
# NOTE: appendleft will push 11th item off right edge
|
||||||
|
if len(unique) == 10:
|
||||||
|
break
|
||||||
|
|
||||||
with open(self.prefs.paths.history, "w") as f:
|
with open(self.prefs.paths.history, "w") as f:
|
||||||
for record in dq:
|
for record in unique:
|
||||||
f.write(f"{record}\n")
|
f.write(f"{record}\n")
|
||||||
|
|
||||||
def remove_saved_server(self, record: str) -> None:
|
def remove_saved_server(self, record: str) -> None:
|
||||||
|
|||||||
@ -265,26 +265,26 @@ class ConnectionManager:
|
|||||||
addr = f"{self.record.ip}:{self.record.gameport}"
|
addr = f"{self.record.ip}:{self.record.gameport}"
|
||||||
playername = self.controller.query_config(Preferences.NAME)
|
playername = self.controller.query_config(Preferences.NAME)
|
||||||
client = self.controller.query_config(Preferences.CLIENT)
|
client = self.controller.query_config(Preferences.CLIENT)
|
||||||
if menu_only:
|
#if menu_only:
|
||||||
rc = load_to_menu(client, addr, self.appid, playername, self.remote_mod_ids)
|
# rc = load_to_menu(client, addr, self.appid, playername, self.remote_mod_ids)
|
||||||
else:
|
#else:
|
||||||
rc = connect(client, addr, self.appid, playername, self.remote_mod_ids)
|
# rc = connect(client, addr, self.appid, playername, self.remote_mod_ids)
|
||||||
if rc != 0:
|
#if rc != 0:
|
||||||
# TODO: log/pop the error
|
# # TODO: log/pop the error
|
||||||
func = StoredFunc(self.controller.update_status)
|
# func = StoredFunc(self.controller.update_status)
|
||||||
self.thread_man.set_cleanup_func(func)
|
# self.thread_man.set_cleanup_func(func)
|
||||||
return
|
# return
|
||||||
|
|
||||||
self.thread_man.show_cancel(False)
|
#self.thread_man.show_cancel(False)
|
||||||
self.thread_man.update_dialog(waiting_for_launch)
|
#self.thread_man.update_dialog(waiting_for_launch)
|
||||||
while True:
|
#while True:
|
||||||
# TODO: check cancel event
|
# # TODO: check cancel event
|
||||||
if self.controller.get_exit_event().is_set():
|
# if self.controller.get_exit_event().is_set():
|
||||||
# TODO: some facility to also close spawned steam process
|
# # TODO: some facility to also close spawned steam process
|
||||||
return
|
# return
|
||||||
if is_dayz_running():
|
# if is_dayz_running():
|
||||||
break
|
# break
|
||||||
time.sleep(1)
|
# time.sleep(1)
|
||||||
|
|
||||||
func = StoredFunc(self._add_to_history_and_return)
|
func = StoredFunc(self._add_to_history_and_return)
|
||||||
self.thread_man.set_cleanup_func(func)
|
self.thread_man.set_cleanup_func(func)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user