Constructor
new TheAlgorithm(params)
Private constructor for TheAlgorithm. Use TheAlgorithm.create() to instantiate.
Parameters:
Name | Type | Description |
---|---|---|
params |
AlgorithmArgs | Constructor params (API client, user, and optional timeline callback/locale). |
Properties:
Name | Type | Attributes | Description |
---|---|---|---|
apiErrorMsgs |
Array.<string> | API error messages | |
filters |
FeedFilterSettings | Current filter settings for the feed | |
isLoading |
boolean | Whether a feed load is in progress* | |
lastLoadTimeInSeconds |
number |
<optional> |
Duration of the last load in seconds |
loadingStatus |
string | null | String describing load activity | |
timeline |
Array.<Toot> | The current filtered timeline | |
trendingData |
TrendingData | Trending data (links, tags, servers, toots) | |
userData |
UserData | User data for scoring and filtering | |
weightsInfo |
WeightInfoDict | Info about all scoring weights |
Members
(static) isDebugMode
True if FEDIALGO_DEBUG environment var was set at compile time.
(static) weightPresets
Dictionary of preset weight configurations for scoring.
Methods
(async) getCurrentState() → {Promise.<Record.<string, any>>}
Return an object describing the state of the world. Mostly for debugging.
Returns:
State object.
- Type
- Promise.<Record.<string, any>>
getRechartsStatsData(numPercentiles) → {Array.<object>}
Build array of objects suitable for charting timeline scoring data by quintile/decile/etc. with Recharts.
Parameters:
Name | Type | Description |
---|---|---|
numPercentiles |
number | Number of percentiles for stats. |
Returns:
Recharts data points.
- Type
- Array.<object>
(async) getUserWeights() → {Promise.<Weights>}
Return the user's current weightings for each score category.
Returns:
The user's weights.
- Type
- Promise.<Weights>
(async) isGoToSocialUser() → {boolean}
True if fedialgo user is on a GoToSocial instance instead of plain vanilla Mastodon.
Returns:
- Type
- boolean
mostRecentHomeTootAgeInSeconds() → {number|null}
Return the number of seconds since the most recent home timeline toot.
Returns:
Age in seconds or null.
- Type
- number | null
mostRecentHomeTootAt() → {Date|null}
Return the timestamp of the most recent toot from followed accounts + hashtags ONLY.
Returns:
The most recent toot date or null.
- Type
- Date | null
(async) refreshMutedAccounts() → {Promise.<void>}
Pull the latest list of muted accounts from the server and use that to filter any newly muted accounts
out of the timeline.
Returns:
- Type
- Promise.<void>
(async) refreshTrendingData() → {Promise.<TrendingData>}
Update the local trendingData property. // TODO: this shouldn't be necessary but there's weirdness on initial load
Returns:
- Type
- Promise.<TrendingData>
(async) reset(completeopt) → {Promise.<void>}
Clear everything from browser storage except the user's identity and weightings (unless complete is true).
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
complete |
boolean |
<optional> |
false | If true, remove user data as well. |
Returns:
- Type
- Promise.<void>
(async) saveTimelineToCache() → {Promise.<void>}
Save the current timeline to the browser storage. Used to save the state of toots' numTimesShown.
Returns:
- Type
- Promise.<void>
(async) serverInfo() → {Promise.<mastodon.v2.Instance>}
Return info about the Fedialgo user's home mastodon instance.
Returns:
Instance info.
- Type
- Promise.<mastodon.v2.Instance>
tagUrl(tag) → {string}
Get the URL for a tag on the user's home instance (aka "server").
Parameters:
Name | Type | Description |
---|---|---|
tag |
string | Hashtag | The tag or tag object. |
Returns:
The tag URL.
- Type
- string
(async) triggerFeedUpdate() → {Promise.<void>}
Trigger the retrieval of the user's timeline from all the sources.
Returns:
- Type
- Promise.<void>
(async) triggerHomeTimelineBackFill() → {Promise.<void>}
Trigger the loading of additional toots, farther back on the home timeline.
Returns:
- Type
- Promise.<void>
(async) triggerMoarData() → {Promise.<void>}
Manually trigger the loading of "moar" user data (recent toots, favourites, notifications, etc).
Usually done by a background task on a set interval.
Returns:
- Type
- Promise.<void>
(async) triggerPullAllUserData() → {Promise.<void>}
Collect *ALL* the user's history data from the server - past toots, favourites, etc.
Use with caution!
Returns:
- Type
- Promise.<void>
updateFilters(newFilters) → {Array.<Toot>}
Update the feed filters and return the newly filtered feed.
Parameters:
Name | Type | Description |
---|---|---|
newFilters |
FeedFilterSettings | The new filter settings. |
Returns:
The filtered feed.
- Type
- Array.<Toot>
(async) updateUserWeights(userWeights) → {Promise.<Array.<Toot>>}
Update user weightings and rescore / resort the feed.
Parameters:
Name | Type | Description |
---|---|---|
userWeights |
Weights | The new user weights. |
Returns:
The filtered and rescored feed.
- Type
- Promise.<Array.<Toot>>
(async) updateUserWeightsToPreset(presetName) → {Promise.<Array.<Toot>>}
Update user weightings to one of the preset values and rescore / resort the feed.
Parameters:
Name | Type | Description |
---|---|---|
presetName |
WeightPresetLabel | string | The preset name. |
Returns:
The filtered and rescored feed.
- Type
- Promise.<Array.<Toot>>
(async, static) create(params) → {Promise.<module:index~TheAlgorithm>}
Publicly callable constructor that instantiates the class and loads the feed from storage.
Parameters:
Name | Type | Description | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
params |
AlgorithmArgs | The parameters for algorithm creation.
Properties
|
Returns:
TheAlgorithm instance.
- Type
- Promise.<module:index~TheAlgorithm>