messages now a bit different, less contructions
not constructing one for each possible message but only constructing when message happens
This commit is contained in:
@@ -38,12 +38,13 @@ class Message:
|
||||
self._args = []
|
||||
|
||||
|
||||
def msg(message, params):
|
||||
if not issubclass(type(message), Message):
|
||||
window.console.log("Not scheduling a Message type, this will not work!")
|
||||
return lambda: None
|
||||
|
||||
def msg(message_class, params):
|
||||
def callback(event):
|
||||
message.on_event(event) #message_class(event, params)
|
||||
message = message_class(params)
|
||||
if not issubclass(type(message), Message):
|
||||
window.console.log("Not scheduling a Message type, this will not work!")
|
||||
return
|
||||
|
||||
message.on_event(event)
|
||||
update.schedule(message)
|
||||
return callback
|
||||
|
||||
@@ -55,7 +55,7 @@ class ShowEditTranslation(ClickMessage):
|
||||
translation.make_copy()
|
||||
num_clusters = len(parent.translations)
|
||||
model.modal_set(lambda: modals.edit_translation(
|
||||
translation, cidx, num_clusters, EditTranslation(translation, cidx)))
|
||||
translation, cidx, num_clusters, (EditTranslation, translation, cidx)))
|
||||
|
||||
|
||||
class ShowAddTranslation(ClickMessage):
|
||||
@@ -68,7 +68,7 @@ class ShowAddTranslation(ClickMessage):
|
||||
translation,
|
||||
-1,
|
||||
len(chosen_sense_or_example.translations),
|
||||
AddTranslation(translation, -1, chosen_sense_or_example)))
|
||||
(AddTranslation, translation, -1, chosen_sense_or_example)))
|
||||
|
||||
|
||||
class ShowEntryLabelsEdit(ClickMessage):
|
||||
|
||||
@@ -62,7 +62,7 @@ class _ModalResetDelayed(Message):
|
||||
class ModalNotOkClose(Reset):
|
||||
def update_model(self, model):
|
||||
# msg just creates a callback, need to actually run it!
|
||||
window.setTimeout(lambda: msg(_ModalResetDelayed())(None), 100)
|
||||
window.setTimeout(lambda: msg(_ModalResetDelayed)(None), 100)
|
||||
|
||||
def data_change(self):
|
||||
return False
|
||||
|
||||
Reference in New Issue
Block a user