Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filecoin-station/core@18 #1296

Merged
merged 5 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 18 additions & 10 deletions main/activities.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
class Activities {
/** @type {Activity[]} */
#activities = []
#online = false
#online = {
spark: false,
voyager: false
}

/**
* Display last 100 activities
Expand All @@ -24,14 +27,19 @@ class Activities {
* @param {Activity} activity
*/
#detectChangeInOnlineStatus (activity) {
if (
activity.type === 'info' &&
(activity.message === 'SPARK started reporting retrievals' ||
activity.message === 'SPARK retrieval reporting resumed')
) {
this.#online = true
} else if (activity.message === 'SPARK failed reporting retrieval') {
this.#online = false
const firstWord = activity.message.split(' ')[0].toLowerCase()
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chose to make this a bit more dynamic, as I think it was getting too verbose and too easy to break when iterating on messages. It can produce false results too, so it's not a finished solution, but in my mind an improvement. Happy to follow up on this

if (activity.type === 'info') {
if (firstWord === 'spark') {
this.#online.spark = true
} else if (firstWord === 'voyager') {
this.#online.voyager = true
}
} else if (activity.type === 'error') {
if (firstWord === 'spark') {
this.#online.spark = false
} else if (firstWord === 'voyager') {
this.#online.voyager = false
}
}
}

Expand All @@ -40,7 +48,7 @@ class Activities {
}

isOnline () {
return this.#online
return this.#online.spark || this.#online.voyager
}
}

Expand Down
Loading