Skip to content
Open
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
6 changes: 6 additions & 0 deletions lib/core/misc/demo_mode_status.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: Apache-2.0
// Copyright 2026 BitCodersNN

class DemoModeStatus {
static bool demoModeEnabled = false;
}
16 changes: 14 additions & 2 deletions lib/core/viewmodels/auth_page/auth_page_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import 'package:unn_mobile/core/misc/authorisation/authorisation_request_result.dart';
import 'package:unn_mobile/core/misc/custom_errors/auth_error_messages.dart';
import 'package:unn_mobile/core/misc/demo_mode_status.dart';
import 'package:unn_mobile/core/models/authorisation/auth_data.dart';
import 'package:unn_mobile/core/providers/interfaces/authorisation/auth_data_provider.dart';
import 'package:unn_mobile/core/services/interfaces/authorisation/unn_authorisation_service.dart';
Expand Down Expand Up @@ -32,21 +33,32 @@ class AuthPageViewModel extends BaseViewModel {
_resetAuthError();

AuthRequestResult? authResult;
final shouldEnableDemo =
user.startsWith('53effbc2-242e-43c1-9046-6580b77cccdb-');

final actualUserName = shouldEnableDemo ? user.substring(37) : user;
Copy link
Member

@Namxobick Namxobick Mar 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

final demoUserPrefix = '53effbc2-242e-43c1-9046-6580b77cccdb-';

user.substring(demoUserPrefix.length)


try {
authResult = await _authorisationService.auth(user, password);
authResult = await _authorisationService.auth(
actualUserName,
password,
);
} catch (error, stackTrace) {
_loggerService.logError(error, stackTrace);
}

if (authResult == AuthRequestResult.success) {
await _authDataProvider.saveData(AuthData(user, password));
await _authDataProvider.saveData(AuthData(actualUserName, password));
} else {
authResult != null
? _setAuthError(text: authResult.errorMessage)
: _setAuthError();
}

if (authResult == AuthRequestResult.success) {
DemoModeStatus.demoModeEnabled = shouldEnableDemo;
}

setState(ViewState.idle);
return authResult == AuthRequestResult.success;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import 'dart:io';

import 'package:unn_mobile/core/constants/date_pattern.dart';
import 'package:unn_mobile/core/misc/date_time_utilities/date_time_extensions.dart';
import 'package:unn_mobile/core/misc/demo_mode_status.dart';
import 'package:unn_mobile/core/models/certificate/certificate.dart';
import 'package:unn_mobile/core/models/certificate/practice_order.dart';
import 'package:unn_mobile/core/services/interfaces/certificate/certificate_downloader_service.dart';
Expand Down Expand Up @@ -68,6 +69,9 @@ class CertificateItemViewModel extends BaseViewModel {
}

Future<void> askForPath() async => await busyCallAsync(() async {
if (DemoModeStatus.demoModeEnabled) {
return;
}
if (_certificate == null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'dart:math';
import 'package:unn_mobile/core/aggregators/interfaces/message_service_aggregator.dart';
import 'package:unn_mobile/core/misc/authorisation/try_login_and_retrieve_data.dart';
import 'package:unn_mobile/core/misc/date_time_utilities/date_time_extensions.dart';
import 'package:unn_mobile/core/misc/demo_mode_status.dart';
import 'package:unn_mobile/core/misc/objects_with_pagination.dart';
import 'package:unn_mobile/core/misc/user/current_user_sync_storage.dart';
import 'package:unn_mobile/core/models/common/file_data.dart';
Expand Down Expand Up @@ -311,6 +312,9 @@ class ChatInsideViewModel extends BaseViewModel {
int chatId,
List<Message> messages,
) async {
if (DemoModeStatus.demoModeEnabled) {
return;
}
await _messagesAggregator.readMessages(
chatId: chatId,
messageIds: messages.map((m) => m.messageId),
Expand All @@ -321,6 +325,9 @@ class ChatInsideViewModel extends BaseViewModel {
FutureOr<T?> Function() sendFunction,
) async =>
await typedBusyCallAsync<bool>(() async {
if (DemoModeStatus.demoModeEnabled) {
return false;
}
if (_dialog == null) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'dart:async';

import 'package:injector/injector.dart';
import 'package:unn_mobile/core/aggregators/interfaces/message_reaction_service_aggregator.dart';
import 'package:unn_mobile/core/misc/demo_mode_status.dart';
import 'package:unn_mobile/core/models/feed/rating_list.dart';
import 'package:unn_mobile/core/models/profile/user_short_info.dart';
import 'package:unn_mobile/core/viewmodels/factories/message_reaction_view_model_factory.dart';
Expand Down Expand Up @@ -32,6 +33,9 @@ class MessageReactionViewModel extends ReactionViewModelBase {

@override
FutureOr<void> setReaction(ReactionType? reaction) async {
if (DemoModeStatus.demoModeEnabled) {
return;
}
if (profileId == ReactionViewModelBase.noId) {
return;
}
Expand Down
7 changes: 7 additions & 0 deletions lib/core/viewmodels/main_page/feed/feed_post_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import 'package:event/event.dart';
import 'package:html_unescape/html_unescape.dart';
import 'package:injector/injector.dart';
import 'package:unn_mobile/core/misc/demo_mode_status.dart';
import 'package:unn_mobile/core/models/feed/blog_post.dart';
import 'package:unn_mobile/core/models/feed/blog_post_data.dart';
import 'package:unn_mobile/core/providers/interfaces/feed/last_feed_load_date_time_provider.dart';
Expand Down Expand Up @@ -123,6 +124,9 @@ class FeedPostViewModel extends BaseViewModel {
}

Future<void> togglePin() async {
if (DemoModeStatus.demoModeEnabled) {
return;
}
final pinnedId = blogData.pinnedId ?? 0;
final success = isPinned
? await _pinningService.unpin(pinnedId)
Expand All @@ -135,6 +139,9 @@ class FeedPostViewModel extends BaseViewModel {
}

Future<void> markReadIfImportant() async {
if (DemoModeStatus.demoModeEnabled) {
return;
}
if (!isAnnouncement) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions lib/core/viewmodels/main_page/feed/reaction_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Copyright 2025 BitCodersNN

import 'package:injector/injector.dart';
import 'package:unn_mobile/core/misc/demo_mode_status.dart';
import 'package:unn_mobile/core/models/feed/rating_list.dart';
import 'package:unn_mobile/core/models/profile/user_short_info.dart';
import 'package:unn_mobile/core/services/interfaces/feed/legacy/getting_rating_list.dart';
Expand Down Expand Up @@ -70,6 +71,9 @@ class ReactionViewModel extends ReactionViewModelBase {

@override
Future<void> setReaction(ReactionType? reaction) async {
if (DemoModeStatus.demoModeEnabled) {
return;
}
if (profileId == ReactionViewModelBase.noId) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: unn_mobile
description: A mobile application for UNN Portal website
publish_to: 'none'

version: 0.6.0+392
version: 0.6.0+395

environment:
sdk: '>=3.1.2 <4.0.0'
Expand Down