-
Notifications
You must be signed in to change notification settings - Fork 173
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
[Rebase] Warn users on possible risks on installing third party unvetted plugins #676
Open
RodoMa92
wants to merge
3
commits into
SteamDeckHomebrew:main
Choose a base branch
from
RodoMa92:warn_third_party_main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import { ConfirmModal } from '@decky/ui'; | ||
import { FC, useEffect, useState } from 'react'; | ||
import { FaExclamationTriangle } from 'react-icons/fa'; | ||
|
||
import { WarnThirdPartyType } from '../../utils/globalTypes'; | ||
import TranslationHelper, { TranslationClass } from '../../utils/TranslationHelper'; | ||
|
||
interface WarnThirdPartyProps { | ||
seconds?: number; | ||
type: WarnThirdPartyType; | ||
onOK(): void; | ||
onCancel(): void; | ||
closeModal?(): void; | ||
} | ||
|
||
const WarnThirdParty: FC<WarnThirdPartyProps> = ({ seconds = 5, type, onOK, onCancel, closeModal }) => { | ||
const [waitTimer, setWaitTimer] = useState(seconds); | ||
|
||
useEffect(() => { | ||
// exit early when we reach 0 | ||
if (waitTimer <= 0) return; | ||
|
||
// save intervalId to clear the interval when the | ||
// component re-renders | ||
const intervalId = setInterval(() => { | ||
setWaitTimer(waitTimer - 1); | ||
}, 1000); | ||
|
||
// clear interval on re-render to avoid memory leaks | ||
return () => clearInterval(intervalId); | ||
// add waitTimer as a dependency to re-rerun the effect | ||
// when we update it | ||
}, [waitTimer]); | ||
|
||
return ( | ||
<ConfirmModal | ||
bOKDisabled={waitTimer > 0} | ||
closeModal={closeModal} | ||
onOK={async () => { | ||
await onOK(); | ||
}} | ||
onCancel={async () => { | ||
await onCancel(); | ||
}} | ||
strTitle={ | ||
<div> | ||
<FaExclamationTriangle /> | ||
<TranslationHelper transClass={TranslationClass.WARN_THIRD_PARTY} transText="title" warnType={type} /> | ||
</div> | ||
} | ||
strOKButtonText={ | ||
waitTimer > 0 ? ( | ||
<div> | ||
<TranslationHelper | ||
transClass={TranslationClass.WARN_THIRD_PARTY} | ||
transText="button_processing" | ||
i18nArgs={{ | ||
timer: waitTimer, | ||
}} | ||
/> | ||
</div> | ||
) : ( | ||
<div> | ||
<TranslationHelper transClass={TranslationClass.WARN_THIRD_PARTY} transText="button_idle" /> | ||
</div> | ||
) | ||
} | ||
> | ||
<span style={{ color: 'red' }}> | ||
<div> | ||
<TranslationHelper transClass={TranslationClass.WARN_THIRD_PARTY} transText="desc" warnType={type} /> | ||
</div> | ||
</span> | ||
</ConfirmModal> | ||
); | ||
}; | ||
|
||
export default WarnThirdParty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export enum WarnThirdPartyType { | ||
REPO = 0, | ||
ZIP = 1, | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't set timeout work better for this then? Unless I'm misunderstanding?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, fair enough. Not really that skilled with react.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AAGaming00 current solution isn't ideal but should it be changed or can this PR go ahead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rereading this now, no, because I'm referencing the timeout on the translation on line 58 to show the remaining time ticking down to give additional feedback to the user, so I can't see how I would be doing this with one single timeout tick compared to one for each second. It was like 6 months from when I wrote this, so I was not that sure why I did stuff at the time, sorry XD. Let me know if I'm missing something.