-
-
Notifications
You must be signed in to change notification settings - Fork 351
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
Convert vuex/keycodes store to pinia #1370
Conversation
- partial - values - no need to spread default exports
- replace all uses of vuex keycodes store with pinia - fix ergo keyboard menu
@precondition if you get a chance, a quick review or running it locally to spot if I broke anything would be appreciated. Thanks |
Some properties for typedefs are actually optional. Use the correct jsdoc syntax.
@@ -1,12 +1,14 @@ | |||
import Vue from 'vue'; | |||
import random from 'lodash/random'; |
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.
remove a lot of dependencies on lodash, as a lot of this stuff is built in now
I added some jsdoc for some of the hairy parts, and documented some of the internal types used inside the keycode JSON. |
Oh shoot, I planned to take a look at this later today. |
No worries. Any feedback you have is appreciated. Please check I didn't break anything on the deployed code. Thank you! |
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.
I pointed out a few typos but I did not notice any regressions. However, during testing, I did uncover a pre-existing bug in the match count feature.
} | ||
|
||
/** | ||
* Used to dynamically generate the tab data for they keycode |
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.
* Used to dynamically generate the tab data for they keycode | |
* Used to dynamically generate the tab data for the keycode |
* | ||
* @param {string} osKeyboardLayout | ||
* @param {boolean} isSteno | ||
* @returns {Array.<KeycodeDefinition|KeycodeLabel|WidthPlaceholder} |
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.
* @returns {Array.<KeycodeDefinition|KeycodeLabel|WidthPlaceholder} | |
* @returns {Array.<KeycodeDefinition|KeycodeLabel|WidthPlaceholder>} |
setSearchFilter(newVal) { | ||
this.searchFilter = newVal; | ||
if (this.searchFilter !== '') { | ||
this.searchCounters = { | ||
ANSI: countMatches(this.searchFilter, ansi), | ||
'ISO/JIS': countMatches(this.searchFilter, iso_jis), | ||
Quantum: countMatches(this.searchFilter, quantum), | ||
KeyboardSettings: countMatches(this.searchFilter, settings), | ||
AppMediaMouse: countMatches(this.searchFilter, media) | ||
}; | ||
} | ||
} |
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.
This is a pre-existing issue but the collections passed to countMatches
(ansi
, iso_jis
, etc.) are read-only variables imported from ./modules/keycodes/###
. Consequently, these keycode collections are not localized at all causing incorrect match counts to be reported.
For example, if I search for "ß" with the German OS layout, the ß
key will be highlighted but the count in both ANSI and ISO tabs will be "(0)". Same story if I search for "Y" with the German OS layout; DE_Y and KC_Y (=DE_Z) are both highlighted but the ANSI tab will only report a single match because it successfully finds a "Y" in the uppercase version of KC_Y
's name
but KC_Z
aka DE_Y
has "Z" as its name
in the ansi
variable so the countMatches
does not count it.
The solution would be to map the toLocalKeycode
on each collection before passing it to the countMatches
. I'll open a separate issue and open a PR for a possible implementation.
EDIT: See issue #1372
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.
Good catch.
* @typedef {Object} WidthPlaceholder - used for spacing | ||
* @property {number} width - width in Key Units * 1000. e.g. 1U = 1000, 2U = 2000. | ||
*/ | ||
|
||
/** | ||
* @typedef {Object} KeycodeDefinition - metadata about a keycode | ||
* @property {string} name - UI display label for the keycode | ||
* @property {string} code - QMK keycode defintion | ||
* @property {string} [keys] - javascript keypress id. Used by keyboard handler | ||
* @property {number} [width] - width in Key Units * 1000. e.g. 1U = 1000, 2U = 2000. |
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.
* @typedef {Object} WidthPlaceholder - used for spacing | |
* @property {number} width - width in Key Units * 1000. e.g. 1U = 1000, 2U = 2000. | |
*/ | |
/** | |
* @typedef {Object} KeycodeDefinition - metadata about a keycode | |
* @property {string} name - UI display label for the keycode | |
* @property {string} code - QMK keycode defintion | |
* @property {string} [keys] - javascript keypress id. Used by keyboard handler | |
* @property {number} [width] - width in Key Units * 1000. e.g. 1U = 1000, 2U = 2000. | |
* @typedef {Object} WidthPlaceholder - used for spacing | |
* @property {number} width - width in Key Units * 1000. e.g. 1U = 1000, 2U = 2000 | |
*/ | |
/** | |
* @typedef {Object} KeycodeDefinition - metadata about a keycode | |
* @property {string} name - UI display label for the keycode | |
* @property {string} code - QMK keycode definition | |
* @property {string} [keys] - javascript keypress id. Used by keyboard handler | |
* @property {number} [width] - width in Key Units * 1000. e.g. 1U = 1000, 2U = 2000 |
Typo + inconsistent use of trailing period
/** | ||
* @typedef {Object} KeycodeStoreState | ||
* @property {Array.<KeycodeDefinition|KeycodeLabel|WidthPlaceholder>} keycodes - active keycodes | ||
* @property {string} searchFilter - currently search filter |
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.
* @property {string} searchFilter - currently search filter | |
* @property {string} searchFilter - current query in the keycode picker search bar |
this.commit('keycodes/updateKeycodeNames'); | ||
const keycodesStore = useKeycodesStore(); | ||
|
||
// Important to call keycodes/updatekeycodeNames *before* keymap/updateKeycodeNames. |
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.
// Important to call keycodes/updatekeycodeNames *before* keymap/updateKeycodeNames. | |
// Important to call keycodesStore.updateKeycodeNames *before* keymap/updateKeycodeNames. |
Updating the comment to reflect changes to the call signature
Description
This PR replaces all the uses of vuex keycodes store with a pinia equivalent. It also fixes a bug in the steno code I discovered while refactoring, where steno boards were not being identified correctly.
This should be 100% equivalent with no regressions.
Vuex is in deep maintenance mode and pinia is the recommended library for vue. This work is preparation for moving to vue 3 and vue 2 is now EOL.