This repository was archived by the owner on Feb 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
Fixes #1484 Create pageName type #1813
Open
Simpcyclassy
wants to merge
10
commits into
mozilla-extensions:master
Choose a base branch
from
Simpcyclassy:pageName-type
base: master
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
10 commits
Select commit
Hold shift + click to select a range
7e3d85d
added notification for removed page name
Simpcyclassy 8ed8557
add named pages to entity types
Simpcyclassy 6d68ba4
re-add readability spaces
Simpcyclassy a057262
get pageNames from intentRunner
Simpcyclassy 36caf42
export namedPages from entity types
Simpcyclassy c0afcbc
save pageNames to entity types
Simpcyclassy 5cfa4b6
get registered pageName from browser storage
Simpcyclassy 197a0e5
Merge branch 'master' into pageName-type
Simpcyclassy 888bc35
remove pageName import
Simpcyclassy 8330269
getRegisteredPageName does not expect a value
Simpcyclassy 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ import { metadata } from "../intents/metadata.js"; | |
| import { compile, splitPhraseLines } from "../language/compiler.js"; | ||
| import { PhraseSet } from "../language/findMatch.js"; | ||
| import * as settings from "../settings.js"; | ||
| import { entityTypes } from "./entityTypes.js"; | ||
| import { entityTypes, addPageName } from "./entityTypes.js"; | ||
| import * as intentParser from "./intentParser.js"; | ||
| import * as telemetry from "./telemetry.js"; | ||
| import { registerHandler, sendMessage } from "../communicate.js"; | ||
|
|
@@ -548,33 +548,27 @@ export function getRegisteredRoutines() { | |
|
|
||
| registerHandler("getRegisteredRoutines", getRegisteredRoutines); | ||
|
|
||
| let pageNames = {}; | ||
| export async function getRegisteredPageName() { | ||
| const result = await browser.storage.sync.get("pageNames"); | ||
| const pageNames = result.pageNames; | ||
|
|
||
| return pageNames; | ||
| } | ||
|
|
||
| export async function registerPageName(name, { url }) { | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this should call a new function in |
||
| name = name.toLowerCase(); | ||
| const creationDate = Date.now(); | ||
| const result = await browser.storage.sync.get("pageNames"); | ||
| pageNames = result.pageNames || {}; | ||
| const pageNames = (await getRegisteredPageName()) || {}; | ||
|
|
||
| pageNames[name] = url; | ||
|
|
||
| log.info("Added routine for page", name, "->", url, creationDate); | ||
| addPageName(name); | ||
| await browser.storage.sync.set({ pageNames }); | ||
| } | ||
|
|
||
| export async function getRegisteredPageName(name) { | ||
| const result = await browser.storage.sync.get("pageNames"); | ||
| pageNames = result.pageNames; | ||
|
|
||
| if (!pageNames[name] || !name) { | ||
| const exc = new Error("No page name to remove"); | ||
| exc.displayMessage = `The page name "${name}" not found`; | ||
| throw exc; | ||
| } | ||
| return pageNames; | ||
| log.info("Added routine for page", name, "->", url, creationDate); | ||
| } | ||
|
|
||
| export async function unregisterPageName(name) { | ||
| const pageNames = await getRegisteredPageName(); | ||
| delete pageNames[name]; | ||
| log.info("Removed routine for page", name); | ||
| await browser.storage.sync.set({ pageNames }); | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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
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.
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:
(Note makeWordMatcher isn't exported at the moment, but could be)