Permalink
Browse files

fix active/inactive detect for Franz 5.0.0 bata 18

Franz 5.0.0 bata 18 でのサービスのアクティブ/非アクティブの検出処理を修正
  • Loading branch information...
sharkpp committed Aug 25, 2018
1 parent 8414086 commit e6e3db9ab3e04aa9f35cdac59b01bba145ae3029
Showing with 44 additions and 12 deletions.
  1. +28 −4 index.js
  2. +16 −8 webview.js
@@ -1,12 +1,36 @@
//'use strict';

module.exports = Franz => class Mastodon extends Franz {

constructor(...args) {
let _temp;
return _temp = super(...args), this.events =
{}
, _temp;
//
let serviceCache = {};
// send service store for webview
setInterval(() => {
if (!window.franz) { // not present(near equal not initialize)
return;
}
const services = window.franz.stores.services;
// filter this recipe class
const instancedServices = services.all.filter(service => service.recipe.constructor === this.constructor);
// send
instancedServices.forEach(service => {
let updated = false;
serviceCache[service.id] = Object.keys(service).reduce((r, key) => {
if (!service[key] || Object !== service[key].constructor) {
updated = updated || serviceCache[key] !== service[key];
r[key] = service[key];
}
return r;
}, serviceCache[service.id] || {});
if (updated) {
service.webview.send('-service-update', service);
}
});
}, 1000);
return _temp = super(...args), this.events = {
}, _temp;
}

async validateUrl(url) {
@@ -12,23 +12,31 @@ if (!Notification.prototype.addEventListener) {
Notification.prototype.addEventListener = function(){};
}

module.exports = (Franz, data) => {
module.exports = (Franz, service_) => {

let service = service_;

// save service instance identify
const serviceId = data.id;
const serviceId = service.id;

// check if this service is active
let activeUpdated = false;
let isActive = true;
let isActive = service.isActive;

ipcRenderer.on('settings-update', (sender, settings) => {
const nextIsActive = serviceId == settings.activeService;
!activeUpdated && (activeUpdated = isActive != nextIsActive);
isActive = nextIsActive;
ipcRenderer.on('-service-update', (sender, serviceNew) => {
service = serviceNew;
!activeUpdated && (activeUpdated = isActive != service.isActive);
isActive = service.isActive;
});

//ipcRenderer.on('settings-update', (sender, settings) => {
// const nextIsActive = serviceId == settings.activeService;
// !activeUpdated && (activeUpdated = isActive != nextIsActive);
// isActive = nextIsActive;
//});

let replyCount = 0;
let limitBadgeClear;
let limitBadgeClear = false;

const getMessages = function getMessages() {
const activeUpdated_ = activeUpdated; activeUpdated = false;

0 comments on commit e6e3db9

Please sign in to comment.