Skip to content
This repository was archived by the owner on Feb 26, 2021. It is now read-only.

Fixes #1484 Create pageName type#1813

Open
Simpcyclassy wants to merge 10 commits into
mozilla-extensions:masterfrom
Simpcyclassy:pageName-type
Open

Fixes #1484 Create pageName type#1813
Simpcyclassy wants to merge 10 commits into
mozilla-extensions:masterfrom
Simpcyclassy:pageName-type

Conversation

@Simpcyclassy
Copy link
Copy Markdown
Collaborator

No description provided.

@Simpcyclassy Simpcyclassy marked this pull request as ready for review July 21, 2020 11:09
@Simpcyclassy Simpcyclassy linked an issue Jul 23, 2020 that may be closed by this pull request
Comment thread extension/background/entityTypes.js Outdated
Comment on lines +26 to +32
for (const id in metadata.pageNames) {
const item = metadata.pageNames[id];
for (const name of item.names) {
namedPages.push(name);
}
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I understand I need to create a new Alternative here can I get a bit more clarity on that @ianb

return pageNames;
}

export async function registerPageName(name, { url }) {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I assume this is the function where I am to save the pageNames to the entityTypes, it's not clear to me how the services communicate

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this should call a new function in entityTypes.js

name: namedPages,
lang: languageNames(),
smallNumber: English.numberNames,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

convertEntities does its own thing. It might actually be OK, but then if you look at entityTypes.name (it would be better to call it .pageName) you'll see it is an instance of Alternatives.

A good approach here is to use things like console.log(entityTypes.name) to see what's what.

But to add a new thing to the entity you'd do something like:

export function addPageName(name) {
  entityTypes.pageNames.alternatives.push(makeWordMatcher(name));
}

(Note makeWordMatcher isn't exported at the moment, but could be)

return pageNames;
}

export async function registerPageName(name, { url }) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this should call a new function in entityTypes.js

const query = context.slots.query.toLowerCase();
const result = await browser.storage.sync.get("pageNames");
const pageNames = result.pageNames;
const name = context.slots.name.toLowerCase();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't think these changes to navigation.js are necessary or related to the rest of the changes

Comment thread extension/background/intentRunner.js Outdated
const creationDate = Date.now();
const result = await browser.storage.sync.get("pageNames");
pageNames = result.pageNames || {};
pageNames = getRegisteredPageName() || {};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We probably won't need this any longer. Instead we can create a new intent that just matches the phrase:

[name:pageName]

And the new intent should look up and open the page.

Comment thread extension/background/intentRunner.js Outdated
const creationDate = Date.now();
const result = await browser.storage.sync.get("pageNames");
pageNames = result.pageNames || {};
const pageNames = getRegisteredPageName() || {};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Missing await?

Comment thread extension/background/intentRunner.js Outdated
@Simpcyclassy Simpcyclassy requested a review from ianb August 6, 2020 13:04
Comment thread extension/background/intentRunner.js Outdated
Comment thread extension/intents/routines/routines.js Outdated
async run(context) {
const name = context.slots.name;
await intentRunner.getRegisteredPageName(name);
const pageNames = await intentRunner.getRegisteredPageName(name);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Here getRegisteredPageName() is used with an argument, but the function as defined doesn't take any arguments.

Really there's a confusion here, as getRegisteredPageName() is also used elsewhere without an argument (in registerPageName()). But in that case it's being used incorrectly.

Be sure when you are changing a function that you look for everywhere where the function is used, to make sure you are changing it in a way that's compatible with how it's being used.

@andrenatal andrenatal force-pushed the master branch 3 times, most recently from 7ad02c2 to 0ec2a05 Compare January 29, 2021 01:57
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create pageName type

2 participants