fix subscription notifications (#52)
This commit is contained in:
parent
f0a3eec80b
commit
c203aa914c
4 changed files with 38 additions and 42 deletions
4
package-lock.json
generated
4
package-lock.json
generated
|
@ -5649,8 +5649,8 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"lbryinc": {
|
"lbryinc": {
|
||||||
"version": "github:lbryio/lbryinc#67bb3e215be3f13605c5e3f9f2b0e2fb880724cf",
|
"version": "github:lbryio/lbryinc#c55a2c98ab92c72149c824ee5906aed4404fd89b",
|
||||||
"from": "github:lbryio/lbryinc#67bb3e215be3f13605c5e3f9f2b0e2fb880724cf",
|
"from": "github:lbryio/lbryinc#c55a2c98ab92c72149c824ee5906aed4404fd89b",
|
||||||
"requires": {
|
"requires": {
|
||||||
"reselect": "^3.0.0"
|
"reselect": "^3.0.0"
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
"@expo/vector-icons": "^8.1.0",
|
"@expo/vector-icons": "^8.1.0",
|
||||||
"gfycat-style-urls": "^1.0.3",
|
"gfycat-style-urls": "^1.0.3",
|
||||||
"lbry-redux": "lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3",
|
"lbry-redux": "lbryio/lbry-redux#7ec72a737bcd336f000c5f5085891643110298c3",
|
||||||
"lbryinc": "lbryio/lbryinc#67bb3e215be3f13605c5e3f9f2b0e2fb880724cf",
|
"lbryinc": "lbryio/lbryinc#c55a2c98ab92c72149c824ee5906aed4404fd89b",
|
||||||
"lodash": ">=4.17.11",
|
"lodash": ">=4.17.11",
|
||||||
"merge": ">=1.2.1",
|
"merge": ">=1.2.1",
|
||||||
"moment": "^2.22.1",
|
"moment": "^2.22.1",
|
||||||
|
|
|
@ -83,7 +83,7 @@ const compressor = createCompressor();
|
||||||
const authFilter = createFilter('auth', ['authToken']);
|
const authFilter = createFilter('auth', ['authToken']);
|
||||||
const contentFilter = createFilter('content', ['positions']);
|
const contentFilter = createFilter('content', ['positions']);
|
||||||
const saveClaimsFilter = createFilter('claims', ['claimsByUri']);
|
const saveClaimsFilter = createFilter('claims', ['claimsByUri']);
|
||||||
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions']);
|
const subscriptionsFilter = createFilter('subscriptions', ['enabledChannelNotifications', 'subscriptions', 'latest']);
|
||||||
const settingsFilter = createFilter('settings', ['clientSettings']);
|
const settingsFilter = createFilter('settings', ['clientSettings']);
|
||||||
const tagsFilter = createFilter('tags', ['followedTags']);
|
const tagsFilter = createFilter('tags', ['followedTags']);
|
||||||
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
const walletFilter = createFilter('wallet', ['receiveAddress']);
|
||||||
|
|
|
@ -61,11 +61,10 @@ class DiscoverPage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { sortByItem, fetchRewardedContent, fetchSubscriptions, fileList, followedTags } = this.props;
|
const { sortByItem, fetchRewardedContent, fileList, followedTags } = this.props;
|
||||||
|
|
||||||
this.buildTagCollection(followedTags);
|
this.buildTagCollection(followedTags);
|
||||||
fetchRewardedContent();
|
fetchRewardedContent();
|
||||||
fetchSubscriptions();
|
|
||||||
fileList();
|
fileList();
|
||||||
|
|
||||||
this.handleSortByItemSelected(sortByItem);
|
this.handleSortByItemSelected(sortByItem);
|
||||||
|
@ -88,9 +87,11 @@ class DiscoverPage extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
onComponentFocused = () => {
|
onComponentFocused = () => {
|
||||||
const { pushDrawerStack } = this.props;
|
const { fetchSubscriptions, pushDrawerStack } = this.props;
|
||||||
// pushDrawerStack();
|
// pushDrawerStack();
|
||||||
NativeModules.Firebase.setCurrentScreen('Your tags');
|
NativeModules.Firebase.setCurrentScreen('Your tags').then(result => {
|
||||||
|
fetchSubscriptions();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
handleSortByItemSelected = item => {
|
handleSortByItemSelected = item => {
|
||||||
|
@ -127,44 +128,39 @@ class DiscoverPage extends React.PureComponent {
|
||||||
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
const { unreadSubscriptions, enabledChannelNotifications } = this.props;
|
||||||
|
|
||||||
const utility = NativeModules.UtilityModule;
|
const utility = NativeModules.UtilityModule;
|
||||||
if (utility) {
|
const hasUnread =
|
||||||
const hasUnread =
|
prevProps.unreadSubscriptions &&
|
||||||
prevProps.unreadSubscriptions &&
|
prevProps.unreadSubscriptions.length !== unreadSubscriptions.length &&
|
||||||
prevProps.unreadSubscriptions.length !== unreadSubscriptions.length &&
|
unreadSubscriptions.length > 0;
|
||||||
unreadSubscriptions.length > 0;
|
|
||||||
|
|
||||||
if (hasUnread) {
|
if (hasUnread) {
|
||||||
unreadSubscriptions.map(({ channel, uris }) => {
|
unreadSubscriptions.map(({ channel, uris }) => {
|
||||||
const { claimName: channelName } = parseURI(channel);
|
const { claimName: channelName } = parseURI(channel);
|
||||||
|
|
||||||
// check if notifications are enabled for the channel
|
// check if notifications are enabled for the channel
|
||||||
if (enabledChannelNotifications.indexOf(channelName) > -1) {
|
if (enabledChannelNotifications.includes(channelName)) {
|
||||||
uris.forEach(uri => {
|
uris.forEach(uri => {
|
||||||
Lbry.resolve({ urls: uri }).then(result => {
|
Lbry.resolve({ urls: uri }).then(result => {
|
||||||
const sub = result[uri].claim;
|
const sub = result[uri];
|
||||||
if (sub && sub.value && sub.value.stream) {
|
|
||||||
let isPlayable = false;
|
if (sub && sub.value) {
|
||||||
const source = sub.value.stream.source;
|
const { source, title, thumbnail } = sub.value;
|
||||||
const metadata = sub.value.stream.metadata;
|
const isPlayable =
|
||||||
if (source) {
|
source && source.media_type && ['audio', 'video'].includes(source.media_type.substring(0, 5));
|
||||||
isPlayable =
|
if (title) {
|
||||||
source.contentType && ['audio', 'video'].indexOf(source.contentType.substring(0, 5)) > -1;
|
utility.showNotificationForContent(
|
||||||
}
|
uri,
|
||||||
if (metadata) {
|
title,
|
||||||
utility.showNotificationForContent(
|
channelName,
|
||||||
uri,
|
thumbnail ? thumbnail.url : null,
|
||||||
metadata.title,
|
isPlayable
|
||||||
channelName,
|
);
|
||||||
metadata.thumbnail,
|
|
||||||
isPlayable
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue