workspace

This commit is contained in:
Ashita Prasad
2024-09-08 15:17:21 +05:30
parent bd5c83525e
commit 802d9e4607
14 changed files with 220 additions and 67 deletions

View File

@ -14,6 +14,7 @@ class SettingsModel {
this.promptBeforeClosing = true,
this.activeEnvironmentId,
this.historyRetentionPeriod = HistoryRetentionPeriod.oneWeek,
this.workspaceFolderPath,
});
final bool isDark;
@ -26,6 +27,7 @@ class SettingsModel {
final bool promptBeforeClosing;
final String? activeEnvironmentId;
final HistoryRetentionPeriod historyRetentionPeriod;
final String? workspaceFolderPath;
SettingsModel copyWith({
bool? isDark,
@ -38,6 +40,7 @@ class SettingsModel {
bool? promptBeforeClosing,
String? activeEnvironmentId,
HistoryRetentionPeriod? historyRetentionPeriod,
String? workspaceFolderPath,
}) {
return SettingsModel(
isDark: isDark ?? this.isDark,
@ -52,6 +55,7 @@ class SettingsModel {
activeEnvironmentId: activeEnvironmentId ?? this.activeEnvironmentId,
historyRetentionPeriod:
historyRetentionPeriod ?? this.historyRetentionPeriod,
workspaceFolderPath: workspaceFolderPath ?? this.workspaceFolderPath,
);
}
@ -86,8 +90,7 @@ class SettingsModel {
final promptBeforeClosing = data["promptBeforeClosing"] as bool?;
final activeEnvironmentId = data["activeEnvironmentId"] as String?;
final historyRetentionPeriodStr = data["historyRetentionPeriod"] as String?;
HistoryRetentionPeriod historyRetentionPeriod =
HistoryRetentionPeriod.oneWeek;
HistoryRetentionPeriod? historyRetentionPeriod;
if (historyRetentionPeriodStr != null) {
try {
historyRetentionPeriod =
@ -96,6 +99,7 @@ class SettingsModel {
// pass
}
}
final workspaceFolderPath = data["workspaceFolderPath"] as String?;
const sm = SettingsModel();
@ -109,7 +113,9 @@ class SettingsModel {
saveResponses: saveResponses,
promptBeforeClosing: promptBeforeClosing,
activeEnvironmentId: activeEnvironmentId,
historyRetentionPeriod: historyRetentionPeriod,
historyRetentionPeriod:
historyRetentionPeriod ?? HistoryRetentionPeriod.oneWeek,
workspaceFolderPath: workspaceFolderPath,
);
}
@ -127,12 +133,13 @@ class SettingsModel {
"promptBeforeClosing": promptBeforeClosing,
"activeEnvironmentId": activeEnvironmentId,
"historyRetentionPeriod": historyRetentionPeriod.name,
"workspaceFolderPath": workspaceFolderPath,
};
}
@override
String toString() {
return toJson().toString();
return kJsonEncoder.convert(toJson());
}
@override
@ -149,7 +156,8 @@ class SettingsModel {
other.saveResponses == saveResponses &&
other.promptBeforeClosing == promptBeforeClosing &&
other.activeEnvironmentId == activeEnvironmentId &&
other.historyRetentionPeriod == historyRetentionPeriod;
other.historyRetentionPeriod == historyRetentionPeriod &&
other.workspaceFolderPath == workspaceFolderPath;
}
@override
@ -166,6 +174,7 @@ class SettingsModel {
promptBeforeClosing,
activeEnvironmentId,
historyRetentionPeriod,
workspaceFolderPath,
);
}
}