Skip to content
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

[DDW-824] Fix app update on specific platform #2759

Merged
merged 7 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
### Features

- Updated slider component to only execute onAfterChange if slider had moved ([PR 2766](https://github.com/input-output-hk/daedalus/pull/2766))
- Fixed app update for specific platform ([PR 2759](https://github.com/input-output-hk/daedalus/pull/2759))

## 4.5.2

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
{
"updatedAt": 1637233200000,
"items": [
{
"title": {
"en-US": "NEW Daedalus 5.1.0 update",
"ja-JP": "最新更新版Daedalus 5.1.0配信"
},
"content": {
"en-US": "Daedalus 5.1.0 for the Cardano mainnet has an improved voting screen layout, which now includes continuous registration for Catalyst projects and footer links. The update also adds a pool over-saturation warning.\n\nPlease read the [release notes](https://iohk.zendesk.com/hc/en-us/articles/4409360119449) for more information.",
"ja-JP": "Cardanoメインネット用Daedalus 5.1.0は、投票画面のレイアウトを改良し、Catalystプロジェクトとフッターのリンクに継続登録を追加しました。この更新ではさらに、プールの過剰飽和警告も追加されました。\n\n詳細は[リリースノート](https://iohk.zendesk.com/hc/ja/articles/4409360119449)をご覧ください。"
},
"target": {
"daedalusVersion": ">=2.3.0 <5.1.0",
"platforms":["win32","darwin","linux"]
},
"action": {
"label": {
"en-US": "",
"ja-JP": ""
},
"url": {
"en-US": "",
"ja-JP": ""
}
},
"date": 1637233200000,
"type": "software-update",
"softwareUpdate": {
"linux": {
"version": "5.1.0",
"hash": "611adbfe653ca8c559e3733559590851018d6914800ac3460854f457651e9c10",
"url": "https://update-cardano-mainnet.iohk.io/daedalus-4.5.0-mainnet-19689.bin"
},
"darwin": {
"version": "5.1.0",
"hash": "2c2e7e46719cf56505a6acaaac8da80345cc3b9c16ed2129489f55dc3f4969e2",
"url": "https://update-cardano-mainnet.iohk.io/daedalus-4.5.0-mainnet-19689.pkg"
},
"win32": {
"version": "5.1.0",
"hash": "2c2e7e46719cf56505a6acaaac8da80345cc3b9c16ed2129489f55dc3f4969e2",
"url": "https://update-cardano-mainnet.iohk.io/daedalus-4.5.0-mainnet-19689.pkg"
}
}
},
{
"title": {
"en-US": "NEW Daedalus 5.1.1 update",
"ja-JP": "最新更新版Daedalus 5.1.1配信"
},
"content": {
"en-US": "Daedalus 5.1.1 for the Cardano mainnet has an improved voting screen layout, which now includes continuous registration for Catalyst projects and footer links. The update also adds a pool over-saturation warning.\n\nPlease read the [release notes](https://iohk.zendesk.com/hc/en-us/articles/4409360119449) for more information.",
"ja-JP": "Cardanoメインネット用Daedalus 5.1.1は、投票画面のレイアウトを改良し、Catalystプロジェクトとフッターのリンクに継続登録を追加しました。この更新ではさらに、プールの過剰飽和警告も追加されました。\n\n詳細は[リリースノート](https://iohk.zendesk.com/hc/ja/articles/4409360119449)をご覧ください。"
},
"target": {
"daedalusVersion": ">=5.1.0 <5.1.1",
"platforms":["win32"]
},
"action": {
"label": {
"en-US": "",
"ja-JP": ""
},
"url": {
"en-US": "",
"ja-JP": ""
}
},
"date": 1637233200001,
"type": "software-update",
"softwareUpdate": {
"win32": {
"version": "5.1.1",
"hash": "50af385a0c12f86fc812e08eda8741f4ccd32367ed421fcaf4cbcea2c57e1b4e",
"url": "https://update-cardano-mainnet.iohk.io/daedalus-4.5.1-mainnet-19689.exe"
}
}
},
{
"title": {
"en-US": "Daedalus 5.1.0 - Release notes",
"ja-JP": "Daedalus 5.1.0 - リリースノート"
},
"content": {
"en-US": "Daedalus 5.1.0 for the Cardano mainnet has an improved voting screen layout, which now includes continuous registration for Catalyst projects and footer links. The update also adds a pool over-saturation warning.",
"ja-JP": "Cardanoメインネット用Daedalus 5.1.0は、投票画面のレイアウトを改良し、Catalystプロジェクトとフッターのリンクに継続登録を追加しました。この更新ではさらに、プールの過剰飽和警告も追加されました。"
},
"target": {
"daedalusVersion": "5.1.0",
"platforms":["darwin","win32","linux"]
},
"action": {
"label": {
"en-US": "Release notes",
"ja-JP": "リリースノート"
},
"url": {
"en-US": "https://iohk.zendesk.com/hc/en-us/articles/4409360119449",
"ja-JP": "https://iohk.zendesk.com/hc/ja/articles/4409360119449"
}
},
"date": 1637233200000,
"type": "announcement"
},
{
"title": {
"en-US": "Daedalus 5.1.1 - Release notes",
"ja-JP": "Daedalus 5.1.1 - リリースノート"
},
"content": {
"en-US": "Daedalus 5.1.1 for the Cardano mainnet has an improved voting screen layout, which now includes continuous registration for Catalyst projects and footer links. The update also adds a pool over-saturation warning.",
"ja-JP": "Cardanoメインネット用Daedalus 5.1.1は、投票画面のレイアウトを改良し、Catalystプロジェクトとフッターのリンクに継続登録を追加しました。この更新ではさらに、プールの過剰飽和警告も追加されました。"
},
"target": {
"daedalusVersion": "5.1.1",
"platforms":["darwin","win32","linux"]
},
"action": {
"label": {
"en-US": "Release notes",
"ja-JP": "リリースノート"
},
"url": {
"en-US": "https://iohk.zendesk.com/hc/en-us/articles/4409360119449",
"ja-JP": "https://iohk.zendesk.com/hc/ja/articles/4409360119449"
}
},
"date": 1637233200001,
"type": "announcement"
},
{
"title": {
"en-US": "Stay safe from scammers - some important advice",
"ja-JP": "詐欺にご注意ください - 重要なアドバイス"
},
"content": {
"en-US": "Read the post on how to stay safe and spot potential Daedalus and Cardano scams.",
"ja-JP": "安全性に注意する方法、そして、DaedalusとCardanoの詐欺の可能性を見抜く方法についての記事をご覧ください。"
},
"target": {
"daedalusVersion": ">=3.0.0",
"platforms":["win32", "darwin", "linux"]
},
"action": {
"label": {
"en-US": "Read the post",
"ja-JP": "記事を読む(英語のみ)"
},
"url": {
"en-US": "https://www.reddit.com/r/cardano/comments/lccorg/psa_there_is_no_such_thing_as_cardano_giveaways/",
"ja-JP": "https://www.reddit.com/r/cardano/comments/lccorg/psa_there_is_no_such_thing_as_cardano_giveaways/"
}
},
"date": 1613757600000,
"type": "announcement"
},
{
"title": {
"en-US": "Catalyst Fund6 Results and Feedback",
"ja-JP": "Catalyst Fund6の結果とフィードバック"
},
"content": {
"en-US": "Fund6 is now finished, congratulations to all who were successful. For more details, read the [funded proposal results](https://mailchi.mp/iohk/g6qpccne38-674338).\n\nWe would now like to invite you to complete the [Fund6 exit survey](https://forms.gle/7FYP2MRaGrVDAUh87). Please let us know what you felt went well, where we could improve, and share any other ideas with us.\n\nHelp us understand where we should focus our attention and how to prioritize our future actions. We value your feedback.\n\nThank you for taking the time to improve the governance processes for Cardano.",
"ja-JP": "Fund6は終了しました。良い結果を得た皆様、おめでとうございます。詳細は、[資金調達対象となる提案の結果](https://mailchi.mp/iohk/g6qpccne38-674338)をご覧ください。\n\n皆様には、[Fund6に関するアンケート](https://forms.gle/7FYP2MRaGrVDAUh87)へのご協力をお願いいたします。良かった点、改善すべき点、その他ご意見をお聞かせください。\n\n皆様からの貴重なご意見は、どこに焦点を置くべきか、今後のアクションの優先順位についての理解を深める助けとなります。\n\nCardanoガバナンスプロセスの向上にお時間をいただき、ありがとうございます。"
},
"target": {
"daedalusVersion": ">=4.4.0",
"platforms":["win32", "darwin", "linux"]
},
"action": {
"label": {
"en-US": "Fund6 Feedback Form",
"ja-JP": "Fund6フィードバックフォーム"
},
"url": {
"en-US": "https://forms.gle/7FYP2MRaGrVDAUh87",
"ja-JP": "https://forms.gle/7FYP2MRaGrVDAUh87"
}
},
"date": 1636383600000,
"type": "announcement"
}
]
}
43 changes: 28 additions & 15 deletions source/renderer/app/domains/News.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ export type NewsTypesStateType = {
read: Array<News>,
};

const { version, platform } = global.environment;

class News {
@observable id: number;
@observable title: string;
Expand Down Expand Up @@ -75,39 +73,52 @@ class News {

class NewsCollection {
@observable all: Array<News> = [];
@observable update: ?News = null;
@observable allWithAppUpdates: Array<News> = [];

constructor(data: Array<News>) {
const { version, platform } = global.environment;
// Filter news by platform and versions
const filteredNews = filter(data, (newsItem) => {
const filteredNewsWithAppUpdates = filter(data, (newsItem) => {
const availableTargetVersionRange = get(
newsItem,
['target', 'daedalusVersion'],
''
);
const targetPlatforms = get(newsItem, ['target', 'platforms']);

const isAppUpdateItem = newsItem.type === NewsTypes.UPDATE;
const hasValidItemLabelDeclaration =
isAppUpdateItem || (!isAppUpdateItem && newsItem.action.label);
return (
(!availableTargetVersionRange ||
(availableTargetVersionRange &&
semver.satisfies(version, availableTargetVersionRange, {
includePrerelease: true,
}))) &&
(platform === 'browser' || includes(targetPlatforms, platform)) &&
newsItem.type !== NewsTypes.UPDATE &&
newsItem.id &&
newsItem.title &&
newsItem.content &&
newsItem.action.label &&
hasValidItemLabelDeclaration &&
newsItem.date
);
});
const orderedNews = orderBy(filteredNews, 'date', 'desc');
const update = data.filter((item) => item.type === NewsTypes.UPDATE)[0];

const filteredNewsWithoutAppUpdates = filter(
filteredNewsWithAppUpdates,
(newsItem) => newsItem.type !== NewsTypes.UPDATE
);
const orderedNewsWithoutAppUpdates = orderBy(
filteredNewsWithoutAppUpdates,
'date',
'desc'
);
const orderedNewsWithAppUpdates = orderBy(
filteredNewsWithAppUpdates,
'date',
'desc'
);
runInAction(() => {
this.all = orderedNews;
this.update = update;
this.all = orderedNewsWithoutAppUpdates;
this.allWithAppUpdates = orderedNewsWithAppUpdates;
});
}

Expand Down Expand Up @@ -177,9 +188,11 @@ class NewsCollection {
return orderBy(read, 'date', 'asc');
}

// @computed get update(): News | null {
// return this.all.filter(item => item.type === NewsTypes.UPDATE)[0];
// }
@computed get update(): News | null {
return this.allWithAppUpdates.filter(
(item) => item.type === NewsTypes.UPDATE
)[0];
}
}

export default {
Expand Down
34 changes: 25 additions & 9 deletions source/renderer/app/stores/NewsFeedStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
MarkNewsAsReadResponse,
} from '../api/news/types';

const { isTest, isDev } = global.environment;
const { isTest, version, isDev } = global.environment;

const AVAILABLE_NEWSFEED_EVENT_ACTIONS = [
'DOWNLOAD_LOGS',
Expand All @@ -43,6 +43,7 @@ export default class NewsFeedStore extends Store {
);
@observable openedAlert: ?News.News = null;
@observable fetchLocalNews: boolean = false;
@observable rawNewsJsonQA: ?GetNewsResponse = null;

pollingNewsIntervalId: ?IntervalID = null;
pollingNewsOnErrorIntervalId: ?IntervalID = null;
Expand All @@ -63,8 +64,11 @@ export default class NewsFeedStore extends Store {
@action getNews = async (params?: { isInit: boolean }) => {
let rawNews;
try {
rawNews = await this.getNewsRequest.execute().promise;

if (this.rawNewsJsonQA && isDev) {
rawNews = this.rawNewsJsonQA;
} else {
rawNews = await this.getNewsRequest.execute().promise;
}
const hasIncident = find(
rawNews.items,
(news) => news.type === NewsTypes.INCIDENT
Expand Down Expand Up @@ -216,15 +220,28 @@ export default class NewsFeedStore extends Store {
}
};

@action setFakedNewsfeed = () => {
@action setFakedNewsfeed = (params: {
isAutomaticUpdateTest: ?boolean,
appVersion?: string,
}) => {
if (isDev) {
const { isAutomaticUpdateTest, appVersion } = params;

// Fake appVersion for news ONLY so we can check multiple cases
global.environment.version = appVersion || version;

if (this.pollingNewsIntervalId) {
clearInterval(this.pollingNewsIntervalId);
this.pollingNewsIntervalId = null;
}
const rawNews = require('../config/news.dummy.json');
this.rawNews = get(rawNews, 'items', []);
this.newsUpdatedAt = get(rawNews, 'updatedAt', null);
let rawNewsJsonQA;
if (isAutomaticUpdateTest) {
rawNewsJsonQA = require('../config/newsfeed-files/news-automatic-update.dummy.json');
} else {
rawNewsJsonQA = require('../config/news.dummy.json');
}
this.rawNewsJsonQA = rawNewsJsonQA;
this.getNews({ isInit: true });
}
};

Expand All @@ -233,7 +250,7 @@ export default class NewsFeedStore extends Store {
const readNews = this.getReadNewsRequest.result;
let news = [];

if (this.getNewsRequest.wasExecuted) {
if (this.getNewsRequest.wasExecuted || (this.rawNewsJsonQA && isDev)) {
news = map(this.rawNews, (item) => {
// Match old and new newsfeed JSON format
const mainIdentificator = item.id || item.date;
Expand Down Expand Up @@ -269,7 +286,6 @@ export default class NewsFeedStore extends Store {
return newsfeedItem;
});
}

return new News.NewsCollection(news);
}

Expand Down