This repository has been archived by the owner on Apr 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Move rate limit to context menu
- Loading branch information
1 parent
a53a422
commit 30e6a75
Showing
11 changed files
with
105 additions
and
35 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import includes from 'lodash/includes' | ||
|
||
class ContextMenuService { | ||
MENU_RATE_LIMIT = 'rateLimit' | ||
MENU_APPLY_ON_GITHUB_ISSUES = 'applyOnGithubIssues' | ||
|
||
constructor (ctx) { | ||
this.menuIds = [] | ||
} | ||
|
||
upsert (id, options) { | ||
if (!includes(this.menuIds, id)) { | ||
chrome.contextMenus.create({id, ...options}) | ||
this.menuIds.push(id) | ||
} | ||
chrome.contextMenus.update(id, options) | ||
} | ||
} | ||
|
||
export default ContextMenuService |
This file contains 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 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 |
---|---|---|
@@ -1,21 +1,9 @@ | ||
import format from 'date-fns/format' | ||
|
||
import colors from './themes/colors' | ||
|
||
export function log (...args) { | ||
if (process.env.NODE_ENV === 'development') { | ||
const timestamp = format(new Date(), 'YYYY-MM-DDTHH:mm:ssZ') | ||
// eslint-disable-next-line no-console | ||
console.log.apply(null, [`[${timestamp}]`, ...args]) | ||
} | ||
} | ||
|
||
export function updateBadge (maybeText) { | ||
const color = maybeText === null ? colors.red : colors.blue | ||
const text = maybeText === null ? 'N/A' : maybeText | ||
|
||
log('badge updated:', {color, text}) | ||
|
||
chrome.browserAction.setBadgeBackgroundColor({color}) | ||
chrome.browserAction.setBadgeText({text}) | ||
} |
This file contains 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 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 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 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