Skip to content

Commit

Permalink
feat: change caching address
Browse files Browse the repository at this point in the history
  • Loading branch information
sparcscasio committed Aug 15, 2024
1 parent abd681b commit 45ac9f1
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions lib/pages/post_write_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,16 @@ class _PostWritePageState extends State<PostWritePage>

bool _isKeyboardClosed = true;

String userID = '';

final _editorScrollController = ScrollController();
@override
void initState() {
super.initState();
UserProvider userProvider = context.read<UserProvider>();

userID = userProvider.naUser!.uid;

context.read<NotificationProvider>().checkIsNotReadExist(userProvider);
debugPrint("post_write_page.dart: ${widget.previousBoard}");
if (widget.previousArticle != null) {
Expand Down Expand Up @@ -289,10 +293,13 @@ class _PostWritePageState extends State<PostWritePage>

data['attachments'] = _attachmentList;

String key =
_isEditingPost ? '/cache/${widget.previousArticle!.id}/' : '/cache/';
String key = _isEditingPost
? '/cache/${widget.previousArticle!.id}/'
: '/cache/${userID}/';

await cacheApiData(key, data);
print(key);
print(data);
}

/// 사용자가 선택 가능한 게시판 목록을 가져오는 함수.
Expand Down Expand Up @@ -356,8 +363,9 @@ class _PostWritePageState extends State<PostWritePage>
}

Future<void> _getCachedContents() async {
String key =
(_isEditingPost) ? '/cache/${widget.previousArticle!.id}/' : '/cache/';
String key = (_isEditingPost)
? '/cache/${widget.previousArticle!.id}/'
: '/cache/${userID}/';
dynamic cachedData = await fetchCachedApiData(key);
debugPrint('cache : ${cachedData}');
if (cachedData == null && _isEditingPost) {
Expand Down Expand Up @@ -528,7 +536,7 @@ class _PostWritePageState extends State<PostWritePage>
//dialog pop
String key = _isEditingPost
? '/cache/${widget.previousArticle!.id}/'
: '/cache/';
: '/cache/${userID}';
await cacheApiData(key, null);
Navigator.pop(context, true);
},
Expand Down Expand Up @@ -599,7 +607,7 @@ class _PostWritePageState extends State<PostWritePage>
// try-catch 문을 도입함.
String key = _isEditingPost
? '/cache/${widget.previousArticle!.id}/'
: '/cache/';
: '/cache/${userID}';
await cacheApiData(key, null);
try {
Navigator.of(context)
Expand Down

0 comments on commit 45ac9f1

Please sign in to comment.