A fork of https://github.com/ueokande/vim-vixen
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
1.0 KiB
35 lines
1.0 KiB
import { injectable } from 'tsyringe'; |
|
import AddonEnabledUseCase from '../usecases/AddonEnabledUseCase'; |
|
import SettingUseCase from '../usecases/SettingUseCase'; |
|
import * as messages from '../../shared/messages'; |
|
|
|
@injectable() |
|
export default class SettingController { |
|
|
|
constructor( |
|
private addonEnabledUseCase: AddonEnabledUseCase, |
|
private settingUseCase: SettingUseCase, |
|
) { |
|
} |
|
|
|
async initSettings(): Promise<void> { |
|
try { |
|
let current = await this.settingUseCase.reload(); |
|
let url = new URL(window.location.href); |
|
let disabled = current.blacklist.includesEntireBlacklist(url); |
|
if (disabled) { |
|
this.addonEnabledUseCase.disable(); |
|
} else { |
|
this.addonEnabledUseCase.enable(); |
|
} |
|
} catch (e) { |
|
// Sometime sendMessage fails when background script is not ready. |
|
console.warn(e); |
|
setTimeout(() => this.initSettings(), 500); |
|
} |
|
} |
|
|
|
async reloadSettings(_message: messages.Message): Promise<void> { |
|
await this.settingUseCase.reload(); |
|
} |
|
}
|
|
|