Skip to content

Commit

Permalink
add edit history to website
Browse files Browse the repository at this point in the history
  • Loading branch information
IoanaAlexandru committed Apr 14, 2020
1 parent 3668939 commit 3e0a519
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/pages/portal/model/website.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class Website {
/// Whether the website is public or part of user data
final bool isPrivate;

final List<String> editedBy;

final WebsiteCategory category;
final String iconPath;
final String label;
Expand All @@ -42,12 +44,14 @@ class Website {
{this.ownerUid,
@required this.id,
@required this.isPrivate,
List<String> editedBy,
@required this.category,
this.iconPath,
String label,
@required String link,
this.infoByLocale})
: this.label = toString(label).isEmpty ? labelFromLink(link) : label,
: this.editedBy = editedBy ?? [],
this.label = toString(label).isEmpty ? labelFromLink(link) : label,
this.link = link;

static String labelFromLink(String link) => link.split('://').last;
Expand Down
2 changes: 2 additions & 0 deletions lib/pages/portal/service/website_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ extension WebsiteExtension on Website {
ownerUid: ownerUid ?? snap.data['addedBy'],
id: snap.documentID,
isPrivate: ownerUid != null,
editedBy: List<String>.from(snap.data['editedBy'] ?? []),
category: WebsiteCategoryExtension.fromString(snap.data['category']),
iconPath: snap.data['icon'] ?? 'icons/websites/globe.png',
label: snap.data['label'] ?? 'Website',
Expand All @@ -50,6 +51,7 @@ extension WebsiteExtension on Website {

if (!isPrivate) {
if (ownerUid != null) data['addedBy'] = ownerUid;
data['editedBy'] = editedBy;
data['relevance'] = null; // TODO: Make relevance customizable
}

Expand Down
1 change: 1 addition & 0 deletions lib/pages/portal/view/website_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class _WebsiteViewState extends State<WebsiteView> {
ownerUid:
widget.website != null ? widget.website.ownerUid : _user?.uid,
isPrivate: _onlyMeController.isSelected ?? true,
editedBy: (widget.website?.editedBy ?? []) + [_user?.uid],
label: _labelController.text,
link: _linkController.text,
category: _selectedCategory,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: A mobile application for students at ACS UPB.
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.4.2+3
version: 0.4.3+1

environment:
sdk: ">=2.6.0 <3.0.0"
Expand Down

0 comments on commit 3e0a519

Please sign in to comment.