Skip to content

Commit

Permalink
Add preference to mute call ringtone (#1273)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas Barrena authored Mar 6, 2020
1 parent 4493b08 commit 5daa934
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ type StoreType = {
sidebar: 'default' | 'hidden' | 'narrow' | 'wide';
autoHideMenuBar: boolean;
notificationsMuted: boolean;
callRingtoneMuted: boolean;
hardwareAcceleration: boolean;
quitOnWindowClose: boolean;
keepMeSignedIn: boolean;
Expand Down Expand Up @@ -166,6 +167,10 @@ const schema: {[Key in keyof StoreType]: Store.Schema} = {
type: 'boolean',
default: false
},
callRingtoneMuted: {
type: 'boolean',
default: false
},
hardwareAcceleration: {
type: 'boolean',
default: true
Expand Down
14 changes: 14 additions & 0 deletions source/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,20 @@ function initRequestsFiltering(): void {
callback({cancel: config.get('block.deliveryReceipt' as any)});
}
});

session.defaultSession.webRequest.onHeadersReceived({
urls: ['*://static.xx.fbcdn.net/rsrc.php/*']
}, ({responseHeaders}, callback) => {
if (!config.get('callRingtoneMuted') || !responseHeaders) {
callback({});
return;
}

const callRingtoneHash = '2NAu/QVqg211BbktgY5GkA==';
callback({
cancel: responseHeaders['content-md5'][0] === callRingtoneHash
});
});
}

function setUserLocale(): void {
Expand Down
8 changes: 8 additions & 0 deletions source/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,14 @@ Press Command/Ctrl+R in Caprine to see your changes.
sendAction('toggle-mute-notifications');
}
},
{
label: 'Mute Call Ringtone',
type: 'checkbox',
checked: config.get('callRingtoneMuted'),
click() {
config.set('callRingtoneMuted', !config.get('callRingtoneMuted'));
}
},
{
label: 'Show Unread Badge',
type: 'checkbox',
Expand Down

0 comments on commit 5daa934

Please sign in to comment.