示例#1
0
        /// <summary>
        /// Saves current clients mute statuses if available
        /// </summary>
        public void SaveCurrentMuteStatuses()
        {
            if (UseStoredIdsStatuses && mutedIds != null)
            {
                StatusesHolder holder = new StatusesHolder();

                foreach (KeyValuePair <ulong, MuteStatus> item in mutedIds)
                {
                    //Save only information about statuses != than None value and ignore RemoteHasMutedLocal status
                    MuteStatus status = item.Value & ~MuteStatus.RemoteHasMutedLocal;
                    if (status == MuteStatus.None)
                    {
                        continue;
                    }

                    holder.IDs.Add(item.Key);
                    holder.Statuses.Add(status);
                }

                if (!Directory.Exists(SavedDataFolderPath))
                {
                    Directory.CreateDirectory(SavedDataFolderPath);
                }

                File.WriteAllText(SavedDataFilePath, JsonUtility.ToJson(holder));
            }
        }
示例#2
0
        /// <summary>
        /// Loads mute statuses from file if available
        /// </summary>
        public void LoadSavedMuteStatuses()
        {
            if (UseStoredIdsStatuses && mutedIds != null)
            {
                StatusesHolder holder = new StatusesHolder();
                if (File.Exists(SavedDataFilePath))
                {
                    JsonUtility.FromJsonOverwrite(File.ReadAllText(SavedDataFilePath), holder);

                    int length = Mathf.Min(holder.IDs.Count, holder.Statuses.Count);

                    for (int i = 0; i < length; i++)
                    {
                        mutedIds[holder.IDs[i]] = holder.Statuses[i];
                    }
                }
            }
        }