From bad0b9ac7fa72f5b00ef691e81fc765deb9c2811 Mon Sep 17 00:00:00 2001 From: FloatingGhost Date: Wed, 8 Mar 2023 18:03:09 +0000 Subject: [PATCH] add akkoma setup set url to repo use same image as target we have to sudo on this image copy masto file use our builder bundle install include rake install rake just use their conifg re-lock deps update service worker build prod ignore ruby deps make sure we have zip yeet SW stream out to the right places fix URL in reactions add sounds to build fix serviceworker stop circles erroring us out fix onclick fix lookup revert changes to gemfile fix notification display don't fetch unsupported stuff yeet most of SW fix reply references fixes #2 fix emoji_reaction type fix public timeline --- .gitignore | 1 + .woodpecker.yml | 28 ++++++++++++++++ app/javascript/mastodon/actions/circles.js | 9 ++--- app/javascript/mastodon/actions/compose.js | 3 +- .../mastodon/actions/favourite_domains.js | 13 ++------ .../mastodon/actions/favourite_tags.js | 13 ++------ .../mastodon/actions/notifications.js | 6 ++-- app/javascript/mastodon/actions/timelines.js | 12 +++---- app/javascript/mastodon/components/account.js | 2 +- app/javascript/mastodon/components/hashtag.js | 33 ------------------- app/javascript/mastodon/components/status.js | 11 +++---- .../components/account_card.js | 2 +- .../features/public_timeline/index.js | 32 ++++++++---------- .../status/components/detailed_status.js | 2 ++ .../features/ui/components/tabs_bar.js | 4 +-- app/javascript/mastodon/features/ui/index.js | 5 +-- .../mastodon/service_worker/entry.js | 31 +++-------------- app/javascript/mastodon/stream.js | 3 +- build.sh | 20 +++++++++++ ci-builder/Dockerfile | 2 ++ config/webpack/shared.js | 7 ++-- dev.sh | 18 ++++++++++ package.json | 6 ++-- package.sh | 8 +++++ yarn.lock | 6 ++-- 25 files changed, 134 insertions(+), 143 deletions(-) create mode 100644 .woodpecker.yml create mode 100755 build.sh create mode 100644 ci-builder/Dockerfile create mode 100755 dev.sh create mode 100755 package.sh diff --git a/.gitignore b/.gitignore index b4d2712ff..8873d519d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ # Ignore bundler config and downloaded libraries. /.bundle /vendor/bundle +distribution # Ignore the default SQLite database. /db/*.sqlite3 diff --git a/.woodpecker.yml b/.woodpecker.yml new file mode 100644 index 000000000..3dcdb50da --- /dev/null +++ b/.woodpecker.yml @@ -0,0 +1,28 @@ +pipeline: + build: + when: + event: + - tag + - push + image: node:16 + commands: + - apt-get update && apt-get install -y zip + - yarn install --frozen-lockfile + - TARGET=distribution ./build.sh + - zip mastofe.zip -r distribution + + release: + image: akkoma/releaser + when: + event: + - tag + - push + secrets: + - SCW_ACCESS_KEY + - SCW_SECRET_KEY + - SCW_DEFAULT_ORGANIZATION_ID + commands: + - export SOURCE=mastofe.zip + - export DEST=scaleway:akkoma-updates/frontend/$${CI_COMMIT_TAG:-"$CI_COMMIT_BRANCH"}/fedibird-fe.zip + - /bin/sh /entrypoint.sh + diff --git a/app/javascript/mastodon/actions/circles.js b/app/javascript/mastodon/actions/circles.js index 8bd963417..c72fb9ff8 100644 --- a/app/javascript/mastodon/actions/circles.js +++ b/app/javascript/mastodon/actions/circles.js @@ -50,6 +50,7 @@ export const CIRCLE_ADDER_CIRCLES_FETCH_SUCCESS = 'CIRCLE_ADDER_CIRCLES_FETCH_SU export const CIRCLE_ADDER_CIRCLES_FETCH_FAIL = 'CIRCLE_ADDER_CIRCLES_FETCH_FAIL'; export const fetchCircle = id => (dispatch, getState) => { + return; if (getState().getIn(['circles', id])) { return; } @@ -77,12 +78,8 @@ export const fetchCircleFail = (id, error) => ({ error, }); -export const fetchCircles = () => (dispatch, getState) => { - dispatch(fetchCirclesRequest()); - - api(getState).get('/api/v1/circles') - .then(({ data }) => dispatch(fetchCirclesSuccess(data))) - .catch(err => dispatch(fetchCirclesFail(err))); +export const fetchCircles = () => () => { + return; }; export const fetchCirclesRequest = () => ({ diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index e2eab242d..5a18872db 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -112,9 +112,8 @@ export const getContextReference = (getState, status) => { return ImmutableSet(); } - const references = status.get('status_reference_ids').toSet(); const replyStatus = status.get('in_reply_to_id') ? getState().getIn(['statuses', status.get('in_reply_to_id')]) : null; - return references.concat(getContextReference(getState, replyStatus)); + return getContextReference(getState, replyStatus); }; export function changeCompose(text) { diff --git a/app/javascript/mastodon/actions/favourite_domains.js b/app/javascript/mastodon/actions/favourite_domains.js index 6304eb852..843ecde84 100644 --- a/app/javascript/mastodon/actions/favourite_domains.js +++ b/app/javascript/mastodon/actions/favourite_domains.js @@ -8,16 +8,8 @@ export const FAVOURITE_DOMAINS_FETCH_REQUEST = 'FAVOURITE_DOMAINS_FETCH_REQUEST' export const FAVOURITE_DOMAINS_FETCH_SUCCESS = 'FAVOURITE_DOMAINS_FETCH_SUCCESS'; export const FAVOURITE_DOMAINS_FETCH_FAIL = 'FAVOURITE_DOMAINS_FETCH_FAIL'; -export const fetchFavouriteDomain = id => (dispatch, getState) => { - if (getState().getIn(['favourite_domains', id])) { - return; - } - - dispatch(fetchFavouriteDomainRequest(id)); - - api(getState).get(`/api/v1/favourite_domains/${id}`) - .then(({ data }) => dispatch(fetchFavouriteDomainSuccess(data))) - .catch(err => dispatch(fetchFavouriteDomainFail(id, err))); +export const fetchFavouriteDomain = () => () => { + return; }; export const fetchFavouriteDomainRequest = id => ({ @@ -37,6 +29,7 @@ export const fetchFavouriteDomainFail = (id, error) => ({ }); export const fetchFavouriteDomains = () => (dispatch, getState) => { + return; dispatch(fetchFavouriteDomainsRequest()); api(getState).get('/api/v1/favourite_domains') diff --git a/app/javascript/mastodon/actions/favourite_tags.js b/app/javascript/mastodon/actions/favourite_tags.js index 91ffb95eb..e4493cb4b 100644 --- a/app/javascript/mastodon/actions/favourite_tags.js +++ b/app/javascript/mastodon/actions/favourite_tags.js @@ -8,16 +8,8 @@ export const FAVOURITE_TAGS_FETCH_REQUEST = 'FAVOURITE_TAGS_FETCH_REQUEST'; export const FAVOURITE_TAGS_FETCH_SUCCESS = 'FAVOURITE_TAGS_FETCH_SUCCESS'; export const FAVOURITE_TAGS_FETCH_FAIL = 'FAVOURITE_TAGS_FETCH_FAIL'; -export const fetchFavouriteTag = id => (dispatch, getState) => { - if (getState().getIn(['favourite_tags', id])) { - return; - } - - dispatch(fetchFavouriteTagRequest(id)); - - api(getState).get(`/api/v1/favourite_tags/${id}`) - .then(({ data }) => dispatch(fetchFavouriteTagSuccess(data))) - .catch(err => dispatch(fetchFavouriteTagFail(id, err))); +export const fetchFavouriteTag = () => () => { + return; }; export const fetchFavouriteTagRequest = id => ({ @@ -37,6 +29,7 @@ export const fetchFavouriteTagFail = (id, error) => ({ }); export const fetchFavouriteTags = () => (dispatch, getState) => { + return; dispatch(fetchFavouriteTagsRequest()); api(getState).get('/api/v1/favourite_tags') diff --git a/app/javascript/mastodon/actions/notifications.js b/app/javascript/mastodon/actions/notifications.js index 171943e8d..dcaf5a006 100644 --- a/app/javascript/mastodon/actions/notifications.js +++ b/app/javascript/mastodon/actions/notifications.js @@ -120,7 +120,7 @@ export function updateNotifications(notification, intlMessages, intlLocale) { const excludeTypesFromSettings = state => state.getIn(['settings', 'notifications', 'shows']).filter(enabled => !enabled).keySeq().toJS(); -const allTypes = ImmutableList(['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', enableReaction ? 'emoji_reaction' : null, enableStatusReference ? 'status_reference' : null].filter(x => !!x)) +const allTypes = ImmutableList(['follow', 'follow_request', 'favourite', 'reblog', 'mention', 'poll', enableReaction ? 'pleroma:emoji_reaction' : null, enableStatusReference ? 'status_reference' : null].filter(x => !!x)) const excludeTypesFromFilter = filter => { return allTypes.filterNot(item => item === filter).toJS(); @@ -141,9 +141,9 @@ export function expandNotifications({ maxId } = {}, done = noOp) { const params = { max_id: maxId, - exclude_types: activeFilter === 'all' + exclude_types: (activeFilter === 'all' ? excludeTypesFromSettings(getState()) - : excludeTypesFromFilter(activeFilter), + : excludeTypesFromFilter(activeFilter)).filter(x => x !== 'status_reference'), }; if (!params.max_id && (notifications.get('items', ImmutableList()).size + notifications.get('pendingItems', ImmutableList()).size) > 0) { diff --git a/app/javascript/mastodon/actions/timelines.js b/app/javascript/mastodon/actions/timelines.js index 27bf373b5..d9bb836bd 100644 --- a/app/javascript/mastodon/actions/timelines.js +++ b/app/javascript/mastodon/actions/timelines.js @@ -148,8 +148,6 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) { } } - params.compact = true; - const isLoadingRecent = !!params.since_id; dispatch(expandTimelineRequest(timelineId, isLoadingMore)); @@ -181,11 +179,11 @@ export function expandTimeline(timelineId, path, params = {}, done = noOp) { }; }; -export const expandHomeTimeline = ({ maxId, visibilities } = {}, done = noOp) => expandTimeline('home', '/api/v1/timelines/home', { max_id: maxId, visibilities: visibilities }, done); -export const expandLimitedTimeline = ({ maxId, visibilities } = {}, done = noOp) => expandTimeline('limited', '/api/v1/timelines/home', { max_id: maxId, visibilities: visibilities }, done); -export const expandPersonalTimeline = ({ maxId, onlyMedia, withoutMedia } = {}, done = noOp) => expandTimeline(`personal${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/personal', { max_id: maxId, only_media: !!onlyMedia, without_media: !!withoutMedia }, done); -export const expandPublicTimeline = ({ maxId, onlyMedia, withoutMedia, withoutBot, onlyRemote } = {}, done = noOp) => expandTimeline(`public${onlyRemote ? ':remote' : ''}${withoutBot ? ':nobot' : ':bot'}${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/public', { remote: !!onlyRemote, max_id: maxId, only_media: !!onlyMedia, without_media: !!withoutMedia, without_bot: !!withoutBot }, done); -export const expandDomainTimeline = (domain, { maxId, onlyMedia, withoutMedia, withoutBot } = {}, done = noOp) => expandTimeline(`domain${withoutBot ? ':nobot' : ':bot'}${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}:${domain}`, '/api/v1/timelines/public', { local: false, domain: domain, max_id: maxId, only_media: !!onlyMedia, without_media: !!withoutMedia, without_bot: !!withoutBot }, done); +export const expandHomeTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('home', '/api/v1/timelines/home', { max_id: maxId }, done); +export const expandLimitedTimeline = ({ maxId } = {}, done = noOp) => expandTimeline('limited', '/api/v1/timelines/home', { max_id: maxId }, done); +export const expandPersonalTimeline = ({ maxId, onlyMedia, withoutMedia } = {}, done = noOp) => expandTimeline(`personal${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}`, '/api/v1/timelines/personal', { max_id: maxId, only_media: !!onlyMedia }, done); +export const expandPublicTimeline = ({ maxId, onlyMedia, withoutMedia, onlyRemote } = {}, done = noOp) => expandTimeline('public', '/api/v1/timelines/public', { remote: !!onlyRemote, max_id: maxId, only_media: !!onlyMedia }, done); +export const expandDomainTimeline = (domain, { maxId, onlyMedia, withoutMedia, withoutBot } = {}, done = noOp) => expandTimeline(`domain${withoutBot ? ':nobot' : ':bot'}${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}:${domain}`, '/api/v1/timelines/public', { local: false, domain: domain, max_id: maxId, only_media: !!onlyMedia, without_media: !!withoutMedia }, done); export const expandGroupTimeline = (id, { maxId, onlyMedia, withoutMedia, tagged } = {}, done = noOp) => expandTimeline(`group:${id}${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}${tagged ? `:${tagged}` : ''}`, `/api/v1/timelines/group/${id}`, { max_id: maxId, only_media: !!onlyMedia, without_media: !!withoutMedia, tagged: tagged }, done); export const expandAccountTimeline = (accountId, { maxId, withReplies, withoutReblogs, tagged } = {}) => expandTimeline(`account:${accountId}${withReplies ? ':with_replies' : ''}${withoutReblogs ? ':without_reblogs' : ''}${tagged ? `:${tagged}` : ''}`, `/api/v1/accounts/${accountId}/statuses`, { exclude_replies: !withReplies, exclude_reblogs: withoutReblogs, tagged, max_id: maxId }); export const expandAccountCoversations = (accountId, { maxId } = {}) => expandTimeline(`account:${accountId}:conversations`, `/api/v1/accounts/${accountId}/conversations`, { max_id: maxId }); diff --git a/app/javascript/mastodon/components/account.js b/app/javascript/mastodon/components/account.js index b124557df..6cd80ce6d 100644 --- a/app/javascript/mastodon/components/account.js +++ b/app/javascript/mastodon/components/account.js @@ -164,7 +164,7 @@ class Account extends ImmutablePureComponent { return (
- +
{mute_expires_at} diff --git a/app/javascript/mastodon/components/hashtag.js b/app/javascript/mastodon/components/hashtag.js index 75fcf20e3..9537b0074 100644 --- a/app/javascript/mastodon/components/hashtag.js +++ b/app/javascript/mastodon/components/hashtag.js @@ -56,39 +56,6 @@ const Hashtag = ({ hashtag }) => ( > #{hashtag.get('name')}
- - -
- -
- -
- -
- - day.get('uses')) - .toArray()} - > - - -
); diff --git a/app/javascript/mastodon/components/status.js b/app/javascript/mastodon/components/status.js index 912129e04..afad589a8 100644 --- a/app/javascript/mastodon/components/status.js +++ b/app/javascript/mastodon/components/status.js @@ -255,14 +255,10 @@ class Status extends ImmutablePureComponent { handleAccountClick = (e) => { if (this.context.router && e.button === 0 && !(e.ctrlKey || e.metaKey)) { - const id = e.currentTarget.getAttribute('data-id'); - const group = e.currentTarget.getAttribute('data-group') !== 'false'; e.preventDefault(); - if (group) { - this.context.router.history.push(`/timelines/groups/${id}`); - } else { - this.context.router.history.push(`/accounts/${id}`); - } + const { status } = this.props; + const id = status.getIn(['account', 'id']); + this.context.router.history.push(`/accounts/${id}`); } } @@ -434,6 +430,7 @@ class Status extends ImmutablePureComponent { 'limited': { icon: 'user-circle', text: intl.formatMessage(messages.limited_short) }, 'direct': { icon: 'envelope', text: intl.formatMessage(messages.direct_short) }, 'personal': { icon: 'book', text: intl.formatMessage(messages.personal_short) }, + 'local': { icon: 'lock', text: 'local' }, }; if (hidden) { diff --git a/app/javascript/mastodon/features/group_directory/components/account_card.js b/app/javascript/mastodon/features/group_directory/components/account_card.js index f3ad1737a..b6471b3e2 100644 --- a/app/javascript/mastodon/features/group_directory/components/account_card.js +++ b/app/javascript/mastodon/features/group_directory/components/account_card.js @@ -304,7 +304,7 @@ class AccountCard extends ImmutablePureComponent { diff --git a/app/javascript/mastodon/features/public_timeline/index.js b/app/javascript/mastodon/features/public_timeline/index.js index 09d4d983a..2180705bb 100644 --- a/app/javascript/mastodon/features/public_timeline/index.js +++ b/app/javascript/mastodon/features/public_timeline/index.js @@ -23,16 +23,14 @@ const mapStateToProps = (state, { columnId }) => { const index = columns.findIndex(c => c.get('uuid') === uuid); const onlyMedia = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'public', 'other', 'onlyMedia']); const withoutMedia = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'withoutMedia']) : state.getIn(['settings', 'public', 'other', 'withoutMedia']); - const withoutBot = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'withoutBot']) : state.getIn(['settings', 'public', 'other', 'withoutBot']); const onlyRemote = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyRemote']) : state.getIn(['settings', 'public', 'other', 'onlyRemote']); const columnWidth = (columnId && index >= 0) ? columns.get(index).getIn(['params', 'columnWidth']) : state.getIn(['settings', 'public', 'columnWidth']); - const timelineState = state.getIn(['timelines', `public${onlyRemote ? ':remote' : ''}${withoutBot ? ':nobot' : ':bot'}${withoutMedia ? ':nomedia' : ''}${onlyMedia ? ':media' : ''}`]); + const timelineState = state.getIn(['timelines', 'public']); return { hasUnread: !!timelineState && timelineState.get('unread') > 0, onlyMedia, withoutMedia, - withoutBot, onlyRemote, columnWidth: columnWidth ?? defaultColumnWidth, }; @@ -49,7 +47,6 @@ class PublicTimeline extends React.PureComponent { static defaultProps = { onlyMedia: false, withoutMedia: false, - withoutBot: false, onlyRemote: false, }; @@ -62,17 +59,16 @@ class PublicTimeline extends React.PureComponent { hasUnread: PropTypes.bool, onlyMedia: PropTypes.bool, withoutMedia: PropTypes.bool, - withoutBot: PropTypes.bool, onlyRemote: PropTypes.bool, }; handlePin = () => { - const { columnId, dispatch, onlyMedia, withoutMedia, withoutBot, onlyRemote } = this.props; + const { columnId, dispatch, onlyMedia, withoutMedia, onlyRemote } = this.props; if (columnId) { dispatch(removeColumn(columnId)); } else { - dispatch(addColumn(onlyRemote ? 'REMOTE' : 'PUBLIC', { other: { onlyMedia, withoutMedia, withoutBot, onlyRemote } })); + dispatch(addColumn(onlyRemote ? 'REMOTE' : 'PUBLIC', { other: { onlyMedia, withoutMedia, onlyRemote } })); } } @@ -96,19 +92,19 @@ class PublicTimeline extends React.PureComponent { } componentDidMount () { - const { dispatch, onlyMedia, withoutMedia, withoutBot, onlyRemote } = this.props; + const { dispatch, onlyMedia, withoutMedia, onlyRemote } = this.props; - dispatch(expandPublicTimeline({ onlyMedia, withoutMedia, withoutBot, onlyRemote })); - this.disconnect = dispatch(connectPublicStream({ onlyMedia, withoutMedia, withoutBot, onlyRemote })); + dispatch(expandPublicTimeline({ onlyMedia, withoutMedia, onlyRemote })); + this.disconnect = dispatch(connectPublicStream({ onlyMedia, withoutMedia, onlyRemote })); } componentDidUpdate (prevProps) { - if (prevProps.onlyMedia !== this.props.onlyMedia || prevProps.withoutMedia !== this.props.withoutMedia || prevProps.withoutBot !== this.props.withoutBot || prevProps.onlyRemote !== this.props.onlyRemote) { - const { dispatch, onlyMedia, withoutMedia, withoutBot, onlyRemote } = this.props; + if (prevProps.onlyMedia !== this.props.onlyMedia || prevProps.withoutMedia !== this.props.withoutMedia || prevProps.onlyRemote !== this.props.onlyRemote) { + const { dispatch, onlyMedia, withoutMedia, onlyRemote } = this.props; this.disconnect(); - dispatch(expandPublicTimeline({ onlyMedia, withoutMedia, withoutBot, onlyRemote })); - this.disconnect = dispatch(connectPublicStream({ onlyMedia, withoutMedia, withoutBot, onlyRemote })); + dispatch(expandPublicTimeline({ onlyMedia, withoutMedia, onlyRemote })); + this.disconnect = dispatch(connectPublicStream({ onlyMedia, withoutMedia, onlyRemote })); } } @@ -124,13 +120,13 @@ class PublicTimeline extends React.PureComponent { } handleLoadMore = maxId => { - const { dispatch, onlyMedia, withoutMedia, withoutBot, onlyRemote } = this.props; + const { dispatch, onlyMedia, withoutMedia, onlyRemote } = this.props; - dispatch(expandPublicTimeline({ maxId, onlyMedia, withoutMedia, withoutBot, onlyRemote })); + dispatch(expandPublicTimeline({ maxId, onlyMedia, withoutMedia, onlyRemote })); } render () { - const { intl, columnId, hasUnread, multiColumn, onlyMedia, withoutMedia, withoutBot, onlyRemote, columnWidth } = this.props; + const { intl, columnId, hasUnread, multiColumn, onlyMedia, withoutMedia, onlyRemote, columnWidth } = this.props; const pinned = !!columnId; return ( @@ -151,7 +147,7 @@ class PublicTimeline extends React.PureComponent { { @@ -359,6 +360,7 @@ class DetailedStatus extends ImmutablePureComponent { 'limited': { icon: 'user-circle', text: intl.formatMessage(messages.limited_short) }, 'direct': { icon: 'envelope', text: intl.formatMessage(messages.direct_short) }, 'personal': { icon: 'book', text: intl.formatMessage(messages.personal_short) }, + 'local': { icon: 'local', text: 'local' }, }; const visibilityIcon = visibilityIconInfo[status.get('visibility')]; diff --git a/app/javascript/mastodon/features/ui/components/tabs_bar.js b/app/javascript/mastodon/features/ui/components/tabs_bar.js index ab414dc3e..7211733e6 100644 --- a/app/javascript/mastodon/features/ui/components/tabs_bar.js +++ b/app/javascript/mastodon/features/ui/components/tabs_bar.js @@ -40,8 +40,8 @@ export const getLinks = memoize((favouriteLists = null) => { return [ link_home, - enableLimitedTimeline ? link_limited : null, - enablePersonalTimeline ? link_personal : null, + null, // enableLimitedTimeline ? link_limited : null, + null, // enablePersonalTimeline ? link_personal : null, link_favourite_lists, link_notifications, enableLocalTimeline ? link_local : null, diff --git a/app/javascript/mastodon/features/ui/index.js b/app/javascript/mastodon/features/ui/index.js index 2dde6bc7d..9b896e50f 100644 --- a/app/javascript/mastodon/features/ui/index.js +++ b/app/javascript/mastodon/features/ui/index.js @@ -178,15 +178,12 @@ class SwitchingColumnsArea extends React.PureComponent { - - - - + diff --git a/app/javascript/mastodon/service_worker/entry.js b/app/javascript/mastodon/service_worker/entry.js index b354f3b33..034bce270 100644 --- a/app/javascript/mastodon/service_worker/entry.js +++ b/app/javascript/mastodon/service_worker/entry.js @@ -10,7 +10,7 @@ function openWebCache() { } function fetchRoot() { - return fetch('/', { credentials: 'include', redirect: 'manual' }); + return fetch('/web', { credentials: 'include', redirect: 'manual' }); } // const firefox = navigator.userAgent.match(/Firefox\/(\d+)/); @@ -19,7 +19,7 @@ function fetchRoot() { // Cause a new version of a registered Service Worker to replace an existing one // that is already installed, and replace the currently active worker on open pages. self.addEventListener('install', function(event) { - event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/', root))); + event.waitUntil(Promise.all([openWebCache(), fetchRoot()]).then(([cache, root]) => cache.put('/web', root))); }); self.addEventListener('activate', function(event) { event.waitUntil(self.clients.claim()); @@ -27,31 +27,8 @@ self.addEventListener('activate', function(event) { self.addEventListener('fetch', function(event) { const url = new URL(event.request.url); - if (url.pathname.startsWith('/web/')) { - const asyncResponse = fetchRoot(); - const asyncCache = openWebCache(); - - event.respondWith(asyncResponse.then( - response => { - const clonedResponse = response.clone(); - asyncCache.then(cache => cache.put('/', clonedResponse)).catch(); - return response; - }, - () => asyncCache.then(cache => cache.match('/')))); - } else if (url.pathname === '/auth/sign_out') { - const asyncResponse = fetch(event.request); - const asyncCache = openWebCache(); - - event.respondWith(asyncResponse.then(response => { - if (response.ok || response.type === 'opaqueredirect') { - return Promise.all([ - asyncCache.then(cache => cache.delete('/')), - indexedDB.deleteDatabase('mastodon'), - ]).then(() => response); - } - - return response; - })); + if (url.pathname.startsWith('/web')) { + return; } /* else if (storageFreeable && (ATTACHMENT_HOST ? url.host === ATTACHMENT_HOST : url.pathname.startsWith('/system/'))) { event.respondWith(openSystemCache().then(cache => { return cache.match(event.request.url).then(cached => { diff --git a/app/javascript/mastodon/stream.js b/app/javascript/mastodon/stream.js index 2db68b67a..3c47f6fbd 100644 --- a/app/javascript/mastodon/stream.js +++ b/app/javascript/mastodon/stream.js @@ -88,7 +88,8 @@ const sharedCallbacks = { }, received (data) { - const { stream } = data; + const { stream: streamFull } = data; + const stream = streamFull.map((name) => name.split(':')[0]); subscriptions.filter(({ channelName, params }) => { const streamChannelName = stream[0]; diff --git a/build.sh b/build.sh new file mode 100755 index 000000000..2a9c90385 --- /dev/null +++ b/build.sh @@ -0,0 +1,20 @@ +TARGET="${TARGET:-./distribution}" # Where pleroma’s repository is sitting +mkdir -p $TARGET/emoji + +die() { + echo "Die: $@" + exit 1 +} + +[ -d "${TARGET}" ] || die "${TARGET} directory is missing, are you sure TARGET is set to a pleroma repository? (Info: TARGET=${TARGET} )" + +yarn install -D || die "Installing dependencies via yarn failed" + +rm -rf public/packs public/assets +env -i "PATH=$PATH" yarn build:production || die "Building the frontend failed" +cp public/assets/sw.js "${TARGET}/sw.js" || die "installing sw.js (service-worker) failed" +rm -rf "${TARGET}/packs" || die "Removing old assets in priv/static/packs failed" +cp -r public/packs "${TARGET}/packs" || die "Copying new assets in priv/static/packs failed" +cp -r public/sounds "${TARGET}/sounds" || die "Copying sounds failed" +rm -rf "${TARGET}/emoji/*.svg" || die "Removing the old emoji assets failed" +cp -r public/emoji/* "${TARGET}/emoji" || die "Installing the new emoji assets failed" diff --git a/ci-builder/Dockerfile b/ci-builder/Dockerfile new file mode 100644 index 000000000..8702ab09a --- /dev/null +++ b/ci-builder/Dockerfile @@ -0,0 +1,2 @@ +FROM circleci/ruby:2.7-buster-node +USER root diff --git a/config/webpack/shared.js b/config/webpack/shared.js index 05828aebe..041a26316 100644 --- a/config/webpack/shared.js +++ b/config/webpack/shared.js @@ -34,9 +34,7 @@ module.exports = { ), output: { - filename: 'js/[name]-[chunkhash].js', - chunkFilename: 'js/[name]-[chunkhash].chunk.js', - hotUpdateChunkFilename: 'js/[id]-[hash].hot-update.js', + filename: 'js/[name].js', path: output.path, publicPath: output.publicPath, }, @@ -75,8 +73,7 @@ module.exports = { }, ), new MiniCssExtractPlugin({ - filename: 'css/[name]-[contenthash:8].css', - chunkFilename: 'css/[name]-[contenthash:8].chunk.css', + filename: 'css/[name].css', }), new AssetsManifestPlugin({ integrity: true, diff --git a/dev.sh b/dev.sh new file mode 100755 index 000000000..f5ec79d51 --- /dev/null +++ b/dev.sh @@ -0,0 +1,18 @@ +TARGET="${TARGET:-./distribution}" # Where pleroma’s repository is sitting +mkdir -p $TARGET/emoji + +die() { + echo "Die: $@" + exit 1 +} + +[ -d "${TARGET}" ] || die "${TARGET} directory is missing, are you sure TARGET is set to a pleroma repository? (Info: TARGET=${TARGET} )" + +yarn install -D || die "Installing dependencies via yarn failed" + +rm -rf public/packs public/assets +env -i "PATH=$PATH" bundle exec yarn build:development || die "Building the frontend failed" +rm -rf "${TARGET}/packs" || die "Removing old assets in priv/static/packs failed" +cp -r public/packs "${TARGET}/packs" || die "Copying new assets in priv/static/packs failed" +rm -rf "${TARGET}/emoji/*.svg" || die "Removing the old emoji assets failed" + diff --git a/package.json b/package.json index 6469a2b92..2d8dd5faa 100644 --- a/package.json +++ b/package.json @@ -6,8 +6,8 @@ }, "scripts": { "postversion": "git push --tags", - "build:development": "cross-env RAILS_ENV=development NODE_ENV=development ./bin/webpack", - "build:production": "cross-env RAILS_ENV=production NODE_ENV=production ./bin/webpack", + "build:development": "cross-env NODE_ENV=development webpack --config config/webpack/development.js", + "build:production": "cross-env NODE_ENV=production webpack --config config/webpack/production.js", "manage:translations": "node ./config/webpack/translationRunner.js", "start": "node ./streaming/index.js", "test": "${npm_execpath} run test:lint:js && ${npm_execpath} run test:jest", @@ -18,7 +18,7 @@ }, "repository": { "type": "git", - "url": "https://github.com/mastodon/mastodon.git" + "url": "https://akkoma.dev/AkkomaGang/fedibird-fe" }, "browserslist": [ "last 2 versions", diff --git a/package.sh b/package.sh new file mode 100755 index 000000000..d9f45a46f --- /dev/null +++ b/package.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +TARGET="${TARGET:-./distribution}" + +rm -rf "${TARGET}/packs" || die "Removing old assets in priv/static/packs failed" +cp -r public/packs "${TARGET}/packs" || die "Copying new assets in priv/static/packs failed" +rm -rf "${TARGET}/emoji/*.svg" || die "Removing the old emoji assets failed" +cp -r public/emoji/* "${TARGET}/emoji" || die "Installing the new emoji assets failed" diff --git a/yarn.lock b/yarn.lock index acfd6a2e5..c2fced139 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2946,9 +2946,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001219: - version "1.0.30001228" - resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001228.tgz#bfdc5942cd3326fa51ee0b42fbef4da9d492a7fa" - integrity sha512-QQmLOGJ3DEgokHbMSA8cj2a+geXqmnpyOFT0lhQV6P3/YOJvGDEwoedcwxEQ30gJIwIIunHIicunJ2rzK5gB2A== + version "1.0.30001462" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001462.tgz" + integrity sha512-PDd20WuOBPiasZ7KbFnmQRyuLE7cFXW2PVd7dmALzbkUXEP46upAuCDm9eY9vho8fgNMGmbAX92QBZHzcnWIqw== capture-exit@^2.0.0: version "2.0.0"