about summary refs log tree commit diff
path: root/app/javascript/mastodon/actions/trends.js
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2018-05-27 21:45:30 +0200
committerGitHub <noreply@github.com>2018-05-27 21:45:30 +0200
commit9bd23dc4e51ba47283a8e3a66cd94b4e624a5235 (patch)
tree119802887a7b894ea3aac5e28a8a7a15524c1c35 /app/javascript/mastodon/actions/trends.js
parent63c7b9157274f57c496399a1a5c728b32415034c (diff)
Track trending tags (#7638)
* Track trending tags

- Half-life of 1 day
- Historical usage in daily buckets (last 7 days stored)
- GET /api/v1/trends

Fix #271

* Add trends to web UI

* Don't render compose form on search route, adjust search results header

* Disqualify tag from trends if it's in disallowed hashtags setting

* Count distinct accounts using tag, ignore silenced accounts
Diffstat (limited to 'app/javascript/mastodon/actions/trends.js')
-rw-r--r--app/javascript/mastodon/actions/trends.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/app/javascript/mastodon/actions/trends.js b/app/javascript/mastodon/actions/trends.js
new file mode 100644
index 000000000..853e4f60a
--- /dev/null
+++ b/app/javascript/mastodon/actions/trends.js
@@ -0,0 +1,32 @@
+import api from '../api';
+
+export const TRENDS_FETCH_REQUEST = 'TRENDS_FETCH_REQUEST';
+export const TRENDS_FETCH_SUCCESS = 'TRENDS_FETCH_SUCCESS';
+export const TRENDS_FETCH_FAIL    = 'TRENDS_FETCH_FAIL';
+
+export const fetchTrends = () => (dispatch, getState) => {
+  dispatch(fetchTrendsRequest());
+
+  api(getState)
+    .get('/api/v1/trends')
+    .then(({ data }) => dispatch(fetchTrendsSuccess(data)))
+    .catch(err => dispatch(fetchTrendsFail(err)));
+};
+
+export const fetchTrendsRequest = () => ({
+  type: TRENDS_FETCH_REQUEST,
+  skipLoading: true,
+});
+
+export const fetchTrendsSuccess = trends => ({
+  type: TRENDS_FETCH_SUCCESS,
+  trends,
+  skipLoading: true,
+});
+
+export const fetchTrendsFail = error => ({
+  type: TRENDS_FETCH_FAIL,
+  error,
+  skipLoading: true,
+  skipAlert: true,
+});