Skip to content

Commit

Permalink
MPRIS Component: inline org.freedesktop.DBus.ListNames call
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Mar 9, 2020
1 parent e42d49f commit f994b8b
Showing 1 changed file with 16 additions and 22 deletions.
38 changes: 16 additions & 22 deletions src/service/components/mpris.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,22 @@ var Manager = GObject.registerClass({
});
});

// Add the current players
let names = await this._listNames();
let names = await new Promise((resolve, reject) => {
this.call(
'org.freedesktop.DBus.ListNames',
null,
Gio.DBusCallFlags.NO_AUTO_START,
-1,
this._cancellable,
(proxy, res) => {
try {
resolve(proxy.call_finish(res).deepUnpack()[0]);
} catch (e) {
reject(e);
}
}
);
});

for (let i = 0, len = names.length; i < len; i++) {
let name = names[i];
Expand Down Expand Up @@ -658,26 +672,6 @@ var Manager = GObject.registerClass({
}
}

_listNames() {
return new Promise((resolve, reject) => {
this.call(
'org.freedesktop.DBus.ListNames',
null,
Gio.DBusCallFlags.NONE,
-1,
null,
(proxy, res) => {
try {
let reply = proxy.call_finish(res);
resolve(reply.deepUnpack()[0]);
} catch (e) {
reject(e);
}
}
);
});
}

async _addPlayer(name) {
try {
if (!this.players.has(name)) {
Expand Down

0 comments on commit f994b8b

Please sign in to comment.