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

Use 'vite-plugin-pwa' to generate the service worker and PWA manifest #1693

Merged
merged 170 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
f0ea22f
Take Save out of "more" menu
n1313 Jan 7, 2022
2783b1b
Start beta
indeyets Jan 9, 2022
ac84e1a
Merge origin/video-on-client into beta
indeyets Jan 9, 2022
31add5a
Merge origin/extract-save into beta
indeyets Jan 9, 2022
4207f3c
Merge line-height into beta
indeyets Jan 9, 2022
c9478e6
Merge save-style-fixes into beta
indeyets Jan 9, 2022
63d883d
Merge branch 'release' into beta
davidmz Feb 3, 2022
0a5c8c6
Merge branch 'release' into beta
davidmz Feb 3, 2022
a5f37f6
Merge pull request #1512 from FreeFeed/regdate
n1313 Mar 15, 2022
56d6703
Merge pull request #1514 from FreeFeed/regdate
n1313 Mar 18, 2022
5fd9f5a
Merge branch 'hide-banned-replies' into beta
davidmz Mar 19, 2022
f06e465
Merge release into beta
indeyets Mar 24, 2022
53bd586
Merge release into beta
indeyets Mar 24, 2022
420d092
Merge branch 'beta' into comment-preview
davidmz Apr 18, 2022
339f369
Merge pull request #1529 from FreeFeed/comment-preview
davidmz Apr 18, 2022
4d6ecb8
Fix direct comments background
davidmz Apr 18, 2022
413d3e8
Merge pull request #1530 from FreeFeed/comment-preview-beta
davidmz Apr 18, 2022
a2177b5
Fix scroll to already focused comment
davidmz Apr 19, 2022
71aee40
Merge pull request #1531 from FreeFeed/comment-preview-beta
davidmz Apr 19, 2022
bfcc526
Merge release into beta
indeyets Apr 20, 2022
b0a408c
Merge branch 'release' into beta
indeyets Apr 20, 2022
8d72367
Merge release into beta
indeyets Apr 20, 2022
3497225
Merge release into beta
indeyets May 12, 2022
8cadcac
Merge release into beta
indeyets Jun 29, 2022
4647ed6
Merge branch 'hide-hashtags-beta' into beta
davidmz Jul 27, 2022
0368cc8
Fix the hide criteria obtaining from whoami-like action
davidmz Jul 27, 2022
1ed22ec
Merge release into beta
indeyets Sep 7, 2022
9e329fa
Merge video-on-client into beta
indeyets Sep 7, 2022
7c7883b
Merge release into beta
indeyets Sep 8, 2022
aeb7796
Bump beta-version
indeyets Sep 8, 2022
fcf2465
Merge branch 'release' into beta
davidmz Sep 23, 2022
5e0fe60
Fix test snapshot on beta
davidmz Sep 23, 2022
aeb35c5
Merge branch 'release' into beta
davidmz Nov 25, 2022
e7e3dc4
Merge release into beta
indeyets Dec 25, 2022
b8beaa5
Merge release into beta
indeyets Jan 19, 2023
0481fc7
Merge release into beta
davidmz Feb 10, 2023
e0c909f
Merge release into beta
davidmz Feb 14, 2023
368c741
Merge release into beta
davidmz Feb 21, 2023
8f1a1fc
Merge branch 'rich-notifications' into beta
davidmz Feb 21, 2023
13d9f42
Merge branch 'rich-notifications' into beta
davidmz Feb 21, 2023
7d17de4
Merge branch 'rich-notifications' into beta
davidmz Feb 23, 2023
9e61db3
Merge branch 'rich-notifications' into beta
davidmz Feb 26, 2023
2bbc581
Fix test snapshots
davidmz Feb 26, 2023
7690cd0
Merge branch 'rich-notifications' into beta
davidmz Mar 3, 2023
e413bd1
Merge branch 'release' into beta
davidmz Mar 10, 2023
6333a4f
Merge branch 'release' into beta
davidmz Mar 11, 2023
55b67c8
Merge branch 'post-form/uploader' into beta
davidmz Mar 27, 2023
ce86349
ci: push images to ghcr.io
id Mar 27, 2023
2b914db
Merge pull request #1594 from FreeFeed/ci-push-images-to-ghcr.io
id Mar 27, 2023
bcd2bfa
ci: explicitly specify context for docker buildx
id Mar 28, 2023
bd08f7f
Merge pull request #1595 from FreeFeed/ci-explicitly-specify-context-…
id Mar 28, 2023
ad60c5c
Merge branch 'release' into beta
davidmz Mar 31, 2023
3012f13
Update test snapshot
davidmz Mar 31, 2023
7ee098f
Merge branch 'release' into beta
davidmz Apr 1, 2023
00e7c00
ci: fix docker workflow
id Apr 2, 2023
3bae746
Merge pull request #1601 from FreeFeed/beta-ci-fix-docker-workflow
id Apr 2, 2023
4be8d80
Use new feed selector in post create form
davidmz Apr 7, 2023
b110633
Remove the directsReceivers reducer
davidmz Apr 7, 2023
da960bf
Allow users to create posts in groups they are not subscribed to
davidmz Apr 7, 2023
c75fa60
Use new feed selector in post edit form
davidmz Apr 7, 2023
baf56d2
Make all CreateForm controls focusable
davidmz Apr 7, 2023
684eedc
Fix tab order of post forms controls
davidmz Apr 7, 2023
240c12f
Add privacy icon to post submit button
davidmz Apr 7, 2023
949ae85
Move AccountsSelector to the separate component and add dynamic loading
davidmz Apr 8, 2023
6717ee5
Use new selector in the invitation form
davidmz Apr 8, 2023
755c381
Fix selector styles in dark mode
davidmz Apr 9, 2023
0fcafbb
Use new selector in bookmarklet
davidmz Apr 10, 2023
8f8231f
Remove old SendTo component
davidmz Apr 10, 2023
34a65b4
Remove unused code
davidmz Apr 10, 2023
4938c23
Update tests
davidmz Apr 10, 2023
1385620
Show usernames and screennames in feeds selector
davidmz Apr 10, 2023
2d2e825
Fix direct/regular detection (own feed present means regular post)
davidmz Apr 11, 2023
ea7f78d
Remove group icons, better privacy check
davidmz Apr 11, 2023
27d1df4
Fix direct mode detection on Directs page
davidmz Apr 14, 2023
6667a97
Add privacy icons to groups
davidmz Apr 29, 2023
e68a446
Better 'create option' message
davidmz Apr 29, 2023
dd1c7f8
Update title of the "Groups" options
davidmz Apr 29, 2023
6ab7d6f
Auto-fix incorrect layout when typing in selector
davidmz Apr 29, 2023
b93838b
Update test snapshot
davidmz Apr 29, 2023
9e34c65
Update changelog
davidmz Apr 30, 2023
9173ea7
Use only pathname of link to check if it is a link to image
davidmz Apr 13, 2023
53e51e3
Merge branch 'post-form/selector' into beta
davidmz Apr 30, 2023
7eeb5a5
Add arial-abel to post submit buttons
davidmz May 1, 2023
bcedcb3
Update some error and warning texts
davidmz May 1, 2023
b57fe06
Collect selector theme colors in a separate object
davidmz May 1, 2023
67e0593
Merge branch 'post-form/selector' into beta
davidmz May 1, 2023
085e3ac
Update test snapshot
davidmz May 1, 2023
3338c95
Merge branch 'post-form/selector' into beta
davidmz May 1, 2023
4919bb9
Fix selector option color
davidmz May 1, 2023
dc18728
Merge branch 'post-form/selector' into beta
davidmz May 1, 2023
1144cde
Show links to groups/users from the feed selector
davidmz May 1, 2023
ae0d51a
Merge branch 'post-form/selector' into beta
davidmz May 1, 2023
5bed34a
Merge branch 'release' into beta
davidmz May 5, 2023
9bc2442
Merge branch 'stable' into beta
davidmz May 26, 2023
fec4d05
Merge branch 'release' into beta
davidmz Jun 2, 2023
7b85178
Merge branch 'release' into beta
davidmz Jun 14, 2023
c9e419a
Add 'role' attribute to the List Editor search box
davidmz Jun 14, 2023
7af98bc
Merge branch 'release' into beta
davidmz Jun 15, 2023
319f758
Merge branch 'release' into beta
davidmz Jun 22, 2023
5b79209
Merge branch 'release' into beta
davidmz Jul 15, 2023
93f7bab
Update test snapshots
davidmz Jul 15, 2023
0b03c2f
Merge branch 'release' into beta
davidmz Jul 15, 2023
26d4b0a
Merge branch 'checklist' into beta
davidmz Jul 25, 2023
85dfeba
Merge branch 'checklist' into beta
davidmz Jul 26, 2023
6f28fe5
Merge branch 'checklist' into beta
davidmz Jul 31, 2023
9c5db73
Merge branch 'release' into beta
davidmz Jul 31, 2023
a3ddb06
Merge branch 'release' into beta
davidmz Aug 10, 2023
4a7ec6a
Merge branch 'release' into beta
davidmz Sep 5, 2023
aa318ea
Merge branch 'release' into beta
davidmz Sep 7, 2023
75c3530
Merge branch 'release' into beta
davidmz Sep 10, 2023
117e1fd
Merge branch 'release' into beta
davidmz Sep 15, 2023
fdb8f7d
Merge branch 'release' into beta
davidmz Oct 11, 2023
fa32ac7
Merge branch 'release' into beta
davidmz Oct 11, 2023
e7f2b84
Merge branch 'release' into beta
davidmz Oct 25, 2023
4e9c134
Merge branch 'release' into beta
davidmz Nov 24, 2023
a0bb3f7
Remove Node 16 from the 'check' action list
davidmz Nov 24, 2023
2f3d531
Merge branch 'release' into beta
davidmz Nov 24, 2023
d1f8f87
Merge branch 'release' into beta
davidmz Dec 21, 2023
5fad36f
Merge branch 'release' into beta
davidmz Jan 19, 2024
3dc475d
Merge branch 'release' into beta
davidmz Feb 2, 2024
361e212
Merge branch 'release' into beta
davidmz Feb 4, 2024
796eddb
Merge branch 'release' into beta
davidmz Feb 14, 2024
b0c0560
Merge branch 'release' into beta
davidmz Mar 1, 2024
0f944de
Update test snapshot
davidmz Mar 1, 2024
3db19f4
Merge branch 'release' into beta
davidmz Mar 18, 2024
6d81d1c
Merge branch 'release' into beta
davidmz Mar 29, 2024
6de8a0c
Merge branch 'release' into beta
davidmz Apr 9, 2024
2710f13
Merge branch 'release' into beta
davidmz Apr 10, 2024
c9b9dc2
Merge branch 'release' into beta
davidmz Apr 10, 2024
2fd6410
Merge branch 'release' into beta
davidmz Apr 12, 2024
326d365
Allow to unfold comments step by step
davidmz Mar 28, 2024
d19e298
Add scroll compensation
davidmz Apr 7, 2024
0124d27
Set minToSteppedFold to 15
davidmz Apr 12, 2024
4b917e3
Merge branch 'partial-comments-unfold' into beta
davidmz Apr 12, 2024
196a5dd
Update style of more-comments-wrapper elements
davidmz Apr 13, 2024
6d26799
Merge branch 'partial-comments-unfold' into beta
davidmz Apr 13, 2024
012cb49
Add will-change: transform to unfolded comments
davidmz Apr 13, 2024
94a1203
Merge branch 'partial-comments-unfold' into beta
davidmz Apr 13, 2024
6e8de8b
Turn off scroll compensation for partial unfold
davidmz Apr 19, 2024
2c80d9d
Merge branch 'symmetric-bans' into beta
davidmz Apr 19, 2024
130d83d
Merge branch 'release' into beta
davidmz Apr 26, 2024
93be231
Merge branch 'release' into beta
davidmz May 5, 2024
f1595c0
Merge branch 'release' into beta
davidmz May 6, 2024
e54a532
Merge branch 'release' into beta
davidmz May 8, 2024
7dbfb74
Merge branch 'release' into beta
davidmz May 8, 2024
47a6231
Merge branch 'release' into beta
davidmz May 27, 2024
24bc43b
Merge branch 'v3-api' into beta
davidmz Jun 25, 2024
bd4b199
Merge branch 'autocomplete' into beta
davidmz Jun 26, 2024
b8f1623
Merge branch 'autocomplete' into beta
davidmz Jun 26, 2024
657784d
Merge branch 'autocomplete' into beta
davidmz Jun 27, 2024
29bd8bc
Update React states right after text update
davidmz Jun 27, 2024
43bce9e
Merge branch 'autocomplete' into beta
davidmz Jun 27, 2024
202e0f4
Merge branch 'autocomplete' into beta
davidmz Jun 28, 2024
3e8ee4c
Merge branch 'autocomplete' into beta
davidmz Jun 29, 2024
c5a525c
Merge branch 'release' into beta
davidmz Jul 4, 2024
50bdaed
Merge branch 'release' into beta
davidmz Jul 15, 2024
804c401
Merge branch 'release' into beta
davidmz Jul 15, 2024
d695537
Merge branch 'release' into beta
davidmz Jul 20, 2024
06060fa
Merge branch 'release' into beta
davidmz Jul 29, 2024
f98ef5c
Merge branch 'release' into beta
davidmz Aug 26, 2024
55227bf
Update site icons set using the @vite-pwa/assets-generator
davidmz Aug 24, 2024
9d25d0e
Use 'vite-plugin-pwa' to generate the service worker and PWA manifest
davidmz Aug 24, 2024
f5db696
Add /docs/ pattern to the navigateFallbackDenylist
davidmz Aug 26, 2024
ffccf52
Update changelog
davidmz Aug 26, 2024
b7cd33b
Remove the 'display' parameter from the web manifest
davidmz Aug 26, 2024
0d10556
Don't check version.txt if the service worker is in use
davidmz Aug 28, 2024
5884f2b
Add /assets/ and /robots.txt to the service worker ignore list
davidmz Sep 3, 2024
607fccb
Merge branch 'pwa' into beta
davidmz Sep 3, 2024
e33d74e
Exclude index.html from cache
davidmz Sep 3, 2024
c575f80
Merge branch 'beta' into pwa
davidmz Sep 3, 2024
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
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ module.exports = {
'import/no-extraneous-dependencies': 2,
'import/no-named-as-default': 2,
'import/no-named-as-default-member': 2,
'import/no-unresolved': 2,
'import/no-unresolved': ['error', { ignore: ['^virtual:'] }],
'import/order': [
2,
{ groups: ['builtin', 'external', 'internal', 'parent', 'sibling', 'index'] },
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,3 @@ jobs:
with:
url: "https://webhook.freefeed.net/${{ secrets.WEBHOOK_SECRET }}/react-client/beta?version=beta"
method: GET

11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.135.0] - Not released
## Experimental
### Added
- The PWA manifest and the service worker was added. The service worker caches
all site assets, including web fonts. It also caches user profile pictures (up
to 100 entries). The AppUpdated component periodically checks the service
worker for update.

## [1.134.4] - 2024-08-26
### Changed
Expand Down Expand Up @@ -379,6 +384,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
created the post, or add their @username to the comment you have already started creating.
- Vimeo on demand links support
### Changed
- Take Save out of "more" menu
- The Dropzone library has been replaced with a custom file uploader.
Attachments for posts and comments are now uploaded uniformly. The CreatePost
and PostEditForm components have been redesigned to utilize the new uploader.
Expand Down Expand Up @@ -486,6 +492,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- It is now possible to hide posts by hashtags! Also, the underlying algorithm
allows to add other types of hiding criteria in the future.

### Changed
- Take Save out of "more" menu

## [1.110.0] - 2022-06-29
### Fixed
- The erroneous "Remove from" items has been removed from the post's "More" menu
Expand Down
15 changes: 3 additions & 12 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,9 @@
<title>FreeFeed</title>
<meta name="description" content="FreeFeed is a small and free social network, that enables you to discover and discuss the interesting stuff your friends find on the web">

<link rel="icon" href="/assets/images/favicon.ico" type="image/x-icon" />
<link rel="icon" href="/assets/images/favicon.svg" type="image/svg+xml" />
<link rel="apple-touch-icon" sizes="512x512" href="/assets/images/ios/icon_512_512.png" />
<link rel="apple-touch-icon" sizes="256x256" href="/assets/images/ios/icon_256_256.png" />
<link rel="apple-touch-icon" sizes="192x192" href="/assets/images/ios/icon_192_192.png" />
<link rel="apple-touch-icon" sizes="180x180" href="/assets/images/ios/icon_180_180.png" />
<link rel="apple-touch-icon" sizes="152x152" href="/assets/images/ios/icon_152_152.png" />
<link rel="apple-touch-icon" sizes="144x144" href="/assets/images/ios/icon_144_144.png" />
<link rel="apple-touch-icon" sizes="120x120" href="/assets/images/ios/icon_120_120.png" />
<link rel="apple-touch-icon" sizes="114x114" href="/assets/images/ios/icon_114_114.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/assets/images/ios/icon_76_76.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/assets/images/ios/icon_72_72.png" />
<link rel="icon" href="/assets/images/favicon.ico" sizes="48x48">
<link rel="icon" href="/assets/images/favicon.svg" sizes="any" type="image/svg+xml">
<link rel="apple-touch-icon" href="/assets/images/apple-touch-icon-180x180.png">

<noscript>
<style>
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
"vite": "~5.3.5",
"vite-plugin-compression": "~0.5.1",
"vite-plugin-generate-file": "~0.2.0",
"vitest": "~2.0.4"
"vite-plugin-pwa": "^0.20.1",
"vitest": "~2.0.4",
"workbox-window": "^7.1.0"
},
"scripts": {
"start": "vite",
Expand Down
Binary file added public/assets/images/apple-touch-icon-180x180.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/assets/images/favicon.ico
Binary file not shown.
Binary file removed public/assets/images/ios/icon_114_114.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_120_120.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_144_144.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_152_152.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_180_180.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_192_192.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_256_256.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_512_512.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_72_72.png
Binary file not shown.
Binary file removed public/assets/images/ios/icon_76_76.png
Binary file not shown.
Binary file added public/assets/images/maskable-icon-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/pwa-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/pwa-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/assets/images/pwa-64x64.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 32 additions & 9 deletions src/components/app-updated.jsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,44 @@
/* global CONFIG */
import { useSelector } from 'react-redux';
import { useRegisterSW } from 'virtual:pwa-register/react';

import { useEvent } from 'react-use-event-hook';
import { useState } from 'react';
import styles from './app-updated.module.scss';
import { ButtonLink } from './button-link';

function reloadPage() {
window.location.reload(true);
}
const { intervalSec } = CONFIG.appVersionCheck;

export function AppUpdated() {
const updated = useSelector((state) => state.appUpdated.updated);
const versionFileUpdated = useSelector((state) => state.appUpdated.updated);
const [swRegistered, setSwRegistered] = useState(false);

const {
needRefresh: [workerUpdated],
updateServiceWorker,
} = useRegisterSW({
onRegistered(r) {
if (r) {
setSwRegistered(true);
setInterval(() => r.update(), intervalSec * 1000);
}
},
});

const reloadPage = useEvent(() => {
if (workerUpdated) {
updateServiceWorker();
// Sometimes the updateServiceWorker doesn't refresh the page, so reload
// it manually after some time
setTimeout(() => window.location.reload(true), 2000);
} else {
window.location.reload(true);
}
});

if (!updated) {
return null;
}
const needRefresh = swRegistered ? workerUpdated : versionFileUpdated;

return (
return needRefresh ? (
<div className={styles.bar}>
<div className={styles.indicator}>
There’s an update for {CONFIG.siteTitle}!{' '}
Expand All @@ -25,5 +48,5 @@ export function AppUpdated() {
when you are ready.
</div>
</div>
);
) : null;
}
2 changes: 1 addition & 1 deletion src/components/footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default function Footer({ short }) {
return (
<footer className="footer">
<p role="navigation">
&copy; FreeFeed 1.135.0 (Not released)
&copy; FreeFeed 1.134.4-beta (Sep 3, 2024)
<br />
<Link to="/about">About</Link>
{' | '}
Expand Down
16 changes: 1 addition & 15 deletions src/components/post/post-more-link.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { CLOSE_ON_CLICK_OUTSIDE } from '../hooks/drop-down';
import { useDropDownKbd } from '../hooks/drop-down-kbd';
import { useMediaQuery } from '../hooks/media-query';
import { MoreWithTriangle } from '../more-with-triangle';
import { TimedMessage } from '../timed-message';
import { ButtonLink } from '../button-link';

import { PostMoreMenu } from './post-more-menu';
Expand All @@ -34,19 +33,6 @@ export default function PostMoreLink({ post, user, ...props }) {

const canonicalPostURI = canonicalURI(post);

const { isSaved, savePostStatus } = post;

let label = 'More';
if (savePostStatus.loading) {
label = isSaved ? 'Un-saving...' : 'Saving...';
}
if (savePostStatus.success) {
label = <TimedMessage message={isSaved ? 'Saved!' : 'Un-saved!'}>More</TimedMessage>;
}
if (savePostStatus.error) {
label = <TimedMessage message="Error!">More</TimedMessage>;
}

useEffect(() => {
if (fixedMenu && opened) {
// Fix scroll position
Expand All @@ -71,7 +57,7 @@ export default function PostMoreLink({ post, user, ...props }) {
aria-haspopup
aria-expanded={opened}
>
<MoreWithTriangle>{label}</MoreWithTriangle>
<MoreWithTriangle>More</MoreWithTriangle>
</ButtonLink>
{opened && (
<Portal>
Expand Down
38 changes: 2 additions & 36 deletions src/components/post/post-more-menu.jsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
import { forwardRef, useLayoutEffect, useState, useMemo, useCallback } from 'react';
import { Link } from 'react-router';
import cn from 'classnames';
import {
faExclamationTriangle,
faLink,
faEdit,
faBookmark as faBookmarkSolid,
faSignOutAlt,
faAt,
} from '@fortawesome/free-solid-svg-icons';
import {
faClock,
faCommentDots,
faTrashAlt,
faBookmark,
} from '@fortawesome/free-regular-svg-icons';
import { faLink, faEdit, faSignOutAlt, faAt } from '@fortawesome/free-solid-svg-icons';
import { faClock, faCommentDots, faTrashAlt } from '@fortawesome/free-regular-svg-icons';
import { noop } from 'lodash-es';
import { useDispatch } from 'react-redux';

import { copyURL } from '../../utils/copy-url';
import { leaveDirect } from '../../redux/action-creators';
import { ButtonLink } from '../button-link';
import { Throbber } from '../throbber';
import { Icon } from '../fontawesome-icons';
import TimeDisplay from '../time-display';

import styles from '../dropdown-menu.module.scss';
Expand All @@ -45,8 +31,6 @@ export const PostMoreMenu = forwardRef(function PostMoreMenu(
commentsDisabled = false,
createdAt,
updatedAt,
isSaved = false,
savePostStatus = {},
createdBy: postCreatedBy,
isDirect = false,
},
Expand All @@ -58,7 +42,6 @@ export const PostMoreMenu = forwardRef(function PostMoreMenu(
doAndClose,
doAndForceClose,
permalink,
toggleSave,
fixed = false,
doMention,
},
Expand Down Expand Up @@ -139,23 +122,6 @@ export const PostMoreMenu = forwardRef(function PostMoreMenu(
</div>
)),
[
amIAuthenticated && (
<div className={styles.item} key="save-post">
<ButtonLink className={styles.link} onClick={doAndClose(toggleSave)}>
<Iconic icon={isSaved ? faBookmarkSolid : faBookmark}>
{isSaved ? 'Un-save' : 'Save'} post
{savePostStatus.loading && <Throbber />}
{savePostStatus.error && (
<Icon
icon={faExclamationTriangle}
className="post-like-fail"
title={savePostStatus.errorText}
/>
)}
</Iconic>
</ButtonLink>
</div>
),
<MenuItemNotifyOfAllComments
key="notify-of-all-comments"
postId={postId}
Expand Down
18 changes: 18 additions & 0 deletions src/components/post/post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@
return { role, postLabel };
};

renderPostActions() {

Check warning on line 231 in src/components/post/post.jsx

View workflow job for this annotation

GitHub Actions / build (18)

Method 'renderPostActions' has a complexity of 21. Maximum allowed is 20

Check warning on line 231 in src/components/post/post.jsx

View workflow job for this annotation

GitHub Actions / build (20)

Method 'renderPostActions' has a complexity of 21. Maximum allowed is 20

Check warning on line 231 in src/components/post/post.jsx

View workflow job for this annotation

GitHub Actions / build (21)

Method 'renderPostActions' has a complexity of 21. Maximum allowed is 20
const { props } = this;

const canonicalPostURI = canonicalURI(props);
Expand Down Expand Up @@ -259,6 +259,23 @@
false
);

const { isSaved, savePostStatus } = this.props;
const saveLink = amIAuthenticated && (
<>
<a className="post-action" onClick={this.toggleSave} role="button">
{isSaved ? 'Un-save' : 'Save'}
</a>
{savePostStatus.loading && <Throbber />}
{savePostStatus.error && (
<Icon
icon={faExclamationTriangle}
className="post-like-fail"
title={savePostStatus.errorText}
/>
)}
</>
);

// "More" menu
const moreLink = (
<PostMoreLink
Expand Down Expand Up @@ -334,6 +351,7 @@
<span className="post-footer-block" role="region">
<span className="post-footer-item">{commentLink}</span>
<span className="post-footer-item">{likeLink}</span>
<span className="post-footer-item">{saveLink}</span>
{props.hideEnabled && (
<span className="post-footer-item" ref={this.hideLink}>
{this.renderHideLink()}
Expand Down
1 change: 1 addition & 0 deletions src/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference types="vite-plugin-pwa/react" />
4 changes: 4 additions & 0 deletions styles/shared/post.scss
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,10 @@ $post-line-height: rem(20px);
margin-left: -1em;
margin-right: 1em;
max-width: 100%;

@media (max-width: 500px) {
display: block;
}
}

.post-footer-item {
Expand Down
75 changes: 0 additions & 75 deletions test/jest/__snapshots__/post-more-menu.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -146,31 +146,6 @@ exports[`PostMoreMenu > Renders a More menu for a group moderator 1`] = `
<div
class="group"
>
<div
class="item"
>
<a
aria-disabled="false"
class="link"
role="button"
tabindex="0"
>
<span
class="iconic"
>
<span
class="iconicIcon"
>
fontawesome icon bookmark
</span>
<span
class="iconicContent"
>
Save post
</span>
</span>
</a>
</div>
<div
class="item"
>
Expand Down Expand Up @@ -322,31 +297,6 @@ exports[`PostMoreMenu > Renders a More menu for a logged-in reader 1`] = `
<div
class="group"
>
<div
class="item"
>
<a
aria-disabled="false"
class="link"
role="button"
tabindex="0"
>
<span
class="iconic"
>
<span
class="iconicIcon"
>
fontawesome icon bookmark
</span>
<span
class="iconicContent"
>
Save post
</span>
</span>
</a>
</div>
<div
class="item"
>
Expand Down Expand Up @@ -674,31 +624,6 @@ exports[`PostMoreMenu > Renders a More menu for a post owner 1`] = `
<div
class="group"
>
<div
class="item"
>
<a
aria-disabled="false"
class="link"
role="button"
tabindex="0"
>
<span
class="iconic"
>
<span
class="iconicIcon"
>
fontawesome icon bookmark
</span>
<span
class="iconicContent"
>
Save post
</span>
</span>
</a>
</div>
<div
class="item"
>
Expand Down
Loading