Skip to content
This repository has been archived by the owner on May 9, 2024. It is now read-only.

chore: logging #1

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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 packages/emoji-mart/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@campsite-software/emoji-mart",
"version": "5.6.0",
"version": "5.6.1-reactive-store.11",
"description": "Emoji picker for the web",
"license": "MIT",
"homepage": "https://github.com/campsite/emoji-mart",
Expand Down
2 changes: 2 additions & 0 deletions packages/emoji-mart/src/components/Picker/Picker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export default class Picker extends Component {
const nextState = this.getInitialState()

if (requiresGridReset) {
console.log('picker requires grid reset')
return this.reset(nextState)
}

Expand All @@ -109,6 +110,7 @@ export default class Picker extends Component {
}

async reset(nextState = {}) {
console.log('picker reset init')
await init(this.props)

this.initGrid()
Expand Down
2 changes: 2 additions & 0 deletions packages/emoji-mart/src/components/Picker/PickerElement.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ export default class PickerElement extends ShadowElement {
this.component = component
}

console.log('picker connected callback', props)

await init(props)
if (this.disconnected) return

Expand Down
22 changes: 19 additions & 3 deletions packages/emoji-mart/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ export function init(options, { caller } = {}) {
}

async function _init(props) {
console.log('init', Data, props)
initialized = true

// console.log('init reset data')
// Data = null

let { emojiVersion, set, locale } = props
emojiVersion || (emojiVersion = PickerProps.emojiVersion.value)
set || (set = PickerProps.set.value)
Expand Down Expand Up @@ -80,8 +84,10 @@ async function _init(props) {

Data.originalCategories = Data.categories
} else {
console.log('init else', Data.originalCategories)
Data.categories = Data.categories.filter((c) => {
const isCustom = !!c.name
console.log('init categories filtering', { c, isCustom })
if (!isCustom) return true

return false
Expand Down Expand Up @@ -111,6 +117,7 @@ async function _init(props) {
category.target = prevCategory.target || prevCategory
}

console.log('init push category', { category })
Data.categories.push(category)

for (const emoji of category.emojis) {
Expand All @@ -120,6 +127,10 @@ async function _init(props) {
}

if (props.categories) {
console.log('init override categories', {
categories: Data.categories,
originalCategories: Data.originalCategories,
})
Data.categories = Data.originalCategories
.filter((c) => {
return props.categories.indexOf(c.id) != -1
Expand Down Expand Up @@ -248,9 +259,10 @@ async function _init(props) {
}
}

if (resetSearchIndex) {
SearchIndex.reset()
}
// if (resetSearchIndex) {
console.log('init reset search index')
SearchIndex.reset()
// }

initCallback()
}
Expand All @@ -263,6 +275,8 @@ export function getProps(props, defaultProps, element) {
_props[k] = getProp(k, props, defaultProps, element)
}

console.log('new props', { _props })

return _props
}

Expand All @@ -274,6 +288,8 @@ export function getProp(propName, props, defaultProps, element) {
? props[propName]
: null)

console.log('getProp', { propName, props, defaultProps, value, defaults })

if (!defaults) {
return value
}
Expand Down
3 changes: 2 additions & 1 deletion packages/emoji-mart/src/helpers/search-index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ async function search(value, { maxResults, caller } = {}) {

if (!values.length) return

let pool = Pool || (Pool = Object.values(Data.emojis))
// let pool = Pool || (Pool = Object.values(Data.emojis))
let pool = Object.values(Data.emojis)
let results, scores

for (const value of values) {
Expand Down