Skip to content
This repository was archived by the owner on Aug 4, 2023. It is now read-only.

Commit a35d2d2

Browse files
committed
Marking the inital news as read, fixed icon bindings in the sidebar
1 parent b0b8f25 commit a35d2d2

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

app/common/firebase.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ interface FirebaseArticle {
1616
readonly date: string;
1717
}
1818

19+
const FIREBASE_NEWS_INITAL = "firebase:news:inital";
1920
const FIREBASE_NEWS_READ_KEY = "firebase:news:read";
2021
let _readArticles;
2122
function loadReadArticles() {
@@ -50,10 +51,24 @@ function markAsRead(id: string) {
5051
loadReadArticles()[id] = true;
5152
saveReadArticles();
5253
}
54+
function markAllAsRead() {
55+
let readArticles = loadReadArticles();
56+
viewModel.news.filter(n => n && n.id).forEach(n => readArticles[n.id] = true);
57+
console.log("Maked as read: " + JSON.stringify(readArticles));
58+
saveReadArticles();
59+
viewModel.updateHasUnreadNews();
60+
}
5361
function markAsUnread(id: string) {
5462
loadReadArticles()[id] = false;
5563
saveReadArticles();
5664
}
65+
function markAllAsReadOnFirstRun() {
66+
const isInitalRun = settings.getBoolean(FIREBASE_NEWS_INITAL, true);
67+
if (isInitalRun) {
68+
markAllAsRead();
69+
settings.setBoolean(FIREBASE_NEWS_INITAL, false);
70+
}
71+
}
5772

5873
export class Article extends Observable {
5974
readonly id: string;
@@ -199,6 +214,7 @@ function firebaseInit() {
199214
if (!result.error) {
200215
console.log("Update news: " + JSON.stringify(result.value))
201216
viewModel.updateNews(result.value || []);
217+
markAllAsReadOnFirstRun();
202218
} else {
203219
console.log(JSON.stringify(result));
204220
}

app/views/main-page/main-page.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<sdp:DrawerPage.actionBar>
2222
<ActionBar automationText="ActionBar" android:opacity="0">
2323
<android>
24-
<NavigationButton icon="{{ firebase.hasUnreadNews ? 'res://ic_menu_main_new' : 'res://ic_menu_main' }}" tap="showSlideout" automationText="SidebarMenu" />
24+
<NavigationButton icon="{{ firebase.hasUnreadNews, firebase.hasUnreadNews ? 'res://ic_menu_main_new' : 'res://ic_menu_main' }}" tap="showSlideout" automationText="SidebarMenu" />
2525
</android>
2626
<ActionBar.actionItems>
2727
<iOS>

app/views/side-drawer-content/side-drawer-content.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
<GridLayout class="drawer-news-link" tap="tapWhatIsNew">
99
<GridLayout class="drawer-news-icon">
10-
<Image src="res://ic_notification" visibility="{{ firebase.hasUnreadNews, firebase.hasUnreadNews ? 'visible' : 'collapse' }}" width="10" height="10" horizontalAlignment="left" />
10+
<Image src="res://ic_notification" opacity="{{ firebase.hasUnreadNews, (firebase && firebase.hasUnreadNews) ? 1 : 0 }}" width="10" height="10" horizontalAlignment="left" />
1111
<Label text="What's new" class="drawer-news-label" margin="0 18" />
1212
</GridLayout>
1313
</GridLayout>

app/views/what-is-new.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import * as firebase from "../common/firebase";
22
import * as utils from "utils/utils";
33
import { isIOS } from "platform";
4+
import * as navigator from "../common/navigator";
5+
import * as gestures from "ui/gestures";
46

57
export function navigatingTo(args) {
68
args.object.bindingContext = firebase.viewModel;
@@ -21,4 +23,8 @@ export function listViewItemLoading(args) {
2123
var cell = args.ios;
2224
cell.selectionStyle = UITableViewCellSelectionStyle.UITableViewCellSelectionStyleNone;
2325
}
24-
}
26+
}
27+
28+
export function goBack(args: gestures.GestureEventData) {
29+
navigator.navigateBack();
30+
}

firebase.nativescript.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"using_android": true,
44
"remote_config": false,
55
"messaging": true,
6+
"crash_reporting": false,
67
"storage": true,
78
"facebook_auth": false,
89
"google_auth": false

0 commit comments

Comments
 (0)