From faf7925ce0a8c58eddf2734b753f09dc70a4533a Mon Sep 17 00:00:00 2001 From: Sebastian Jambor Date: Mon, 19 Dec 2022 20:23:04 +0100 Subject: [PATCH] use external library --- .../mastodon/features/activity_log/index.js | 76 +------------------ app/javascript/styles/application.scss | 2 + 2 files changed, 6 insertions(+), 72 deletions(-) diff --git a/app/javascript/mastodon/features/activity_log/index.js b/app/javascript/mastodon/features/activity_log/index.js index 845aa8ac6..7ee189a36 100644 --- a/app/javascript/mastodon/features/activity_log/index.js +++ b/app/javascript/mastodon/features/activity_log/index.js @@ -1,11 +1,13 @@ import PropTypes from 'prop-types'; -import React, { useState } from 'react'; +import React from 'react'; import ImmutablePropTypes from 'react-immutable-proptypes'; import ImmutablePureComponent from 'react-immutable-pure-component'; import { injectIntl } from 'react-intl'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; +import ActivityPubVisualization from 'activity-pub-visualization'; + const getOrderedLists = createSelector([state => state.get('lists')], lists => { if (!lists) { return lists; @@ -191,77 +193,7 @@ class Lists extends ImmutablePureComponent { } render () { - // return
{this.state.logs.filter(x => x.type !== 'keep-alive').map(x => (
{JSON.stringify(x, null, 2)}
))}
; - return (
- { - this.state.logs - .filter(x => x.type !== 'keep-alive') - .map(x => ()) - } -
); + return ; } } - -const userRegex = /^https:\/\/([^\/]+)\/users\/([^\/]+)$/; - -function userName(uri) { - const match = uri.match(userRegex); - - if (match !== null) { - return `${match[2]}@${match[1]}`; - } else { - return uri; - } -} - -function Type({ activity }) { - switch (activity.type) { - case 'Follow': - return (<> -
Follow
-
{activity.object}
- ); - case 'Like': - return (<> -
Like
-
{activity.object}
- ); - case 'Note': - return (<> -
Note
-
{activity.content}
- ); - default: - return
{activity.type}
; - } -} - -function Activity({ activity }) { - if (!activity.type) { - return null; - } - - return (
- {activity.actor &&
From {userName(activity.actor)}
} - - {activity.object && } -
); -} - -function Foo({ event }) { - - const [showSource, setShowSource] = useState(false); - - return (
- -
-
{new Date(event.timestamp).toLocaleTimeString()}
-
Sent to {event.path}
- -
- {showSource &&
{JSON.stringify(event.data, null, 2)}
} -
); -} diff --git a/app/javascript/styles/application.scss b/app/javascript/styles/application.scss index 81a040108..c60a5fa94 100644 --- a/app/javascript/styles/application.scss +++ b/app/javascript/styles/application.scss @@ -23,3 +23,5 @@ @import 'mastodon/dashboard'; @import 'mastodon/rtl'; @import 'mastodon/accessibility'; + +@import 'activity-pub-visualization';