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

Make Cmd left/right go back/forward #6466

Merged

Conversation

PikachuEXE
Copy link
Collaborator

@PikachuEXE PikachuEXE commented Dec 28, 2024

Pull Request Type

  • Bugfix
  • Feature Implementation
  • Documentation
  • Other

Related issue

Closes #5966

Description

For MacOS only, make Cmd left/right as an additional keyboard shortcut to go back/forward in history

Screenshots

image
image

Old, outdated
image

Testing

  • Ensure existing back/forward shortcuts working (All OS) (Alt Left/Right)
  • Ensure new back/forward shortcuts working (macOS only) (Cmd Left/Right)
  • Ensure tooltip on back/forward buttons unchanged (non macOS only)
  • Ensure tooltip on back/forward buttons updated (macOS only)
  • Open keyboard modal, ensure shortcuts unchanged (non macOS only)
  • Open keyboard modal, ensure shortcut list updated (MacOS only)

Desktop

  • OS: macOS
  • OS Version:
  • FreeTube version:

Additional context

@FreeTubeBot FreeTubeBot enabled auto-merge (squash) December 28, 2024 02:01
@github-actions github-actions bot added the PR: waiting for review For PRs that are complete, tested, and ready for review label Dec 28, 2024
unlocalizedShortcuts = [unlocalizedShortcuts]
}
const localizedShortcuts = unlocalizedShortcuts.map((s) => getLocalizedShortcut(s))
return addKeyboardShortcutToActionTitle(localizedActionTitle, localizedShortcuts.join('/'))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (blocking): I think we should localize this like we do here for the plus sign. This is the best quick source I could find, but I think it's apparent enough that some languages do this differently:

American English frequently uses the slash symbol to represent the idea of “or” or “and.” To minimize ambiguity in your source English text for translation, it is recommendable to actually use the words “or” or “and.”

    const shortcutJoinOperator = i18n.t('shortcutJoinOperator')
    return localizedShortcuts.join(shortcutJoinOperator)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines 118 to 125
...(
isMac
? [
['HISTORY_BACKWARD_ALT_MAC', t('KeyboardShortcutPrompt.History Backward (Mac only)')],
['HISTORY_FORWARD_ALT_MAC', t('KeyboardShortcutPrompt.History Forward (Mac only)')],
]
: []
),
Copy link
Collaborator

@kommunarr kommunarr Dec 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (non-blocking): I'm curious if showing a non-monospace slash character joining the different alts would be more elegant than separate entries for alts. I was thinking about storing alts by storing the shortcut constant as A|B, which is then parsed into A<span>/</span>B, where we can then apply a separate styling rule (no monospace) to the nested spans. But that would need some special logic in the caller as well for Mac-only additional shortcut cases like this one, or a separate character for representing non-Mac and Mac-exclusive shortcut alts (e.g., ┛A|┗B|C|D for Windows/Mac-specific alt A, Mac-specific alt B, and universal alts C and D).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way too complicated to understand
Left for another PR at least -_-

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good - this will currently be the only action with two displayed shortcuts we have in the modal (I excluded the dupe alt shortcuts in the original PR), so I suggest we move to a more elegant solution when we want to add more of them

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this extra shortcut is only displayed to MacOS users, do we really need to specify in the text that it is macOS only? It also uses the command key which doesn't exist on Windows or Linux, so it seems unlikely that someone would try to use it on Windows or Linux anyway if they happen to use macOS + Windows or Linux.

Copy link
Collaborator Author

@PikachuEXE PikachuEXE Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The best way is to have 1 action to N shortcut(s)
Not sure how to do that yet...
Let me take a look ~_~

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't you just have two mappings that use the same title, the Map uses the shortcuts as the key, so it should work? That way it'll still be displayed as two separate lines/rows but with different shortcuts.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated
image

Also in PR description

@efb4f5ff-1298-471a-8973-3d47447115dc efb4f5ff-1298-471a-8973-3d47447115dc added PR: changes requested and removed PR: waiting for review For PRs that are complete, tested, and ready for review labels Dec 28, 2024
@absidue
Copy link
Member

absidue commented Dec 28, 2024

This pull request doesn't actually close the linked issue, this adds Command+Arrow Left and Command+Arrow Right but the feature request is asking for Cmd+[ and Cmd+].

Would you prefer to unlink the issue so that it stays open for someone else to implement in the future or change the code to use the keyboard shortcuts that that person asked for?

Edit: According to the Apple Support link that was provided in the issue:

Command–Left Bracket ([): Go to the previous folder.
Command–Right Bracket (]): Go to the next folder.

@PikachuEXE
Copy link
Collaborator Author

@absidue Yup my Vivaldi uses Cmd+arrow key so I got it wrong. Fixed now

kommunarr
kommunarr previously approved these changes Dec 29, 2024
@PikachuEXE PikachuEXE added PR: waiting for review For PRs that are complete, tested, and ready for review and removed PR: changes requested labels Jan 2, 2025
Copy link
Member

@absidue absidue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would hardcoding a wider separator be an option, just the slash without any whitespace makes it difficult to easily tell that they are two separate shortcuts.

Comment on lines 1150 to 1151
History Backward (Mac only): Go back one page (Mac only)
History Forward (Mac only): Go forward one page (Mac only)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As these new strings are no longer used please remove them.

Copy link
Member

@absidue absidue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As we now just use it as a list and don't actually use it for the look ups, we can just return an array of arrays.

@@ -110,56 +110,60 @@ const primarySections = computed(() => [

const isMac = process.platform === 'darwin'

const localizedShortcutNameDictionary = computed(() => {
const localizedShortcutNameToShortcutsMap = computed(() => {
return new Map([
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return new Map([
return [

[t('KeyboardShortcutPrompt.Last Chapter'), ['LAST_CHAPTER']],
[t('KeyboardShortcutPrompt.Next Chapter'), ['NEXT_CHAPTER']],
[t('KeyboardShortcutPrompt.Last Frame'), ['LAST_FRAME']],
[t('KeyboardShortcutPrompt.Next Frame'), ['NEXT_FRAME']],
])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
])
]

const shortcutNameToShortcutsMap = localizedShortcutNameToShortcutsMap.value
const shortcutLabelSeparator = t('shortcutLabelSeparator')

return shortcutNameToShortcutsMap.entries()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return shortcutNameToShortcutsMap.entries()
return shortcutNameToShortcutsMap

@PikachuEXE
Copy link
Collaborator Author

If using /
image
image

If using (https://www.amp-what.com/unicode/search/vertical%20line
image
image

Going for later assuming that's good enough

Copy link
Member

@absidue absidue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a mac so I wasn't able to test this properly but the code looks like it should work and the keyboard shortcuts prompt seems to work the same as it did before on Windows.

@PikachuEXE PikachuEXE requested a review from kommunarr January 15, 2025 00:11
@FreeTubeBot FreeTubeBot merged commit e8d2624 into FreeTubeApp:development Jan 19, 2025
5 checks passed
@github-actions github-actions bot removed the PR: waiting for review For PRs that are complete, tested, and ready for review label Jan 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request]: Add more macOS back and forward keyboard shortcuts
5 participants