Skip to content

Commit 0a62419

Browse files
authored
Activity optimization (#112)
* Fix duplicate notification when started * Bump version to 2.1.11
1 parent f95dd6d commit 0a62419

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

octoapp/notificationsender.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,11 +518,13 @@ def pick_best_app(apps):
518518
activities = helper.GetActivities(apps)
519519
ios = helper.GetIosApps(apps)
520520
android = helper.GetAndroidApps(apps)
521+
hasActivityAutoStart = False
521522

522523
# For start events we can generate LiveActivity instances on the fly which will start a LiveActivity
523524
if event == self.EVENT_STARTED:
524525
for ios_app in ios:
525526
if ios_app.ActivityAutoStartToken:
527+
hasActivityAutoStart = True
526528
activities.append(ios_app.WithToken(ios_app.ActivityAutoStartToken))
527529

528530
if len(android):
@@ -531,7 +533,10 @@ def pick_best_app(apps):
531533
elif event in [self.EVENT_CUSTOM, self.EVENT_BEEP, self.EVENT_FIRST_LAYER_DONE, self.EVENT_THIRD_LAYER_DONE]:
532534
# If we have an event Live Activities can't handle send via notification
533535
return ios
534-
elif event in [self.EVENT_STARTED, self.EVENT_FILAMENT_REQUIRED, self.EVENT_USER_INTERACTION_NEEDED, self.EVENT_CANCELLED, self.EVENT_DONE, self.EVENT_ERROR]:
536+
elif event == self.EVENT_STARTED and hasActivityAutoStart:
537+
# We can start the activity automatically, only push to Activity
538+
return activities
539+
elif event in [self.EVENT_FILAMENT_REQUIRED, self.EVENT_USER_INTERACTION_NEEDED, self.EVENT_CANCELLED, self.EVENT_DONE, self.EVENT_ERROR]:
535540
# If we have a important event, send to all targets
536541
return activities + ios
537542
else:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
# The plugin's version. Can be overwritten within OctoPrint's internal data via __plugin_version__ in the plugin module
2424
# Note that this is also parsed by the moonraker module to pull the version, so the string and format must remain the same!
25-
plugin_version = "2.1.10"
25+
plugin_version = "2.1.11"
2626

2727
# The plugin's description. Can be overwritten within OctoPrint's internal data via __plugin_description__ in the plugin
2828
# module

0 commit comments

Comments
 (0)