Skip to content

Commit 9556912

Browse files
committed
Remove Yes/No singleton cache on MenuItem
MenuItem.yes() and .no() cached their first-call result on the class, so labels stayed stuck in the language active at first call. With the new locale-apply Confirmation firing right after a language switch this became user-visible. Drop the cache and construct fresh items per call - allocation cost is negligible and equality continues to work via the dataclass __eq__.
1 parent a2f6950 commit 9556912

1 file changed

Lines changed: 3 additions & 12 deletions

File tree

archinstall/tui/ui/menu_item.py

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from dataclasses import dataclass, field
33
from enum import Enum
44
from functools import cached_property
5-
from typing import Any, ClassVar, Self, override
5+
from typing import Any, Self, override
66

77
from archinstall.lib.translationhandler import tr
88

@@ -23,9 +23,6 @@ class MenuItem:
2323

2424
_id: str = ''
2525

26-
_yes: ClassVar[Self | None] = None
27-
_no: ClassVar[Self | None] = None
28-
2926
def __post_init__(self) -> None:
3027
if self.key is not None:
3128
self._id = self.key
@@ -45,17 +42,11 @@ def get_value(self) -> Any:
4542

4643
@classmethod
4744
def yes(cls, action: Callable[[Any], Any] | None = None) -> Self:
48-
if cls._yes is None:
49-
cls._yes = cls(tr('Yes'), value=True, key='yes', action=action)
50-
51-
return cls._yes
45+
return cls(tr('Yes'), value=True, key='yes', action=action)
5246

5347
@classmethod
5448
def no(cls, action: Callable[[Any], Any] | None = None) -> Self:
55-
if cls._no is None:
56-
cls._no = cls(tr('No'), value=False, key='no', action=action)
57-
58-
return cls._no
49+
return cls(tr('No'), value=False, key='no', action=action)
5950

6051
def is_empty(self) -> bool:
6152
return self.text == '' or self.text is None

0 commit comments

Comments
 (0)