-
Notifications
You must be signed in to change notification settings - Fork 471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added the ability to see connectors that have been downloaded #1456
Changes from 1 commit
753a1c0
0a3a657
e199668
cf345bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ export default class Connectors { | |
constructor(ipc) { | ||
ipc.listen('on-connector-protocol-handler', this._onConnectorProtocolHandler.bind(this)); | ||
this._list = []; | ||
this._favList = []; | ||
this._favlist = []; | ||
} | ||
|
||
async _loadPlugins(uri) { | ||
|
@@ -25,20 +25,20 @@ export default class Connectors { | |
]; | ||
let userPlugins = await this._loadPlugins('hakuneko://plugins/'); | ||
let internalPlugins = await this._loadPlugins('hakuneko://cache/mjs/connectors/'); | ||
let favoritePlugins = Storage.downloadedConnectors; | ||
let favoritePlugins = Engine.Storage.downloadedConnectors; | ||
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. Not needed anymore if you accept the suggested change based on |
||
|
||
await this.register(systemPlugins); | ||
await this.register(userPlugins); | ||
await this.register(internalPlugins); | ||
await this.register(favoritePlugins); | ||
await this.registerfav(favoritePlugins); | ||
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. Not needed anymore if you accept the suggested change based on |
||
} | ||
|
||
get list() { | ||
return this._list; | ||
} | ||
|
||
get favoriteList() { | ||
return this._favList; | ||
get favlist() { | ||
return this._favlist; | ||
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. Just get the connector IDs of downloaded lists as suggested in let downloaded = Storage.getDownloadedConnectorIDs();
return this._list.filter(connector => downloaded.includes(connector.id)); |
||
} | ||
|
||
async register(files) { | ||
|
@@ -63,7 +63,30 @@ export default class Connectors { | |
console.warn(`Failed to load connector`, error); | ||
} | ||
} | ||
|
||
|
||
async registerfav(files) { | ||
try { | ||
for(let file of files) { | ||
try { | ||
let module = await import(file); | ||
let connector = new module.default(); | ||
if(this._favlist.find(c => c.id === connector.id)) { | ||
console.warn(`The connector "${connector.label}" with ID "${connector.id}" is already registered`); | ||
} else { | ||
this._favlist.push(connector); | ||
} | ||
} catch(error) { | ||
console.warn(`Failed to load connector "${file}"`, error); | ||
} | ||
} | ||
this._favlist.sort( ( a, b ) => { | ||
return ( a.label.toLowerCase() < b.label.toLowerCase() ? -1 : 1 ); | ||
} ); | ||
} catch(error) { | ||
console.warn(`Failed to load connector`, error); | ||
} | ||
} | ||
|
||
Comment on lines
+67
to
+89
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. only part I'm not happy with, since original 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. Method is not needed anymore if you accept the suggested change based on |
||
async _onConnectorProtocolHandler(request) { | ||
try { | ||
let uri = new URL(request.url); | ||
|
This file was deleted.
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.
Not needed anymore if you accept the suggested change based on
Storage.mjs