about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorMichael Vetter <jubalh@iodoru.org>2020-05-25 13:49:24 +0200
committerMichael Vetter <jubalh@iodoru.org>2020-05-25 13:49:24 +0200
commit438552c14cd5fc32adcc39f5a88fd2c0a17242b2 (patch)
treeff8dd55c149e46ebdbb9818e23934c0df0d0272e /src
parent1cfab017a44b3059dc811eebd1d92edf794defb4 (diff)
downloadprofani-tty-438552c14cd5fc32adcc39f5a88fd2c0a17242b2.tar.gz
Save bookmark ignore list
Diffstat (limited to 'src')
-rw-r--r--src/command/cmd_funcs.c2
-rw-r--r--src/tools/bookmark_ignore.c18
2 files changed, 19 insertions, 1 deletions
diff --git a/src/command/cmd_funcs.c b/src/command/cmd_funcs.c
index 83a050ed..7d9f92f2 100644
--- a/src/command/cmd_funcs.c
+++ b/src/command/cmd_funcs.c
@@ -4780,7 +4780,7 @@ cmd_bookmark_ignore(ProfWin *window, const char *const command, gchar **args)
 
     // `/bookmark ignore` lists them
     if (args[1] == NULL) {
-        gsize len;
+        gsize len = 0;
         gchar **list = bookmark_ignore_list(&len);
         cons_show_bookmarks_ignore(list, len);
         g_strfreev(list);
diff --git a/src/tools/bookmark_ignore.c b/src/tools/bookmark_ignore.c
index 2be65d5f..5e6a43c5 100644
--- a/src/tools/bookmark_ignore.c
+++ b/src/tools/bookmark_ignore.c
@@ -63,6 +63,22 @@ _bookmark_ignore_load()
     free(bi_loc);
 }
 
+static void
+_bookmark_save()
+{
+    gsize g_data_size;
+    gchar *g_bookmark_ignore_data = g_key_file_to_data(bookmark_ignore_keyfile, &g_data_size, NULL);
+
+    char *bi_loc;
+    bi_loc = files_get_data_path(FILE_BOOKMARK_AUTOJOIN_IGNORE);
+
+    g_file_set_contents(bi_loc, g_bookmark_ignore_data, g_data_size, NULL);
+    g_chmod(bi_loc, S_IRUSR | S_IWUSR);
+
+    free(bi_loc);
+    g_free(g_bookmark_ignore_data);
+}
+
 void
 bookmark_ignore_on_connect(const char *const barejid)
 {
@@ -96,10 +112,12 @@ void
 bookmark_ignore_add(const char *const barejid)
 {
     g_key_file_set_boolean(bookmark_ignore_keyfile, account_jid, barejid, TRUE);
+    _bookmark_save();
 }
 
 void
 bookmark_ignore_remove(const char *const barejid)
 {
     g_key_file_remove_key(bookmark_ignore_keyfile, account_jid, barejid, NULL);
+    _bookmark_save();
 }