Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

Commit

Permalink
Pre-fill the URL of the current tab into the doorhanger's filter
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Porter committed Mar 7, 2018
1 parent cacc134 commit 021f587
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/webextension/list/popup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import thunk from "redux-thunk";

import AppLocalizationProvider from "../../l10n";
import App from "./components/app";
import { listItems } from "../actions";
import { filterItems, listItems } from "../actions";
import reducer from "./reducers";
import initializeMessagePorts from "../message-ports";
import * as telemetry from "../../telemetry";
Expand All @@ -19,6 +19,17 @@ import telemetryLogger from "./telemetry";
const store = createStore(reducer, undefined, applyMiddleware(
thunk, telemetryLogger
));

// Pre-fill the URL of the current tab.
// XXX: Eventually, we'll probably want to put this in another file.
browser.tabs.query({ active: true, currentWindow: true }).then((result) => {
const validProtocols = ["http:", "https:"];
const url = new URL(result[0].url);
if (validProtocols.includes(url.protocol)) {
store.dispatch(filterItems(url.hostname));
}
});

store.dispatch(listItems());
initializeMessagePorts(store);

Expand Down

0 comments on commit 021f587

Please sign in to comment.